blob: f6c344126b8367bf0899039a179e901bdc24bb69 [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:
5083 return "Speaker";
5084 case AUTO_PIN_HP_OUT:
5085 return "Headphone";
5086 default:
5087 if (cfg->line_outs == 1)
5088 return "PCM";
5089 break;
5090 }
5091 return NULL;
5092}
5093
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005094/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01005095static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
5096 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005097{
Takashi Iwaiea734962011-01-17 11:29:34 +01005098 static const char * const chname[4] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005099 "Front", "Surround", NULL /*CLFE*/, "Side"
5100 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005101 const char *pfx = alc_get_line_out_pfx(cfg, false);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005102 hda_nid_t nid;
5103 int i, err;
5104
5105 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005106 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005107 continue;
5108 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005109 if (!pfx && i == 2) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005110 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005111 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5112 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005113 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
5114 HDA_OUTPUT));
5115 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005116 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005117 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5118 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005119 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
5120 HDA_OUTPUT));
5121 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005122 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005123 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5124 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005125 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
5126 HDA_INPUT));
5127 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005128 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005129 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5130 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005131 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
5132 HDA_INPUT));
5133 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005134 return err;
5135 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005136 const char *name = pfx;
5137 if (!name)
5138 name = chname[i];
5139 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5140 name, i,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005141 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
5142 HDA_OUTPUT));
5143 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005144 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005145 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5146 name, i,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005147 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
5148 HDA_INPUT));
5149 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005150 return err;
5151 }
5152 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005153 return 0;
5154}
5155
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005156/* add playback controls for speaker and HP outputs */
5157static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
5158 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005159{
5160 hda_nid_t nid;
5161 int err;
5162
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005163 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005164 return 0;
5165
5166 if (alc880_is_fixed_pin(pin)) {
5167 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01005168 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005169 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005170 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005171 else
5172 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005173 /* control HP volume/switch on the output mixer amp */
5174 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005175 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005176 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
5177 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005178 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005179 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005180 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
5181 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005182 return err;
5183 } else if (alc880_is_multi_pin(pin)) {
5184 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005185 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005186 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005187 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
5188 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005189 return err;
5190 }
5191 return 0;
5192}
5193
5194/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005195static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005196 const char *ctlname, int ctlidx,
Kailang Yangdf694da2005-12-05 19:42:22 +01005197 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005198{
Kailang Yangdf694da2005-12-05 19:42:22 +01005199 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005200
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005201 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005202 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5203 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005204 return err;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005205 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005206 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5207 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005208 return err;
5209 return 0;
5210}
5211
Takashi Iwai05f5f472009-08-25 13:10:18 +02005212static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005213{
Takashi Iwai05f5f472009-08-25 13:10:18 +02005214 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
5215 return (pincap & AC_PINCAP_IN) != 0;
5216}
5217
5218/* create playback/capture controls for input pins */
5219static int alc_auto_create_input_ctls(struct hda_codec *codec,
5220 const struct auto_pin_cfg *cfg,
5221 hda_nid_t mixer,
5222 hda_nid_t cap1, hda_nid_t cap2)
5223{
5224 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005225 struct hda_input_mux *imux = &spec->private_imux[0];
David Henningsson5322bf22011-01-05 11:03:56 +01005226 int i, err, idx, type_idx = 0;
5227 const char *prev_label = NULL;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005228
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005229 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02005230 hda_nid_t pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005231 const char *label;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005232
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005233 pin = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005234 if (!alc_is_input_pin(codec, pin))
5235 continue;
5236
David Henningsson5322bf22011-01-05 11:03:56 +01005237 label = hda_get_autocfg_input_label(codec, cfg, i);
5238 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005239 type_idx++;
5240 else
5241 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +01005242 prev_label = label;
5243
Takashi Iwai05f5f472009-08-25 13:10:18 +02005244 if (mixer) {
5245 idx = get_connection_index(codec, mixer, pin);
5246 if (idx >= 0) {
5247 err = new_analog_input(spec, pin,
Takashi Iwai10a20af2010-09-09 16:28:02 +02005248 label, type_idx,
5249 idx, mixer);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005250 if (err < 0)
5251 return err;
5252 }
5253 }
5254
5255 if (!cap1)
5256 continue;
5257 idx = get_connection_index(codec, cap1, pin);
5258 if (idx < 0 && cap2)
5259 idx = get_connection_index(codec, cap2, pin);
Takashi Iwai10a20af2010-09-09 16:28:02 +02005260 if (idx >= 0)
5261 snd_hda_add_imux_item(imux, label, idx, NULL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005262 }
5263 return 0;
5264}
5265
Takashi Iwai05f5f472009-08-25 13:10:18 +02005266static int alc880_auto_create_input_ctls(struct hda_codec *codec,
5267 const struct auto_pin_cfg *cfg)
5268{
5269 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
5270}
5271
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005272static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
5273 unsigned int pin_type)
5274{
5275 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5276 pin_type);
5277 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01005278 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5279 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005280}
5281
Kailang Yangdf694da2005-12-05 19:42:22 +01005282static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
5283 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005284 int dac_idx)
5285{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005286 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005287 /* need the manual connection? */
5288 if (alc880_is_multi_pin(nid)) {
5289 struct alc_spec *spec = codec->spec;
5290 int idx = alc880_multi_pin_idx(nid);
5291 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
5292 AC_VERB_SET_CONNECT_SEL,
5293 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
5294 }
5295}
5296
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005297static int get_pin_type(int line_out_type)
5298{
5299 if (line_out_type == AUTO_PIN_HP_OUT)
5300 return PIN_HP;
5301 else
5302 return PIN_OUT;
5303}
5304
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005305static void alc880_auto_init_multi_out(struct hda_codec *codec)
5306{
5307 struct alc_spec *spec = codec->spec;
5308 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005309
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005310 for (i = 0; i < spec->autocfg.line_outs; i++) {
5311 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005312 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5313 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005314 }
5315}
5316
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005317static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005318{
5319 struct alc_spec *spec = codec->spec;
5320 hda_nid_t pin;
5321
Takashi Iwai82bc9552006-03-21 11:24:42 +01005322 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005323 if (pin) /* connect to front */
5324 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005325 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005326 if (pin) /* connect to front */
5327 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5328}
5329
5330static void alc880_auto_init_analog_input(struct hda_codec *codec)
5331{
5332 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005333 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005334 int i;
5335
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005336 for (i = 0; i < cfg->num_inputs; i++) {
5337 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005338 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02005339 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005340 if (nid != ALC880_PIN_CD_NID &&
5341 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005342 snd_hda_codec_write(codec, nid, 0,
5343 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005344 AMP_OUT_MUTE);
5345 }
5346 }
5347}
5348
Takashi Iwai7f311a42010-04-09 17:32:23 +02005349static void alc880_auto_init_input_src(struct hda_codec *codec)
5350{
5351 struct alc_spec *spec = codec->spec;
5352 int c;
5353
5354 for (c = 0; c < spec->num_adc_nids; c++) {
5355 unsigned int mux_idx;
5356 const struct hda_input_mux *imux;
5357 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5358 imux = &spec->input_mux[mux_idx];
5359 if (!imux->num_items && mux_idx > 0)
5360 imux = &spec->input_mux[0];
5361 if (imux)
5362 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5363 AC_VERB_SET_CONNECT_SEL,
5364 imux->items[0].index);
5365 }
5366}
5367
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005368/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005369/* return 1 if successful, 0 if the proper config is not found,
5370 * or a negative error code
5371 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005372static int alc880_parse_auto_config(struct hda_codec *codec)
5373{
5374 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005375 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005376 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005377
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005378 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5379 alc880_ignore);
5380 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005381 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005382 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005383 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005384
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005385 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5386 if (err < 0)
5387 return err;
5388 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5389 if (err < 0)
5390 return err;
5391 err = alc880_auto_create_extra_out(spec,
5392 spec->autocfg.speaker_pins[0],
5393 "Speaker");
5394 if (err < 0)
5395 return err;
5396 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5397 "Headphone");
5398 if (err < 0)
5399 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005400 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005401 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005402 return err;
5403
5404 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5405
Takashi Iwai757899a2010-07-30 10:48:14 +02005406 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005407
Takashi Iwai603c4012008-07-30 15:01:44 +02005408 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005409 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005410
Takashi Iwaid88897e2008-10-31 15:01:37 +01005411 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005412
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005413 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005414 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005415
Kailang Yang6227cdc2010-02-25 08:36:52 +01005416 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005417
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005418 return 1;
5419}
5420
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005421/* additional initialization for auto-configuration model */
5422static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005423{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005424 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005425 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005426 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005427 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005428 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005429 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005430 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005431 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005432}
5433
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005434/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5435 * one of two digital mic pins, e.g. on ALC272
5436 */
5437static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005438{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005439 struct alc_spec *spec = codec->spec;
5440 int i;
5441
5442 for (i = 0; i < spec->num_adc_nids; i++) {
5443 hda_nid_t cap = spec->capsrc_nids ?
5444 spec->capsrc_nids[i] : spec->adc_nids[i];
5445 int iidx, eidx;
5446
5447 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5448 if (iidx < 0)
5449 continue;
5450 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5451 if (eidx < 0)
5452 continue;
5453 spec->int_mic.mux_idx = iidx;
5454 spec->ext_mic.mux_idx = eidx;
5455 if (spec->capsrc_nids)
5456 spec->capsrc_nids += i;
5457 spec->adc_nids += i;
5458 spec->num_adc_nids = 1;
5459 return;
5460 }
5461 snd_printd(KERN_INFO "hda_codec: %s: "
5462 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5463 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5464 spec->auto_mic = 0; /* disable auto-mic to be sure */
5465}
5466
Takashi Iwai748cce42010-08-04 07:37:39 +02005467/* select or unmute the given capsrc route */
5468static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5469 int idx)
5470{
5471 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5472 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5473 HDA_AMP_MUTE, 0);
5474 } else {
5475 snd_hda_codec_write_cache(codec, cap, 0,
5476 AC_VERB_SET_CONNECT_SEL, idx);
5477 }
5478}
5479
Takashi Iwai840b64c2010-07-13 22:49:01 +02005480/* set the default connection to that pin */
5481static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5482{
5483 struct alc_spec *spec = codec->spec;
5484 int i;
5485
5486 for (i = 0; i < spec->num_adc_nids; i++) {
5487 hda_nid_t cap = spec->capsrc_nids ?
5488 spec->capsrc_nids[i] : spec->adc_nids[i];
5489 int idx;
5490
5491 idx = get_connection_index(codec, cap, pin);
5492 if (idx < 0)
5493 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005494 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005495 return i; /* return the found index */
5496 }
5497 return -1; /* not found */
5498}
5499
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005500/* choose the ADC/MUX containing the input pin and initialize the setup */
5501static void fixup_single_adc(struct hda_codec *codec)
5502{
5503 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005504 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005505 int i;
5506
5507 /* search for the input pin; there must be only one */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005508 if (cfg->num_inputs != 1)
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005509 return;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005510 i = init_capsrc_for_pin(codec, cfg->inputs[0].pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005511 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005512 /* use only this ADC */
5513 if (spec->capsrc_nids)
5514 spec->capsrc_nids += i;
5515 spec->adc_nids += i;
5516 spec->num_adc_nids = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005517 }
5518}
5519
Takashi Iwai840b64c2010-07-13 22:49:01 +02005520/* initialize dual adcs */
5521static void fixup_dual_adc_switch(struct hda_codec *codec)
5522{
5523 struct alc_spec *spec = codec->spec;
5524 init_capsrc_for_pin(codec, spec->ext_mic.pin);
5525 init_capsrc_for_pin(codec, spec->int_mic.pin);
5526}
5527
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005528static void set_capture_mixer(struct hda_codec *codec)
5529{
5530 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005531 static struct snd_kcontrol_new *caps[2][3] = {
5532 { alc_capture_mixer_nosrc1,
5533 alc_capture_mixer_nosrc2,
5534 alc_capture_mixer_nosrc3 },
5535 { alc_capture_mixer1,
5536 alc_capture_mixer2,
5537 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005538 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005539 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005540 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005541 int num_adcs = spec->num_adc_nids;
5542 if (spec->dual_adc_switch)
5543 fixup_dual_adc_switch(codec);
5544 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005545 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005546 else if (spec->input_mux) {
5547 if (spec->input_mux->num_items > 1)
5548 mux = 1;
5549 else if (spec->input_mux->num_items == 1)
5550 fixup_single_adc(codec);
5551 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005552 if (spec->dual_adc_switch)
5553 num_adcs = 1;
5554 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005555 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005556}
5557
Takashi Iwai66946352010-03-29 17:21:45 +02005558/* fill adc_nids (and capsrc_nids) containing all active input pins */
5559static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5560 int num_nids)
5561{
5562 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005563 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai66946352010-03-29 17:21:45 +02005564 int n;
5565 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5566
5567 for (n = 0; n < num_nids; n++) {
5568 hda_nid_t adc, cap;
5569 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5570 int nconns, i, j;
5571
5572 adc = nids[n];
5573 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5574 continue;
5575 cap = adc;
5576 nconns = snd_hda_get_connections(codec, cap, conn,
5577 ARRAY_SIZE(conn));
5578 if (nconns == 1) {
5579 cap = conn[0];
5580 nconns = snd_hda_get_connections(codec, cap, conn,
5581 ARRAY_SIZE(conn));
5582 }
5583 if (nconns <= 0)
5584 continue;
5585 if (!fallback_adc) {
5586 fallback_adc = adc;
5587 fallback_cap = cap;
5588 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005589 for (i = 0; i < cfg->num_inputs; i++) {
5590 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai66946352010-03-29 17:21:45 +02005591 for (j = 0; j < nconns; j++) {
5592 if (conn[j] == nid)
5593 break;
5594 }
5595 if (j >= nconns)
5596 break;
5597 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005598 if (i >= cfg->num_inputs) {
Takashi Iwai66946352010-03-29 17:21:45 +02005599 int num_adcs = spec->num_adc_nids;
5600 spec->private_adc_nids[num_adcs] = adc;
5601 spec->private_capsrc_nids[num_adcs] = cap;
5602 spec->num_adc_nids++;
5603 spec->adc_nids = spec->private_adc_nids;
5604 if (adc != cap)
5605 spec->capsrc_nids = spec->private_capsrc_nids;
5606 }
5607 }
5608 if (!spec->num_adc_nids) {
5609 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005610 " using fallback 0x%x\n",
5611 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005612 spec->private_adc_nids[0] = fallback_adc;
5613 spec->adc_nids = spec->private_adc_nids;
5614 if (fallback_adc != fallback_cap) {
5615 spec->private_capsrc_nids[0] = fallback_cap;
5616 spec->capsrc_nids = spec->private_adc_nids;
5617 }
5618 }
5619}
5620
Takashi Iwai67d634c2009-11-16 15:35:59 +01005621#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005622#define set_beep_amp(spec, nid, idx, dir) \
5623 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005624
5625static struct snd_pci_quirk beep_white_list[] = {
5626 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005627 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005628 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005629 {}
5630};
5631
5632static inline int has_cdefine_beep(struct hda_codec *codec)
5633{
5634 struct alc_spec *spec = codec->spec;
5635 const struct snd_pci_quirk *q;
5636 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5637 if (q)
5638 return q->value;
5639 return spec->cdefine.enable_pcbeep;
5640}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005641#else
5642#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005643#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005644#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005645
5646/*
5647 * OK, here we have finally the patch for ALC880
5648 */
5649
Linus Torvalds1da177e2005-04-16 15:20:36 -07005650static int patch_alc880(struct hda_codec *codec)
5651{
5652 struct alc_spec *spec;
5653 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005654 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005655
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005656 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005657 if (spec == NULL)
5658 return -ENOMEM;
5659
5660 codec->spec = spec;
5661
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005662 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5663 alc880_models,
5664 alc880_cfg_tbl);
5665 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005666 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5667 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005668 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005669 }
5670
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005671 if (board_config == ALC880_AUTO) {
5672 /* automatic parse from the BIOS config */
5673 err = alc880_parse_auto_config(codec);
5674 if (err < 0) {
5675 alc_free(codec);
5676 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005677 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005678 printk(KERN_INFO
5679 "hda_codec: Cannot set up configuration "
5680 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005681 board_config = ALC880_3ST;
5682 }
5683 }
5684
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005685 err = snd_hda_attach_beep_device(codec, 0x1);
5686 if (err < 0) {
5687 alc_free(codec);
5688 return err;
5689 }
5690
Kailang Yangdf694da2005-12-05 19:42:22 +01005691 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005692 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005693
Linus Torvalds1da177e2005-04-16 15:20:36 -07005694 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5695 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005696 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005697
Linus Torvalds1da177e2005-04-16 15:20:36 -07005698 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5699 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5700
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005701 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005702 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005703 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005704 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005705 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005706 if (wcap != AC_WID_AUD_IN) {
5707 spec->adc_nids = alc880_adc_nids_alt;
5708 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005709 } else {
5710 spec->adc_nids = alc880_adc_nids;
5711 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005712 }
5713 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005714 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005715 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005716
Takashi Iwai2134ea42008-01-10 16:53:55 +01005717 spec->vmaster_nid = 0x0c;
5718
Linus Torvalds1da177e2005-04-16 15:20:36 -07005719 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005720 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005721 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005722#ifdef CONFIG_SND_HDA_POWER_SAVE
5723 if (!spec->loopback.amplist)
5724 spec->loopback.amplist = alc880_loopbacks;
5725#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005726
5727 return 0;
5728}
5729
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005730
Linus Torvalds1da177e2005-04-16 15:20:36 -07005731/*
5732 * ALC260 support
5733 */
5734
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005735static hda_nid_t alc260_dac_nids[1] = {
5736 /* front */
5737 0x02,
5738};
5739
5740static hda_nid_t alc260_adc_nids[1] = {
5741 /* ADC0 */
5742 0x04,
5743};
5744
Kailang Yangdf694da2005-12-05 19:42:22 +01005745static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005746 /* ADC1 */
5747 0x05,
5748};
5749
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005750/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5751 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5752 */
5753static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005754 /* ADC0, ADC1 */
5755 0x04, 0x05
5756};
5757
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005758#define ALC260_DIGOUT_NID 0x03
5759#define ALC260_DIGIN_NID 0x06
5760
5761static struct hda_input_mux alc260_capture_source = {
5762 .num_items = 4,
5763 .items = {
5764 { "Mic", 0x0 },
5765 { "Front Mic", 0x1 },
5766 { "Line", 0x2 },
5767 { "CD", 0x4 },
5768 },
5769};
5770
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005771/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005772 * headphone jack and the internal CD lines since these are the only pins at
5773 * which audio can appear. For flexibility, also allow the option of
5774 * recording the mixer output on the second ADC (ADC0 doesn't have a
5775 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005776 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005777static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5778 {
5779 .num_items = 3,
5780 .items = {
5781 { "Mic/Line", 0x0 },
5782 { "CD", 0x4 },
5783 { "Headphone", 0x2 },
5784 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005785 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005786 {
5787 .num_items = 4,
5788 .items = {
5789 { "Mic/Line", 0x0 },
5790 { "CD", 0x4 },
5791 { "Headphone", 0x2 },
5792 { "Mixer", 0x5 },
5793 },
5794 },
5795
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005796};
5797
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005798/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5799 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005800 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005801static struct hda_input_mux alc260_acer_capture_sources[2] = {
5802 {
5803 .num_items = 4,
5804 .items = {
5805 { "Mic", 0x0 },
5806 { "Line", 0x2 },
5807 { "CD", 0x4 },
5808 { "Headphone", 0x5 },
5809 },
5810 },
5811 {
5812 .num_items = 5,
5813 .items = {
5814 { "Mic", 0x0 },
5815 { "Line", 0x2 },
5816 { "CD", 0x4 },
5817 { "Headphone", 0x6 },
5818 { "Mixer", 0x5 },
5819 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005820 },
5821};
Michael Schwingencc959482009-02-22 18:58:45 +01005822
5823/* Maxdata Favorit 100XS */
5824static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5825 {
5826 .num_items = 2,
5827 .items = {
5828 { "Line/Mic", 0x0 },
5829 { "CD", 0x4 },
5830 },
5831 },
5832 {
5833 .num_items = 3,
5834 .items = {
5835 { "Line/Mic", 0x0 },
5836 { "CD", 0x4 },
5837 { "Mixer", 0x5 },
5838 },
5839 },
5840};
5841
Linus Torvalds1da177e2005-04-16 15:20:36 -07005842/*
5843 * This is just place-holder, so there's something for alc_build_pcms to look
5844 * at when it calculates the maximum number of channels. ALC260 has no mixer
5845 * element which allows changing the channel mode, so the verb list is
5846 * never used.
5847 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005848static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005849 { 2, NULL },
5850};
5851
Kailang Yangdf694da2005-12-05 19:42:22 +01005852
5853/* Mixer combinations
5854 *
5855 * basic: base_output + input + pc_beep + capture
5856 * HP: base_output + input + capture_alt
5857 * HP_3013: hp_3013 + input + capture
5858 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005859 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005860 */
5861
5862static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005863 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005864 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005865 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5866 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5867 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5868 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5869 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005870};
Kailang Yangdf694da2005-12-05 19:42:22 +01005871
5872static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005873 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5874 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5875 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5876 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5877 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5878 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5879 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5880 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005881 { } /* end */
5882};
5883
Takashi Iwaibec15c32008-01-28 18:16:30 +01005884/* update HP, line and mono out pins according to the master switch */
5885static void alc260_hp_master_update(struct hda_codec *codec,
5886 hda_nid_t hp, hda_nid_t line,
5887 hda_nid_t mono)
5888{
5889 struct alc_spec *spec = codec->spec;
5890 unsigned int val = spec->master_sw ? PIN_HP : 0;
5891 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005892 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005893 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005894 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005895 val);
5896 /* mono (speaker) depending on the HP jack sense */
5897 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005898 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005899 val);
5900}
5901
5902static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5903 struct snd_ctl_elem_value *ucontrol)
5904{
5905 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5906 struct alc_spec *spec = codec->spec;
5907 *ucontrol->value.integer.value = spec->master_sw;
5908 return 0;
5909}
5910
5911static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5912 struct snd_ctl_elem_value *ucontrol)
5913{
5914 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5915 struct alc_spec *spec = codec->spec;
5916 int val = !!*ucontrol->value.integer.value;
5917 hda_nid_t hp, line, mono;
5918
5919 if (val == spec->master_sw)
5920 return 0;
5921 spec->master_sw = val;
5922 hp = (kcontrol->private_value >> 16) & 0xff;
5923 line = (kcontrol->private_value >> 8) & 0xff;
5924 mono = kcontrol->private_value & 0xff;
5925 alc260_hp_master_update(codec, hp, line, mono);
5926 return 1;
5927}
5928
5929static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5930 {
5931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5932 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005933 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005934 .info = snd_ctl_boolean_mono_info,
5935 .get = alc260_hp_master_sw_get,
5936 .put = alc260_hp_master_sw_put,
5937 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5938 },
5939 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5940 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5941 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5942 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5943 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5944 HDA_OUTPUT),
5945 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5946 { } /* end */
5947};
5948
5949static struct hda_verb alc260_hp_unsol_verbs[] = {
5950 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5951 {},
5952};
5953
5954static void alc260_hp_automute(struct hda_codec *codec)
5955{
5956 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005957
Wu Fengguang864f92b2009-11-18 12:38:02 +08005958 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005959 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5960}
5961
5962static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5963{
5964 if ((res >> 26) == ALC880_HP_EVENT)
5965 alc260_hp_automute(codec);
5966}
5967
Kailang Yangdf694da2005-12-05 19:42:22 +01005968static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005969 {
5970 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5971 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005972 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005973 .info = snd_ctl_boolean_mono_info,
5974 .get = alc260_hp_master_sw_get,
5975 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005976 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005977 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005978 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5979 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5980 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5981 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5982 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5983 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005984 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5985 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005986 { } /* end */
5987};
5988
Kailang Yang3f878302008-08-26 13:02:23 +02005989static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5990 .ops = &snd_hda_bind_vol,
5991 .values = {
5992 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5993 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5994 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5995 0
5996 },
5997};
5998
5999static struct hda_bind_ctls alc260_dc7600_bind_switch = {
6000 .ops = &snd_hda_bind_sw,
6001 .values = {
6002 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
6003 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
6004 0
6005 },
6006};
6007
6008static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
6009 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
6010 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
6011 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
6012 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
6013 { } /* end */
6014};
6015
Takashi Iwaibec15c32008-01-28 18:16:30 +01006016static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
6017 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6018 {},
6019};
6020
6021static void alc260_hp_3013_automute(struct hda_codec *codec)
6022{
6023 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006024
Wu Fengguang864f92b2009-11-18 12:38:02 +08006025 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01006026 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01006027}
6028
6029static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
6030 unsigned int res)
6031{
6032 if ((res >> 26) == ALC880_HP_EVENT)
6033 alc260_hp_3013_automute(codec);
6034}
6035
Kailang Yang3f878302008-08-26 13:02:23 +02006036static void alc260_hp_3012_automute(struct hda_codec *codec)
6037{
Wu Fengguang864f92b2009-11-18 12:38:02 +08006038 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02006039
Kailang Yang3f878302008-08-26 13:02:23 +02006040 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6041 bits);
6042 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6043 bits);
6044 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6045 bits);
6046}
6047
6048static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
6049 unsigned int res)
6050{
6051 if ((res >> 26) == ALC880_HP_EVENT)
6052 alc260_hp_3012_automute(codec);
6053}
6054
6055/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006056 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
6057 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006058static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006059 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006060 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006061 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006062 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6063 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6064 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
6065 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006066 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006067 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6068 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006069 { } /* end */
6070};
6071
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006072/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
6073 * versions of the ALC260 don't act on requests to enable mic bias from NID
6074 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
6075 * datasheet doesn't mention this restriction. At this stage it's not clear
6076 * whether this behaviour is intentional or is a hardware bug in chip
6077 * revisions available in early 2006. Therefore for now allow the
6078 * "Headphone Jack Mode" control to span all choices, but if it turns out
6079 * that the lack of mic bias for this NID is intentional we could change the
6080 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6081 *
6082 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
6083 * don't appear to make the mic bias available from the "line" jack, even
6084 * though the NID used for this jack (0x14) can supply it. The theory is
6085 * that perhaps Acer have included blocking capacitors between the ALC260
6086 * and the output jack. If this turns out to be the case for all such
6087 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
6088 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01006089 *
6090 * The C20x Tablet series have a mono internal speaker which is controlled
6091 * via the chip's Mono sum widget and pin complex, so include the necessary
6092 * controls for such models. On models without a "mono speaker" the control
6093 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006094 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006095static struct snd_kcontrol_new alc260_acer_mixer[] = {
6096 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6097 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006098 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006099 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01006100 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006101 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01006102 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006103 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6104 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6105 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6106 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6107 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6108 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6109 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6110 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006111 { } /* end */
6112};
6113
Michael Schwingencc959482009-02-22 18:58:45 +01006114/* Maxdata Favorit 100XS: one output and one input (0x12) jack
6115 */
6116static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
6117 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6118 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
6119 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
6120 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6121 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6122 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6123 { } /* end */
6124};
6125
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006126/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
6127 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
6128 */
6129static struct snd_kcontrol_new alc260_will_mixer[] = {
6130 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6131 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6132 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6133 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6134 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6135 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6136 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6137 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6138 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6139 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006140 { } /* end */
6141};
6142
6143/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
6144 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
6145 */
6146static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
6147 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6148 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6149 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6150 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6151 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6152 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
6153 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
6154 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6155 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6156 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6157 { } /* end */
6158};
6159
Kailang Yangdf694da2005-12-05 19:42:22 +01006160/*
6161 * initialization verbs
6162 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006163static struct hda_verb alc260_init_verbs[] = {
6164 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006165 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006166 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006167 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006168 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006169 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006170 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006171 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006172 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02006173 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006174 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01006175 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006176 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02006177 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006178 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02006179 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006180 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02006181 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6182 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02006183 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006184 /* set connection select to line in (default select for this ADC) */
6185 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02006186 /* mute capture amp left and right */
6187 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6188 /* set connection select to line in (default select for this ADC) */
6189 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02006190 /* set vol=0 Line-Out mixer amp left and right */
6191 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6192 /* unmute pin widget amp left and right (no gain on this amp) */
6193 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6194 /* set vol=0 HP mixer amp left and right */
6195 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6196 /* unmute pin widget amp left and right (no gain on this amp) */
6197 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6198 /* set vol=0 Mono mixer amp left and right */
6199 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6200 /* unmute pin widget amp left and right (no gain on this amp) */
6201 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6202 /* unmute LINE-2 out pin */
6203 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006204 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6205 * Line In 2 = 0x03
6206 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006207 /* mute analog inputs */
6208 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6209 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6210 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6211 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6212 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006213 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006214 /* mute Front out path */
6215 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6216 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6217 /* mute Headphone out path */
6218 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6219 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6220 /* mute Mono out path */
6221 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6222 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006223 { }
6224};
6225
Takashi Iwai474167d2006-05-17 17:17:43 +02006226#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01006227static struct hda_verb alc260_hp_init_verbs[] = {
6228 /* Headphone and output */
6229 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6230 /* mono output */
6231 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6232 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6233 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6234 /* Mic2 (front panel) pin widget for input and vref at 80% */
6235 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6236 /* Line In pin widget for input */
6237 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6238 /* Line-2 pin widget for output */
6239 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6240 /* CD pin widget for input */
6241 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6242 /* unmute amp left and right */
6243 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6244 /* set connection select to line in (default select for this ADC) */
6245 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6246 /* unmute Line-Out mixer amp left and right (volume = 0) */
6247 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6248 /* mute pin widget amp left and right (no gain on this amp) */
6249 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6250 /* unmute HP mixer amp left and right (volume = 0) */
6251 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6252 /* mute pin widget amp left and right (no gain on this amp) */
6253 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006254 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6255 * Line In 2 = 0x03
6256 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006257 /* mute analog inputs */
6258 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6259 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6260 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6261 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6262 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006263 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6264 /* Unmute Front out path */
6265 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6266 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6267 /* Unmute Headphone out path */
6268 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6269 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6270 /* Unmute Mono out path */
6271 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6272 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6273 { }
6274};
Takashi Iwai474167d2006-05-17 17:17:43 +02006275#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006276
6277static struct hda_verb alc260_hp_3013_init_verbs[] = {
6278 /* Line out and output */
6279 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6280 /* mono output */
6281 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6282 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6283 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6284 /* Mic2 (front panel) pin widget for input and vref at 80% */
6285 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6286 /* Line In pin widget for input */
6287 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6288 /* Headphone pin widget for output */
6289 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6290 /* CD pin widget for input */
6291 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6292 /* unmute amp left and right */
6293 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6294 /* set connection select to line in (default select for this ADC) */
6295 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6296 /* unmute Line-Out mixer amp left and right (volume = 0) */
6297 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6298 /* mute pin widget amp left and right (no gain on this amp) */
6299 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6300 /* unmute HP mixer amp left and right (volume = 0) */
6301 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6302 /* mute pin widget amp left and right (no gain on this amp) */
6303 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006304 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6305 * Line In 2 = 0x03
6306 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006307 /* mute analog inputs */
6308 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6309 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6310 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6311 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6312 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006313 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6314 /* Unmute Front out path */
6315 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6316 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6317 /* Unmute Headphone out path */
6318 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6319 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6320 /* Unmute Mono out path */
6321 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6322 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6323 { }
6324};
6325
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006326/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006327 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6328 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006329 */
6330static struct hda_verb alc260_fujitsu_init_verbs[] = {
6331 /* Disable all GPIOs */
6332 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6333 /* Internal speaker is connected to headphone pin */
6334 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6335 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6336 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006337 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6338 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6339 /* Ensure all other unused pins are disabled and muted. */
6340 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6341 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006342 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006343 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006344 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006345 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6346 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6347 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006348
Jonathan Woithef7ace402006-02-28 11:46:14 +01006349 /* Disable digital (SPDIF) pins */
6350 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6351 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006352
Kailang Yangea1fb292008-08-26 12:58:38 +02006353 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006354 * when acting as an output.
6355 */
6356 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6357
6358 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006359 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6360 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6361 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6362 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6363 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6364 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6365 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6366 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6367 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006368
Jonathan Woithef7ace402006-02-28 11:46:14 +01006369 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6370 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6371 /* Unmute Line1 pin widget output buffer since it starts as an output.
6372 * If the pin mode is changed by the user the pin mode control will
6373 * take care of enabling the pin's input/output buffers as needed.
6374 * Therefore there's no need to enable the input buffer at this
6375 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006376 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006377 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006378 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006379 * mixer ctrl)
6380 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006381 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006382
Jonathan Woithef7ace402006-02-28 11:46:14 +01006383 /* Mute capture amp left and right */
6384 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006385 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006386 * in (on mic1 pin)
6387 */
6388 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006389
Jonathan Woithef7ace402006-02-28 11:46:14 +01006390 /* Do the same for the second ADC: mute capture input amp and
6391 * set ADC connection to line in (on mic1 pin)
6392 */
6393 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6394 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006395
Jonathan Woithef7ace402006-02-28 11:46:14 +01006396 /* Mute all inputs to mixer widget (even unconnected ones) */
6397 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6398 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6399 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6400 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6401 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6402 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6403 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6404 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006405
6406 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006407};
6408
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006409/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6410 * similar laptops (adapted from Fujitsu init verbs).
6411 */
6412static struct hda_verb alc260_acer_init_verbs[] = {
6413 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6414 * the headphone jack. Turn this on and rely on the standard mute
6415 * methods whenever the user wants to turn these outputs off.
6416 */
6417 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6418 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6419 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6420 /* Internal speaker/Headphone jack is connected to Line-out pin */
6421 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6422 /* Internal microphone/Mic jack is connected to Mic1 pin */
6423 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6424 /* Line In jack is connected to Line1 pin */
6425 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006426 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6427 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006428 /* Ensure all other unused pins are disabled and muted. */
6429 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6430 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006431 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6432 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6433 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6434 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6435 /* Disable digital (SPDIF) pins */
6436 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6437 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6438
Kailang Yangea1fb292008-08-26 12:58:38 +02006439 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006440 * bus when acting as outputs.
6441 */
6442 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6443 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6444
6445 /* Start with output sum widgets muted and their output gains at min */
6446 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6447 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6448 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6449 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6450 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6451 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6452 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6453 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6454 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6455
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006456 /* Unmute Line-out pin widget amp left and right
6457 * (no equiv mixer ctrl)
6458 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006459 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006460 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6461 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006462 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6463 * inputs. If the pin mode is changed by the user the pin mode control
6464 * will take care of enabling the pin's input/output buffers as needed.
6465 * Therefore there's no need to enable the input buffer at this
6466 * stage.
6467 */
6468 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6469 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6470
6471 /* Mute capture amp left and right */
6472 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6473 /* Set ADC connection select to match default mixer setting - mic
6474 * (on mic1 pin)
6475 */
6476 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6477
6478 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006479 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006480 */
6481 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006482 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006483
6484 /* Mute all inputs to mixer widget (even unconnected ones) */
6485 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6486 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6487 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6488 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6489 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6490 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6491 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6492 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6493
6494 { }
6495};
6496
Michael Schwingencc959482009-02-22 18:58:45 +01006497/* Initialisation sequence for Maxdata Favorit 100XS
6498 * (adapted from Acer init verbs).
6499 */
6500static struct hda_verb alc260_favorit100_init_verbs[] = {
6501 /* GPIO 0 enables the output jack.
6502 * Turn this on and rely on the standard mute
6503 * methods whenever the user wants to turn these outputs off.
6504 */
6505 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6506 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6507 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6508 /* Line/Mic input jack is connected to Mic1 pin */
6509 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6510 /* Ensure all other unused pins are disabled and muted. */
6511 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6512 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6513 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6514 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6515 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6516 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6517 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6518 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6519 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6520 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6521 /* Disable digital (SPDIF) pins */
6522 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6523 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6524
6525 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6526 * bus when acting as outputs.
6527 */
6528 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6529 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6530
6531 /* Start with output sum widgets muted and their output gains at min */
6532 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6533 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6534 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6535 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6536 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6537 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6538 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6539 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6540 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6541
6542 /* Unmute Line-out pin widget amp left and right
6543 * (no equiv mixer ctrl)
6544 */
6545 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6546 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6547 * inputs. If the pin mode is changed by the user the pin mode control
6548 * will take care of enabling the pin's input/output buffers as needed.
6549 * Therefore there's no need to enable the input buffer at this
6550 * stage.
6551 */
6552 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6553
6554 /* Mute capture amp left and right */
6555 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6556 /* Set ADC connection select to match default mixer setting - mic
6557 * (on mic1 pin)
6558 */
6559 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6560
6561 /* Do similar with the second ADC: mute capture input amp and
6562 * set ADC connection to mic to match ALSA's default state.
6563 */
6564 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6565 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6566
6567 /* Mute all inputs to mixer widget (even unconnected ones) */
6568 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6569 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6570 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6571 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6572 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6573 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6574 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6575 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6576
6577 { }
6578};
6579
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006580static struct hda_verb alc260_will_verbs[] = {
6581 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6582 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6583 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6584 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6585 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6586 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6587 {}
6588};
6589
6590static struct hda_verb alc260_replacer_672v_verbs[] = {
6591 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6592 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6593 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6594
6595 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6596 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6597 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6598
6599 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6600 {}
6601};
6602
6603/* toggle speaker-output according to the hp-jack state */
6604static void alc260_replacer_672v_automute(struct hda_codec *codec)
6605{
6606 unsigned int present;
6607
6608 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006609 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006610 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006611 snd_hda_codec_write_cache(codec, 0x01, 0,
6612 AC_VERB_SET_GPIO_DATA, 1);
6613 snd_hda_codec_write_cache(codec, 0x0f, 0,
6614 AC_VERB_SET_PIN_WIDGET_CONTROL,
6615 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006616 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006617 snd_hda_codec_write_cache(codec, 0x01, 0,
6618 AC_VERB_SET_GPIO_DATA, 0);
6619 snd_hda_codec_write_cache(codec, 0x0f, 0,
6620 AC_VERB_SET_PIN_WIDGET_CONTROL,
6621 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006622 }
6623}
6624
6625static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6626 unsigned int res)
6627{
6628 if ((res >> 26) == ALC880_HP_EVENT)
6629 alc260_replacer_672v_automute(codec);
6630}
6631
Kailang Yang3f878302008-08-26 13:02:23 +02006632static struct hda_verb alc260_hp_dc7600_verbs[] = {
6633 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6634 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6635 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6636 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6637 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6638 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6639 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6640 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6641 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6642 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6643 {}
6644};
6645
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006646/* Test configuration for debugging, modelled after the ALC880 test
6647 * configuration.
6648 */
6649#ifdef CONFIG_SND_DEBUG
6650static hda_nid_t alc260_test_dac_nids[1] = {
6651 0x02,
6652};
6653static hda_nid_t alc260_test_adc_nids[2] = {
6654 0x04, 0x05,
6655};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006656/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006657 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006658 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006659 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006660static struct hda_input_mux alc260_test_capture_sources[2] = {
6661 {
6662 .num_items = 7,
6663 .items = {
6664 { "MIC1 pin", 0x0 },
6665 { "MIC2 pin", 0x1 },
6666 { "LINE1 pin", 0x2 },
6667 { "LINE2 pin", 0x3 },
6668 { "CD pin", 0x4 },
6669 { "LINE-OUT pin", 0x5 },
6670 { "HP-OUT pin", 0x6 },
6671 },
6672 },
6673 {
6674 .num_items = 8,
6675 .items = {
6676 { "MIC1 pin", 0x0 },
6677 { "MIC2 pin", 0x1 },
6678 { "LINE1 pin", 0x2 },
6679 { "LINE2 pin", 0x3 },
6680 { "CD pin", 0x4 },
6681 { "Mixer", 0x5 },
6682 { "LINE-OUT pin", 0x6 },
6683 { "HP-OUT pin", 0x7 },
6684 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006685 },
6686};
6687static struct snd_kcontrol_new alc260_test_mixer[] = {
6688 /* Output driver widgets */
6689 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6690 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6691 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6692 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6693 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6694 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6695
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006696 /* Modes for retasking pin widgets
6697 * Note: the ALC260 doesn't seem to act on requests to enable mic
6698 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6699 * mention this restriction. At this stage it's not clear whether
6700 * this behaviour is intentional or is a hardware bug in chip
6701 * revisions available at least up until early 2006. Therefore for
6702 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6703 * choices, but if it turns out that the lack of mic bias for these
6704 * NIDs is intentional we could change their modes from
6705 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6706 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006707 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6708 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6709 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6710 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6711 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6712 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6713
6714 /* Loopback mixer controls */
6715 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6716 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6717 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6718 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6719 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6720 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6721 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6722 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6723 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6724 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006725 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6726 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6727 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6728 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006729
6730 /* Controls for GPIO pins, assuming they are configured as outputs */
6731 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6732 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6733 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6734 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6735
Jonathan Woithe92621f12006-02-28 11:47:47 +01006736 /* Switches to allow the digital IO pins to be enabled. The datasheet
6737 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006738 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006739 */
6740 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6741 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6742
Jonathan Woithef8225f62008-01-08 12:16:54 +01006743 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6744 * this output to turn on an external amplifier.
6745 */
6746 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6747 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6748
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006749 { } /* end */
6750};
6751static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006752 /* Enable all GPIOs as outputs with an initial value of 0 */
6753 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6754 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6755 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6756
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006757 /* Enable retasking pins as output, initially without power amp */
6758 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6759 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6760 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6761 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6762 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6763 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6764
Jonathan Woithe92621f12006-02-28 11:47:47 +01006765 /* Disable digital (SPDIF) pins initially, but users can enable
6766 * them via a mixer switch. In the case of SPDIF-out, this initverb
6767 * payload also sets the generation to 0, output to be in "consumer"
6768 * PCM format, copyright asserted, no pre-emphasis and no validity
6769 * control.
6770 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006771 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6772 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6773
Kailang Yangea1fb292008-08-26 12:58:38 +02006774 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006775 * OUT1 sum bus when acting as an output.
6776 */
6777 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6778 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6779 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6780 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6781
6782 /* Start with output sum widgets muted and their output gains at min */
6783 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6784 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6785 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6786 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6787 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6788 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6789 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6790 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6791 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6792
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006793 /* Unmute retasking pin widget output buffers since the default
6794 * state appears to be output. As the pin mode is changed by the
6795 * user the pin mode control will take care of enabling the pin's
6796 * input/output buffers as needed.
6797 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006798 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6799 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6800 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6801 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6802 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6803 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6804 /* Also unmute the mono-out pin widget */
6805 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6806
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006807 /* Mute capture amp left and right */
6808 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006809 /* Set ADC connection select to match default mixer setting (mic1
6810 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006811 */
6812 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6813
6814 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006815 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006816 */
6817 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6818 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6819
6820 /* Mute all inputs to mixer widget (even unconnected ones) */
6821 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6822 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6823 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6824 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6825 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6826 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6827 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6828 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6829
6830 { }
6831};
6832#endif
6833
Takashi Iwai63300792008-01-24 15:31:36 +01006834#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6835#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006836
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006837#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6838#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6839
Kailang Yangdf694da2005-12-05 19:42:22 +01006840/*
6841 * for BIOS auto-configuration
6842 */
6843
6844static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006845 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006846{
6847 hda_nid_t nid_vol;
6848 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006849 int err;
6850
6851 if (nid >= 0x0f && nid < 0x11) {
6852 nid_vol = nid - 0x7;
6853 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6854 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6855 } else if (nid == 0x11) {
6856 nid_vol = nid - 0x7;
6857 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6858 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6859 } else if (nid >= 0x12 && nid <= 0x15) {
6860 nid_vol = 0x08;
6861 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6862 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6863 } else
6864 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006865
Takashi Iwai863b4512008-10-21 17:01:47 +02006866 if (!(*vol_bits & (1 << nid_vol))) {
6867 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006868 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006869 if (err < 0)
6870 return err;
6871 *vol_bits |= (1 << nid_vol);
6872 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006873 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006874 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006875 return err;
6876 return 1;
6877}
6878
6879/* add playback controls from the parsed DAC table */
6880static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6881 const struct auto_pin_cfg *cfg)
6882{
6883 hda_nid_t nid;
6884 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006885 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006886
6887 spec->multiout.num_dacs = 1;
6888 spec->multiout.dac_nids = spec->private_dac_nids;
6889 spec->multiout.dac_nids[0] = 0x02;
6890
6891 nid = cfg->line_out_pins[0];
6892 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006893 const char *pfx;
6894 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6895 pfx = "Master";
6896 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6897 pfx = "Speaker";
6898 else
6899 pfx = "Front";
6900 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006901 if (err < 0)
6902 return err;
6903 }
6904
Takashi Iwai82bc9552006-03-21 11:24:42 +01006905 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006906 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006907 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006908 if (err < 0)
6909 return err;
6910 }
6911
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006912 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006913 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006914 err = alc260_add_playback_controls(spec, nid, "Headphone",
6915 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006916 if (err < 0)
6917 return err;
6918 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006919 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006920}
6921
6922/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006923static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006924 const struct auto_pin_cfg *cfg)
6925{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006926 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006927}
6928
6929static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6930 hda_nid_t nid, int pin_type,
6931 int sel_idx)
6932{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006933 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006934 /* need the manual connection? */
6935 if (nid >= 0x12) {
6936 int idx = nid - 0x12;
6937 snd_hda_codec_write(codec, idx + 0x0b, 0,
6938 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006939 }
6940}
6941
6942static void alc260_auto_init_multi_out(struct hda_codec *codec)
6943{
6944 struct alc_spec *spec = codec->spec;
6945 hda_nid_t nid;
6946
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006947 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006948 if (nid) {
6949 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6950 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6951 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006952
Takashi Iwai82bc9552006-03-21 11:24:42 +01006953 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006954 if (nid)
6955 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6956
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006957 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006958 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006959 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006960}
Kailang Yangdf694da2005-12-05 19:42:22 +01006961
6962#define ALC260_PIN_CD_NID 0x16
6963static void alc260_auto_init_analog_input(struct hda_codec *codec)
6964{
6965 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006966 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +01006967 int i;
6968
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006969 for (i = 0; i < cfg->num_inputs; i++) {
6970 hda_nid_t nid = cfg->inputs[i].pin;
Kailang Yangdf694da2005-12-05 19:42:22 +01006971 if (nid >= 0x12) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02006972 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006973 if (nid != ALC260_PIN_CD_NID &&
6974 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006975 snd_hda_codec_write(codec, nid, 0,
6976 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006977 AMP_OUT_MUTE);
6978 }
6979 }
6980}
6981
Takashi Iwai7f311a42010-04-09 17:32:23 +02006982#define alc260_auto_init_input_src alc880_auto_init_input_src
6983
Kailang Yangdf694da2005-12-05 19:42:22 +01006984/*
6985 * generic initialization of ADC, input mixers and output mixers
6986 */
6987static struct hda_verb alc260_volume_init_verbs[] = {
6988 /*
6989 * Unmute ADC0-1 and set the default input to mic-in
6990 */
6991 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6992 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6993 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6994 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006995
Kailang Yangdf694da2005-12-05 19:42:22 +01006996 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6997 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006998 * Note: PASD motherboards uses the Line In 2 as the input for
6999 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007000 */
7001 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007002 /* mute analog inputs */
7003 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7004 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7005 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7006 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7007 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007008
7009 /*
7010 * Set up output mixers (0x08 - 0x0a)
7011 */
7012 /* set vol=0 to output mixers */
7013 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7014 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7015 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7016 /* set up input amps for analog loopback */
7017 /* Amp Indices: DAC = 0, mixer = 1 */
7018 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7019 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7020 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7021 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7022 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7023 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02007024
Kailang Yangdf694da2005-12-05 19:42:22 +01007025 { }
7026};
7027
7028static int alc260_parse_auto_config(struct hda_codec *codec)
7029{
7030 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007031 int err;
7032 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
7033
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007034 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7035 alc260_ignore);
7036 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007037 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007038 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
7039 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01007040 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02007041 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01007042 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02007043 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007044 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007045 return err;
7046
7047 spec->multiout.max_channels = 2;
7048
Takashi Iwai0852d7a2009-02-11 11:35:15 +01007049 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007050 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02007051 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01007052 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01007053
Takashi Iwaid88897e2008-10-31 15:01:37 +01007054 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01007055
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007056 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007057 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007058
Kailang Yang6227cdc2010-02-25 08:36:52 +01007059 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02007060
Kailang Yangdf694da2005-12-05 19:42:22 +01007061 return 1;
7062}
7063
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007064/* additional initialization for auto-configuration model */
7065static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007066{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007067 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007068 alc260_auto_init_multi_out(codec);
7069 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02007070 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02007071 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007072 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007073 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007074}
7075
Takashi Iwaicb53c622007-08-10 17:21:45 +02007076#ifdef CONFIG_SND_HDA_POWER_SAVE
7077static struct hda_amp_list alc260_loopbacks[] = {
7078 { 0x07, HDA_INPUT, 0 },
7079 { 0x07, HDA_INPUT, 1 },
7080 { 0x07, HDA_INPUT, 2 },
7081 { 0x07, HDA_INPUT, 3 },
7082 { 0x07, HDA_INPUT, 4 },
7083 { } /* end */
7084};
7085#endif
7086
Kailang Yangdf694da2005-12-05 19:42:22 +01007087/*
Takashi Iwaifc091762010-08-04 23:53:36 +02007088 * Pin config fixes
7089 */
7090enum {
7091 PINFIX_HP_DC5750,
7092};
7093
Takashi Iwaifc091762010-08-04 23:53:36 +02007094static const struct alc_fixup alc260_fixups[] = {
7095 [PINFIX_HP_DC5750] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007096 .type = ALC_FIXUP_PINS,
7097 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +02007098 { 0x11, 0x90130110 }, /* speaker */
7099 { }
7100 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007101 },
7102};
7103
7104static struct snd_pci_quirk alc260_fixup_tbl[] = {
7105 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
7106 {}
7107};
7108
7109/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007110 * ALC260 configurations
7111 */
Takashi Iwaiea734962011-01-17 11:29:34 +01007112static const char * const alc260_models[ALC260_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007113 [ALC260_BASIC] = "basic",
7114 [ALC260_HP] = "hp",
7115 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02007116 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007117 [ALC260_FUJITSU_S702X] = "fujitsu",
7118 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007119 [ALC260_WILL] = "will",
7120 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01007121 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007122#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007123 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007124#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007125 [ALC260_AUTO] = "auto",
7126};
7127
7128static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01007129 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05007130 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007131 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01007132 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01007133 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01007134 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007135 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02007136 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02007137 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007138 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
7139 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
7140 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
7141 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
7142 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
7143 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
7144 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
7145 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
7146 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007147 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007148 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02007149 {}
7150};
7151
Kailang Yangdf694da2005-12-05 19:42:22 +01007152static struct alc_config_preset alc260_presets[] = {
7153 [ALC260_BASIC] = {
7154 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007155 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007156 .init_verbs = { alc260_init_verbs },
7157 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7158 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007159 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01007160 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007161 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7162 .channel_mode = alc260_modes,
7163 .input_mux = &alc260_capture_source,
7164 },
7165 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01007166 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007167 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007168 .init_verbs = { alc260_init_verbs,
7169 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007170 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7171 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007172 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7173 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007174 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7175 .channel_mode = alc260_modes,
7176 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007177 .unsol_event = alc260_hp_unsol_event,
7178 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007179 },
Kailang Yang3f878302008-08-26 13:02:23 +02007180 [ALC260_HP_DC7600] = {
7181 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007182 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02007183 .init_verbs = { alc260_init_verbs,
7184 alc260_hp_dc7600_verbs },
7185 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7186 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007187 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7188 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02007189 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7190 .channel_mode = alc260_modes,
7191 .input_mux = &alc260_capture_source,
7192 .unsol_event = alc260_hp_3012_unsol_event,
7193 .init_hook = alc260_hp_3012_automute,
7194 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007195 [ALC260_HP_3013] = {
7196 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007197 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007198 .init_verbs = { alc260_hp_3013_init_verbs,
7199 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007200 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7201 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007202 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7203 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007204 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7205 .channel_mode = alc260_modes,
7206 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007207 .unsol_event = alc260_hp_3013_unsol_event,
7208 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007209 },
7210 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007211 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007212 .init_verbs = { alc260_fujitsu_init_verbs },
7213 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7214 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01007215 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7216 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007217 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7218 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007219 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
7220 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01007221 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007222 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007223 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007224 .init_verbs = { alc260_acer_init_verbs },
7225 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7226 .dac_nids = alc260_dac_nids,
7227 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7228 .adc_nids = alc260_dual_adc_nids,
7229 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7230 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007231 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
7232 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007233 },
Michael Schwingencc959482009-02-22 18:58:45 +01007234 [ALC260_FAVORIT100] = {
7235 .mixers = { alc260_favorit100_mixer },
7236 .init_verbs = { alc260_favorit100_init_verbs },
7237 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7238 .dac_nids = alc260_dac_nids,
7239 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7240 .adc_nids = alc260_dual_adc_nids,
7241 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7242 .channel_mode = alc260_modes,
7243 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
7244 .input_mux = alc260_favorit100_capture_sources,
7245 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007246 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007247 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007248 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
7249 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7250 .dac_nids = alc260_dac_nids,
7251 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7252 .adc_nids = alc260_adc_nids,
7253 .dig_out_nid = ALC260_DIGOUT_NID,
7254 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7255 .channel_mode = alc260_modes,
7256 .input_mux = &alc260_capture_source,
7257 },
7258 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007259 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007260 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
7261 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7262 .dac_nids = alc260_dac_nids,
7263 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7264 .adc_nids = alc260_adc_nids,
7265 .dig_out_nid = ALC260_DIGOUT_NID,
7266 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7267 .channel_mode = alc260_modes,
7268 .input_mux = &alc260_capture_source,
7269 .unsol_event = alc260_replacer_672v_unsol_event,
7270 .init_hook = alc260_replacer_672v_automute,
7271 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007272#ifdef CONFIG_SND_DEBUG
7273 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007274 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007275 .init_verbs = { alc260_test_init_verbs },
7276 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
7277 .dac_nids = alc260_test_dac_nids,
7278 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
7279 .adc_nids = alc260_test_adc_nids,
7280 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7281 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007282 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7283 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007284 },
7285#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007286};
7287
Linus Torvalds1da177e2005-04-16 15:20:36 -07007288static int patch_alc260(struct hda_codec *codec)
7289{
7290 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007291 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007292
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007293 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007294 if (spec == NULL)
7295 return -ENOMEM;
7296
7297 codec->spec = spec;
7298
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007299 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7300 alc260_models,
7301 alc260_cfg_tbl);
7302 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007303 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007304 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007305 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007306 }
7307
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007308 if (board_config == ALC260_AUTO) {
7309 alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups);
7310 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
7311 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007312
Kailang Yangdf694da2005-12-05 19:42:22 +01007313 if (board_config == ALC260_AUTO) {
7314 /* automatic parse from the BIOS config */
7315 err = alc260_parse_auto_config(codec);
7316 if (err < 0) {
7317 alc_free(codec);
7318 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007319 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007320 printk(KERN_INFO
7321 "hda_codec: Cannot set up configuration "
7322 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007323 board_config = ALC260_BASIC;
7324 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007325 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007326
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007327 err = snd_hda_attach_beep_device(codec, 0x1);
7328 if (err < 0) {
7329 alc_free(codec);
7330 return err;
7331 }
7332
Kailang Yangdf694da2005-12-05 19:42:22 +01007333 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007334 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007335
Linus Torvalds1da177e2005-04-16 15:20:36 -07007336 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7337 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307338 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007339
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007340 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7341 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7342
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007343 if (!spec->adc_nids && spec->input_mux) {
7344 /* check whether NID 0x04 is valid */
7345 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007346 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007347 /* get type */
7348 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7349 spec->adc_nids = alc260_adc_nids_alt;
7350 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7351 } else {
7352 spec->adc_nids = alc260_adc_nids;
7353 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7354 }
7355 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007356 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007357 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007358
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007359 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaifc091762010-08-04 23:53:36 +02007360
Takashi Iwai2134ea42008-01-10 16:53:55 +01007361 spec->vmaster_nid = 0x08;
7362
Linus Torvalds1da177e2005-04-16 15:20:36 -07007363 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007364 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007365 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007366#ifdef CONFIG_SND_HDA_POWER_SAVE
7367 if (!spec->loopback.amplist)
7368 spec->loopback.amplist = alc260_loopbacks;
7369#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007370
7371 return 0;
7372}
7373
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007374
Linus Torvalds1da177e2005-04-16 15:20:36 -07007375/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007376 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007377 *
7378 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7379 * configuration. Each pin widget can choose any input DACs and a mixer.
7380 * Each ADC is connected from a mixer of all inputs. This makes possible
7381 * 6-channel independent captures.
7382 *
7383 * In addition, an independent DAC for the multi-playback (not used in this
7384 * driver yet).
7385 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007386#define ALC882_DIGOUT_NID 0x06
7387#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007388#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7389#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7390#define ALC1200_DIGOUT_NID 0x10
7391
Linus Torvalds1da177e2005-04-16 15:20:36 -07007392
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007393static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007394 { 8, NULL }
7395};
7396
Takashi Iwai4953550a2009-06-30 15:28:30 +02007397/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007398static hda_nid_t alc882_dac_nids[4] = {
7399 /* front, rear, clfe, rear_surr */
7400 0x02, 0x03, 0x04, 0x05
7401};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007402#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007403
Takashi Iwai4953550a2009-06-30 15:28:30 +02007404/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007405#define alc882_adc_nids alc880_adc_nids
7406#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007407#define alc883_adc_nids alc882_adc_nids_alt
7408static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7409static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7410#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007411
Takashi Iwaie1406342008-02-11 18:32:32 +01007412static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7413static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007414#define alc883_capsrc_nids alc882_capsrc_nids_alt
7415static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7416#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007417
Linus Torvalds1da177e2005-04-16 15:20:36 -07007418/* input MUX */
7419/* FIXME: should be a matrix-type input source selection */
7420
7421static struct hda_input_mux alc882_capture_source = {
7422 .num_items = 4,
7423 .items = {
7424 { "Mic", 0x0 },
7425 { "Front Mic", 0x1 },
7426 { "Line", 0x2 },
7427 { "CD", 0x4 },
7428 },
7429};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007430
Takashi Iwai4953550a2009-06-30 15:28:30 +02007431#define alc883_capture_source alc882_capture_source
7432
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007433static struct hda_input_mux alc889_capture_source = {
7434 .num_items = 3,
7435 .items = {
7436 { "Front Mic", 0x0 },
7437 { "Mic", 0x3 },
7438 { "Line", 0x2 },
7439 },
7440};
7441
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007442static struct hda_input_mux mb5_capture_source = {
7443 .num_items = 3,
7444 .items = {
7445 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307446 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007447 { "CD", 0x4 },
7448 },
7449};
7450
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007451static struct hda_input_mux macmini3_capture_source = {
7452 .num_items = 2,
7453 .items = {
7454 { "Line", 0x2 },
7455 { "CD", 0x4 },
7456 },
7457};
7458
Takashi Iwai4953550a2009-06-30 15:28:30 +02007459static struct hda_input_mux alc883_3stack_6ch_intel = {
7460 .num_items = 4,
7461 .items = {
7462 { "Mic", 0x1 },
7463 { "Front Mic", 0x0 },
7464 { "Line", 0x2 },
7465 { "CD", 0x4 },
7466 },
7467};
7468
7469static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7470 .num_items = 2,
7471 .items = {
7472 { "Mic", 0x1 },
7473 { "Line", 0x2 },
7474 },
7475};
7476
7477static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7478 .num_items = 4,
7479 .items = {
7480 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007481 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007482 { "Line", 0x2 },
7483 { "CD", 0x4 },
7484 },
7485};
7486
7487static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7488 .num_items = 2,
7489 .items = {
7490 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007491 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007492 },
7493};
7494
7495static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7496 .num_items = 3,
7497 .items = {
7498 { "Mic", 0x0 },
7499 { "Front Mic", 0x1 },
7500 { "Line", 0x4 },
7501 },
7502};
7503
7504static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7505 .num_items = 2,
7506 .items = {
7507 { "Mic", 0x0 },
7508 { "Line", 0x2 },
7509 },
7510};
7511
7512static struct hda_input_mux alc889A_mb31_capture_source = {
7513 .num_items = 2,
7514 .items = {
7515 { "Mic", 0x0 },
7516 /* Front Mic (0x01) unused */
7517 { "Line", 0x2 },
7518 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007519 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007520 },
7521};
7522
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007523static struct hda_input_mux alc889A_imac91_capture_source = {
7524 .num_items = 2,
7525 .items = {
7526 { "Mic", 0x01 },
7527 { "Line", 0x2 }, /* Not sure! */
7528 },
7529};
7530
Takashi Iwai4953550a2009-06-30 15:28:30 +02007531/*
7532 * 2ch mode
7533 */
7534static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7535 { 2, NULL }
7536};
7537
Kailang Yangdf694da2005-12-05 19:42:22 +01007538/*
Kailang Yang272a5272007-05-14 11:00:38 +02007539 * 2ch mode
7540 */
7541static struct hda_verb alc882_3ST_ch2_init[] = {
7542 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7543 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7544 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7545 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7546 { } /* end */
7547};
7548
7549/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007550 * 4ch mode
7551 */
7552static struct hda_verb alc882_3ST_ch4_init[] = {
7553 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7554 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7555 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7556 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7557 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7558 { } /* end */
7559};
7560
7561/*
Kailang Yang272a5272007-05-14 11:00:38 +02007562 * 6ch mode
7563 */
7564static struct hda_verb alc882_3ST_ch6_init[] = {
7565 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7566 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7567 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7568 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7569 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7570 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7571 { } /* end */
7572};
7573
Takashi Iwai4953550a2009-06-30 15:28:30 +02007574static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007575 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007576 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007577 { 6, alc882_3ST_ch6_init },
7578};
7579
Takashi Iwai4953550a2009-06-30 15:28:30 +02007580#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7581
Kailang Yang272a5272007-05-14 11:00:38 +02007582/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307583 * 2ch mode
7584 */
7585static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7586 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7587 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7588 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7589 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7590 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7591 { } /* end */
7592};
7593
7594/*
7595 * 4ch mode
7596 */
7597static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7598 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7599 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7600 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7601 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7602 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7603 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7604 { } /* end */
7605};
7606
7607/*
7608 * 6ch mode
7609 */
7610static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7611 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7612 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7613 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7614 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7615 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7616 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7617 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7618 { } /* end */
7619};
7620
7621static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7622 { 2, alc883_3ST_ch2_clevo_init },
7623 { 4, alc883_3ST_ch4_clevo_init },
7624 { 6, alc883_3ST_ch6_clevo_init },
7625};
7626
7627
7628/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007629 * 6ch mode
7630 */
7631static struct hda_verb alc882_sixstack_ch6_init[] = {
7632 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7633 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7634 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7635 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7636 { } /* end */
7637};
7638
7639/*
7640 * 8ch mode
7641 */
7642static struct hda_verb alc882_sixstack_ch8_init[] = {
7643 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7644 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7645 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7646 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7647 { } /* end */
7648};
7649
7650static struct hda_channel_mode alc882_sixstack_modes[2] = {
7651 { 6, alc882_sixstack_ch6_init },
7652 { 8, alc882_sixstack_ch8_init },
7653};
7654
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007655
7656/* Macbook Air 2,1 */
7657
7658static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7659 { 2, NULL },
7660};
7661
Takashi Iwai87350ad2007-08-16 18:19:38 +02007662/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007663 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007664 */
7665
7666/*
7667 * 2ch mode
7668 */
7669static struct hda_verb alc885_mbp_ch2_init[] = {
7670 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7671 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7672 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7673 { } /* end */
7674};
7675
7676/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007677 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007678 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007679static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007680 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7681 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7682 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7683 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7684 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7685 { } /* end */
7686};
7687
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007688static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007689 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007690 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007691};
7692
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007693/*
7694 * 2ch
7695 * Speakers/Woofer/HP = Front
7696 * LineIn = Input
7697 */
7698static struct hda_verb alc885_mb5_ch2_init[] = {
7699 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7700 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7701 { } /* end */
7702};
7703
7704/*
7705 * 6ch mode
7706 * Speakers/HP = Front
7707 * Woofer = LFE
7708 * LineIn = Surround
7709 */
7710static struct hda_verb alc885_mb5_ch6_init[] = {
7711 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7712 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7713 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7714 { } /* end */
7715};
7716
7717static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7718 { 2, alc885_mb5_ch2_init },
7719 { 6, alc885_mb5_ch6_init },
7720};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007721
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007722#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007723
7724/*
7725 * 2ch mode
7726 */
7727static struct hda_verb alc883_4ST_ch2_init[] = {
7728 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7729 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7730 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7731 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7732 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7733 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7734 { } /* end */
7735};
7736
7737/*
7738 * 4ch mode
7739 */
7740static struct hda_verb alc883_4ST_ch4_init[] = {
7741 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7742 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7743 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7744 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7745 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7746 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7747 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7748 { } /* end */
7749};
7750
7751/*
7752 * 6ch mode
7753 */
7754static struct hda_verb alc883_4ST_ch6_init[] = {
7755 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7756 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7757 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7758 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7759 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7760 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7761 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7762 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7763 { } /* end */
7764};
7765
7766/*
7767 * 8ch mode
7768 */
7769static struct hda_verb alc883_4ST_ch8_init[] = {
7770 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7771 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7772 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7773 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7774 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7775 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7776 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7777 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7778 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7779 { } /* end */
7780};
7781
7782static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7783 { 2, alc883_4ST_ch2_init },
7784 { 4, alc883_4ST_ch4_init },
7785 { 6, alc883_4ST_ch6_init },
7786 { 8, alc883_4ST_ch8_init },
7787};
7788
7789
7790/*
7791 * 2ch mode
7792 */
7793static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7794 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7795 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7796 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7797 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7798 { } /* end */
7799};
7800
7801/*
7802 * 4ch mode
7803 */
7804static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7805 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7806 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7807 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7808 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7809 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7810 { } /* end */
7811};
7812
7813/*
7814 * 6ch mode
7815 */
7816static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7817 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7818 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7819 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7820 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7821 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7822 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7823 { } /* end */
7824};
7825
7826static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7827 { 2, alc883_3ST_ch2_intel_init },
7828 { 4, alc883_3ST_ch4_intel_init },
7829 { 6, alc883_3ST_ch6_intel_init },
7830};
7831
7832/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007833 * 2ch mode
7834 */
7835static struct hda_verb alc889_ch2_intel_init[] = {
7836 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7837 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7838 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7839 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7840 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7841 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7842 { } /* end */
7843};
7844
7845/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007846 * 6ch mode
7847 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007848static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007849 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7850 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7851 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7852 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7853 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007854 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7855 { } /* end */
7856};
7857
7858/*
7859 * 8ch mode
7860 */
7861static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007862 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7863 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7864 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7865 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7866 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007867 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7868 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007869 { } /* end */
7870};
7871
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007872static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7873 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007874 { 6, alc889_ch6_intel_init },
7875 { 8, alc889_ch8_intel_init },
7876};
7877
7878/*
7879 * 6ch mode
7880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007881static struct hda_verb alc883_sixstack_ch6_init[] = {
7882 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7883 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7884 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7885 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7886 { } /* end */
7887};
7888
7889/*
7890 * 8ch mode
7891 */
7892static struct hda_verb alc883_sixstack_ch8_init[] = {
7893 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7894 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7895 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7896 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7897 { } /* end */
7898};
7899
7900static struct hda_channel_mode alc883_sixstack_modes[2] = {
7901 { 6, alc883_sixstack_ch6_init },
7902 { 8, alc883_sixstack_ch8_init },
7903};
7904
7905
Linus Torvalds1da177e2005-04-16 15:20:36 -07007906/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7907 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7908 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007909static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007910 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007911 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007912 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007913 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007914 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7915 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007916 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7917 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007918 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007919 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007920 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7921 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7922 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7923 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7924 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7925 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007926 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007927 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7928 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007929 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007930 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007931 { } /* end */
7932};
7933
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007934/* Macbook Air 2,1 same control for HP and internal Speaker */
7935
7936static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7937 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7938 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7939 { }
7940};
7941
7942
Takashi Iwai87350ad2007-08-16 18:19:38 +02007943static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007944 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7945 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7946 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7947 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7948 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007949 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7950 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007951 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7952 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007953 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
7954 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007955 { } /* end */
7956};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007957
7958static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007959 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7960 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7961 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7962 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7963 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7964 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307965 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7966 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09307967 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7968 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7970 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007971 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
7972 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0x00, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007973 { } /* end */
7974};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007975
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007976static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7977 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7978 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7979 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7980 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7981 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7982 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7983 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7984 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7985 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7986 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007987 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007988 { } /* end */
7989};
7990
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007991static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007992 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7993 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007994 { } /* end */
7995};
7996
7997
Kailang Yangbdd148a2007-05-08 15:19:08 +02007998static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7999 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8000 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8001 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8002 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8003 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8004 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8005 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008006 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008007 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008008 { } /* end */
8009};
8010
Kailang Yang272a5272007-05-14 11:00:38 +02008011static struct snd_kcontrol_new alc882_targa_mixer[] = {
8012 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8013 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8014 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8015 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8016 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8017 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8018 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8019 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8020 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008021 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008022 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8023 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008024 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008025 { } /* end */
8026};
8027
8028/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
8029 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
8030 */
8031static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
8032 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8033 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8034 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8035 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8036 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8037 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8038 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8039 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8040 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
8041 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
8042 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8043 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008044 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008045 { } /* end */
8046};
8047
Takashi Iwai914759b2007-09-06 14:52:04 +02008048static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
8049 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8050 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8051 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8052 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8053 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8054 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8055 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8056 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008057 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008058 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008059 { } /* end */
8060};
8061
Kailang Yangdf694da2005-12-05 19:42:22 +01008062static struct snd_kcontrol_new alc882_chmode_mixer[] = {
8063 {
8064 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8065 .name = "Channel Mode",
8066 .info = alc_ch_mode_info,
8067 .get = alc_ch_mode_get,
8068 .put = alc_ch_mode_put,
8069 },
8070 { } /* end */
8071};
8072
Takashi Iwai4953550a2009-06-30 15:28:30 +02008073static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07008074 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008075 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8076 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008077 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008078 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8079 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008080 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008081 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8082 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008083 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008084 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8085 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008086
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008087 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008088 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008089 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008090 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008091 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008092 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008093 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008094 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008095 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008096 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008097 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008098 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008099 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008100 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008101 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008102 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008103 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008104 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008105 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8106 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008107 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008108 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8109 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008110 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008111 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8112 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8113 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8114 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8115 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008116 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008117 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008118
8119 /* FIXME: use matrix-type input source selection */
8120 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008121 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008122 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008123 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008124 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02008125 /* ADC2: mute amp left and right */
8126 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008127 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02008128 /* ADC3: mute amp left and right */
8129 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008130 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008131
8132 { }
8133};
8134
Takashi Iwai4953550a2009-06-30 15:28:30 +02008135static struct hda_verb alc882_adc1_init_verbs[] = {
8136 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8137 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8138 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8139 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8140 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8141 /* ADC1: mute amp left and right */
8142 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8143 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8144 { }
8145};
8146
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008147static struct hda_verb alc882_eapd_verbs[] = {
8148 /* change to EAPD mode */
8149 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008150 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008151 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008152};
8153
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008154static struct hda_verb alc889_eapd_verbs[] = {
8155 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8156 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8157 { }
8158};
8159
Wu Fengguang6732bd02009-07-30 09:19:14 +02008160static struct hda_verb alc_hp15_unsol_verbs[] = {
8161 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8162 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8163 {}
8164};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008165
8166static struct hda_verb alc885_init_verbs[] = {
8167 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01008168 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8169 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008170 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008171 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8172 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008173 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008174 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8175 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008176 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008177 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8178 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008179
8180 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02008181 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008182 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8183 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8184 /* Front Pin: output 0 (0x0c) */
8185 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8186 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8187 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8188 /* Rear Pin: output 1 (0x0d) */
8189 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8190 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8191 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
8192 /* CLFE Pin: output 2 (0x0e) */
8193 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8194 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8195 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8196 /* Side Pin: output 3 (0x0f) */
8197 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8198 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8199 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8200 /* Mic (rear) pin: input vref at 80% */
8201 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8202 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8203 /* Front Mic pin: input vref at 80% */
8204 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8205 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8206 /* Line In pin: input */
8207 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8208 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8209
8210 /* Mixer elements: 0x18, , 0x1a, 0x1b */
8211 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01008212 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008213 /* Input mixer2 */
8214 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008215 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008216 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008217 /* ADC2: mute amp left and right */
8218 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8219 /* ADC3: mute amp left and right */
8220 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8221
8222 { }
8223};
8224
8225static struct hda_verb alc885_init_input_verbs[] = {
8226 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8227 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8228 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8229 { }
8230};
8231
8232
8233/* Unmute Selector 24h and set the default input to front mic */
8234static struct hda_verb alc889_init_input_verbs[] = {
8235 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8236 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8237 { }
8238};
8239
8240
Takashi Iwai4953550a2009-06-30 15:28:30 +02008241#define alc883_init_verbs alc882_base_init_verbs
8242
Tobin Davis9102cd12006-12-15 10:02:12 +01008243/* Mac Pro test */
8244static struct snd_kcontrol_new alc882_macpro_mixer[] = {
8245 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8246 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8247 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
8248 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8249 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008250 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01008251 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
8252 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008253 */
Tobin Davis9102cd12006-12-15 10:02:12 +01008254 { } /* end */
8255};
8256
8257static struct hda_verb alc882_macpro_init_verbs[] = {
8258 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8259 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8260 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8261 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8262 /* Front Pin: output 0 (0x0c) */
8263 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8264 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8265 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8266 /* Front Mic pin: input vref at 80% */
8267 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8268 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8269 /* Speaker: output */
8270 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8271 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8272 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
8273 /* Headphone output (output 0 - 0x0c) */
8274 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8275 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8276 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8277
8278 /* FIXME: use matrix-type input source selection */
8279 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8280 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8281 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8282 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8283 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8284 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8285 /* Input mixer2 */
8286 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8287 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8288 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8289 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8290 /* Input mixer3 */
8291 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8292 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8293 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8294 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8295 /* ADC1: mute amp left and right */
8296 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8297 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8298 /* ADC2: mute amp left and right */
8299 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8300 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8301 /* ADC3: mute amp left and right */
8302 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8303 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8304
8305 { }
8306};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008307
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008308/* Macbook 5,1 */
8309static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008310 /* DACs */
8311 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8312 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8313 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8314 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008315 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008316 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8317 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8318 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008319 /* Surround mixer */
8320 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8321 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8322 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8323 /* LFE mixer */
8324 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8325 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8326 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8327 /* HP mixer */
8328 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8329 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8330 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8331 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008332 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8333 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008334 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8335 /* LFE Pin (0x0e) */
8336 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8337 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8338 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8339 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008340 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8341 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008342 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308343 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008344 /* Front Mic pin: input vref at 80% */
8345 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8346 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8347 /* Line In pin */
8348 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8349 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8350
Alex Murrayb8f171e2010-06-14 12:08:43 +09308351 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8352 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8353 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008354 { }
8355};
8356
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008357/* Macmini 3,1 */
8358static struct hda_verb alc885_macmini3_init_verbs[] = {
8359 /* DACs */
8360 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8361 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8362 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8363 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8364 /* Front mixer */
8365 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8366 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8367 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8368 /* Surround mixer */
8369 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8370 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8371 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8372 /* LFE mixer */
8373 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8374 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8375 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8376 /* HP mixer */
8377 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8378 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8379 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8380 /* Front Pin (0x0c) */
8381 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8382 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8383 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8384 /* LFE Pin (0x0e) */
8385 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8386 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8387 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8388 /* HP Pin (0x0f) */
8389 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8390 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8391 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8392 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8393 /* Line In pin */
8394 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8395 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8396
8397 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8398 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8399 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8400 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8401 { }
8402};
8403
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008404
8405static struct hda_verb alc885_mba21_init_verbs[] = {
8406 /*Internal and HP Speaker Mixer*/
8407 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8408 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8409 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8410 /*Internal Speaker Pin (0x0c)*/
8411 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8412 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8413 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8414 /* HP Pin: output 0 (0x0e) */
8415 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8416 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8417 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8418 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8419 /* Line in (is hp when jack connected)*/
8420 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8421 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8422
8423 { }
8424 };
8425
8426
Takashi Iwai87350ad2007-08-16 18:19:38 +02008427/* Macbook Pro rev3 */
8428static struct hda_verb alc885_mbp3_init_verbs[] = {
8429 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8430 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8431 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8432 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8433 /* Rear mixer */
8434 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8435 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8436 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008437 /* HP mixer */
8438 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8439 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8440 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008441 /* Front Pin: output 0 (0x0c) */
8442 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8443 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8444 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008445 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008446 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008447 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8448 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008449 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8450 /* Mic (rear) pin: input vref at 80% */
8451 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8452 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8453 /* Front Mic pin: input vref at 80% */
8454 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8455 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8456 /* Line In pin: use output 1 when in LineOut mode */
8457 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8458 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8459 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8460
8461 /* FIXME: use matrix-type input source selection */
8462 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8463 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8464 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8465 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8466 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8467 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8468 /* Input mixer2 */
8469 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8470 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8471 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8472 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8473 /* Input mixer3 */
8474 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8475 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8476 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8477 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8478 /* ADC1: mute amp left and right */
8479 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8480 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8481 /* ADC2: mute amp left and right */
8482 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8483 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8484 /* ADC3: mute amp left and right */
8485 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8486 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8487
8488 { }
8489};
8490
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008491/* iMac 9,1 */
8492static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008493 /* Internal Speaker Pin (0x0c) */
8494 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8495 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8496 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8497 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8498 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8499 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8500 /* HP Pin: Rear */
8501 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8502 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8503 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8504 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8505 /* Line in Rear */
8506 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8507 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8508 /* Front Mic pin: input vref at 80% */
8509 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8510 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008511 /* Rear mixer */
8512 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8513 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8514 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008515 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8516 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8517 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8518 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8519 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008520 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8521 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8522 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8523 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008524 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008525 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8526 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8527 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8528 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008529 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008530 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8531 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8532 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8533 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008534 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008535 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8536 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008537 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008538 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8539 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008540 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008541 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8542 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008543 { }
8544};
8545
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008546/* iMac 24 mixer. */
8547static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8548 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8549 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8550 { } /* end */
8551};
8552
8553/* iMac 24 init verbs. */
8554static struct hda_verb alc885_imac24_init_verbs[] = {
8555 /* Internal speakers: output 0 (0x0c) */
8556 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8557 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8558 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8559 /* Internal speakers: output 0 (0x0c) */
8560 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8561 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8562 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8563 /* Headphone: output 0 (0x0c) */
8564 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8565 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8566 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8567 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8568 /* Front Mic: input vref at 80% */
8569 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8570 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8571 { }
8572};
8573
8574/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008575static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008576{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008577 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008578
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008579 spec->autocfg.hp_pins[0] = 0x14;
8580 spec->autocfg.speaker_pins[0] = 0x18;
8581 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008582}
8583
Takashi Iwai9d54f082010-02-22 08:34:40 +01008584#define alc885_mb5_setup alc885_imac24_setup
8585#define alc885_macmini3_setup alc885_imac24_setup
8586
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008587/* Macbook Air 2,1 */
8588static void alc885_mba21_setup(struct hda_codec *codec)
8589{
8590 struct alc_spec *spec = codec->spec;
8591
8592 spec->autocfg.hp_pins[0] = 0x14;
8593 spec->autocfg.speaker_pins[0] = 0x18;
8594}
8595
8596
8597
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008598static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008599{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008600 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008601
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008602 spec->autocfg.hp_pins[0] = 0x15;
8603 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008604}
8605
Takashi Iwai9d54f082010-02-22 08:34:40 +01008606static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308607{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008608 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308609
Takashi Iwai9d54f082010-02-22 08:34:40 +01008610 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008611 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008612 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008613}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008614
Kailang Yang272a5272007-05-14 11:00:38 +02008615static struct hda_verb alc882_targa_verbs[] = {
8616 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8617 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8618
8619 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8620 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008621
Kailang Yang272a5272007-05-14 11:00:38 +02008622 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8623 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8624 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8625
8626 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008627 { } /* end */
8628};
8629
8630/* toggle speaker-output according to the hp-jack state */
8631static void alc882_targa_automute(struct hda_codec *codec)
8632{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008633 struct alc_spec *spec = codec->spec;
8634 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008635 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008636 spec->jack_present ? 1 : 3);
8637}
8638
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008639static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008640{
8641 struct alc_spec *spec = codec->spec;
8642
8643 spec->autocfg.hp_pins[0] = 0x14;
8644 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008645}
8646
8647static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8648{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008649 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008650 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008651}
8652
8653static struct hda_verb alc882_asus_a7j_verbs[] = {
8654 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8655 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8656
8657 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8658 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8659 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008660
Kailang Yang272a5272007-05-14 11:00:38 +02008661 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8662 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8663 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8664
8665 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8666 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8667 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8668 { } /* end */
8669};
8670
Takashi Iwai914759b2007-09-06 14:52:04 +02008671static struct hda_verb alc882_asus_a7m_verbs[] = {
8672 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8673 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8674
8675 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8676 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8677 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008678
Takashi Iwai914759b2007-09-06 14:52:04 +02008679 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8680 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8681 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8682
8683 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8684 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8685 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8686 { } /* end */
8687};
8688
Tobin Davis9102cd12006-12-15 10:02:12 +01008689static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8690{
8691 unsigned int gpiostate, gpiomask, gpiodir;
8692
8693 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8694 AC_VERB_GET_GPIO_DATA, 0);
8695
8696 if (!muted)
8697 gpiostate |= (1 << pin);
8698 else
8699 gpiostate &= ~(1 << pin);
8700
8701 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8702 AC_VERB_GET_GPIO_MASK, 0);
8703 gpiomask |= (1 << pin);
8704
8705 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8706 AC_VERB_GET_GPIO_DIRECTION, 0);
8707 gpiodir |= (1 << pin);
8708
8709
8710 snd_hda_codec_write(codec, codec->afg, 0,
8711 AC_VERB_SET_GPIO_MASK, gpiomask);
8712 snd_hda_codec_write(codec, codec->afg, 0,
8713 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8714
8715 msleep(1);
8716
8717 snd_hda_codec_write(codec, codec->afg, 0,
8718 AC_VERB_SET_GPIO_DATA, gpiostate);
8719}
8720
Takashi Iwai7debbe52007-08-16 15:01:03 +02008721/* set up GPIO at initialization */
8722static void alc885_macpro_init_hook(struct hda_codec *codec)
8723{
8724 alc882_gpio_mute(codec, 0, 0);
8725 alc882_gpio_mute(codec, 1, 0);
8726}
8727
8728/* set up GPIO and update auto-muting at initialization */
8729static void alc885_imac24_init_hook(struct hda_codec *codec)
8730{
8731 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008732 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008733}
8734
Kailang Yangdf694da2005-12-05 19:42:22 +01008735/*
8736 * generic initialization of ADC, input mixers and output mixers
8737 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008738static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008739 /*
8740 * Unmute ADC0-2 and set the default input to mic-in
8741 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008742 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8743 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8744 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8745 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8746
Kailang Yangdf694da2005-12-05 19:42:22 +01008747 /*
8748 * Set up output mixers (0x0c - 0x0f)
8749 */
8750 /* set vol=0 to output mixers */
8751 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8752 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8753 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8754 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8755 /* set up input amps for analog loopback */
8756 /* Amp Indices: DAC = 0, mixer = 1 */
8757 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8758 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8759 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8760 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8761 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8762 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8763 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8764 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8765 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8766 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8767
8768 /* FIXME: use matrix-type input source selection */
8769 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008770 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008771 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008772 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008773 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008774 { }
8775};
8776
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008777/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8778static struct hda_verb alc889A_mb31_ch2_init[] = {
8779 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8780 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8781 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8782 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8783 { } /* end */
8784};
8785
8786/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8787static struct hda_verb alc889A_mb31_ch4_init[] = {
8788 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8789 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8790 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8791 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8792 { } /* end */
8793};
8794
8795/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8796static struct hda_verb alc889A_mb31_ch5_init[] = {
8797 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8798 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8799 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8800 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8801 { } /* end */
8802};
8803
8804/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8805static struct hda_verb alc889A_mb31_ch6_init[] = {
8806 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8807 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8808 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8809 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8810 { } /* end */
8811};
8812
8813static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8814 { 2, alc889A_mb31_ch2_init },
8815 { 4, alc889A_mb31_ch4_init },
8816 { 5, alc889A_mb31_ch5_init },
8817 { 6, alc889A_mb31_ch6_init },
8818};
8819
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008820static struct hda_verb alc883_medion_eapd_verbs[] = {
8821 /* eanable EAPD on medion laptop */
8822 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8823 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8824 { }
8825};
8826
Takashi Iwai4953550a2009-06-30 15:28:30 +02008827#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008828
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008829static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8830 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8831 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8832 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8833 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8834 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8835 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8836 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8837 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008838 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008839 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8840 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008841 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008842 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008843 { } /* end */
8844};
8845
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008846static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008847 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8848 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8849 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8850 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8851 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008852 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008853 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008854 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008855 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008856 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008857 { } /* end */
8858};
8859
Jiang zhefb97dc62008-03-06 11:07:11 +01008860static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8861 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8862 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8863 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8864 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8865 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008866 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008867 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008868 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008869 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008870 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008871 { } /* end */
8872};
8873
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008874static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8875 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8876 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8877 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8878 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8879 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8880 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8881 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8882 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008883 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008884 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8885 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008886 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008887 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008888 { } /* end */
8889};
8890
8891static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8892 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8893 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8894 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8895 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8896 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8897 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8898 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8899 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8900 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8901 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8902 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8903 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8904 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8905 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008906 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008907 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8908 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008909 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008910 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008911 { } /* end */
8912};
8913
Jiang zhe17bba1b2008-06-04 12:11:07 +02008914static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8915 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8916 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8917 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8918 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8919 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8920 HDA_OUTPUT),
8921 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8922 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8923 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8924 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8925 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8926 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8927 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8928 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8929 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008930 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008931 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8932 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008933 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008934 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008935 { } /* end */
8936};
8937
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008938static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8939 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8940 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8941 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8942 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8943 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8944 HDA_OUTPUT),
8945 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8946 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8947 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8948 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8949 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8950 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8951 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8952 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008954 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008955 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8956 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008957 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008958 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8959 { } /* end */
8960};
8961
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008962static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008963 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008964 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008965 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008966 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008967 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8968 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008969 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8970 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008971 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8972 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8973 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8974 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8975 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8976 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008977 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008978 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8979 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008980 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008981 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008982 { } /* end */
8983};
8984
Sasha Alexandrc2592492009-06-16 14:52:54 -04008985static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008986 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008987 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008988 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008989 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008990 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8991 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8992 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8993 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8994 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8995 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8996 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8997 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8998 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8999 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9000 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009001 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009002 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009003 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009004};
Kailang Yangccc656c2006-10-17 12:32:26 +02009005
Sasha Alexandrc2592492009-06-16 14:52:54 -04009006static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009007 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009008 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009009 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009010 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009011 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9012 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9013 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009014 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009015 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009016 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009017 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009018 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009019 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009020};
Kailang Yangccc656c2006-10-17 12:32:26 +02009021
Takashi Iwaib99dba32009-09-17 18:23:00 +02009022static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
9023 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9024 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009025 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009026 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009027 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009028 { } /* end */
9029};
9030
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009031static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
9032 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9033 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009034 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9035 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009036 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9037 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009038 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009039 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009040 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009041};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009042
Kailang Yang272a5272007-05-14 11:00:38 +02009043static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
9044 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9045 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
9046 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9047 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9048 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9049 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9050 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009051 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9052 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02009053 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02009054};
Kailang Yang272a5272007-05-14 11:00:38 +02009055
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009056static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
9057 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9058 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9059 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9060 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
9061 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
9062 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
9063 { } /* end */
9064};
9065
9066static struct hda_verb alc883_medion_wim2160_verbs[] = {
9067 /* Unmute front mixer */
9068 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9069 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9070
9071 /* Set speaker pin to front mixer */
9072 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9073
9074 /* Init headphone pin */
9075 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9076 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9077 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9078 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9079
9080 { } /* end */
9081};
9082
9083/* toggle speaker-output according to the hp-jack state */
9084static void alc883_medion_wim2160_setup(struct hda_codec *codec)
9085{
9086 struct alc_spec *spec = codec->spec;
9087
9088 spec->autocfg.hp_pins[0] = 0x1a;
9089 spec->autocfg.speaker_pins[0] = 0x15;
9090}
9091
Tobin Davis2880a862007-08-07 11:50:26 +02009092static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02009093 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9094 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009095 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009096 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9097 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009098 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009099 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009100 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009101 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02009102};
Tobin Davis2880a862007-08-07 11:50:26 +02009103
Tony Vroond2fd4b02009-06-21 00:40:10 +01009104static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
9105 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009106 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01009107 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9108 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009109 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9110 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9111 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009112 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009113 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9114 { } /* end */
9115};
9116
Kailang Yange2757d52008-08-26 13:17:46 +02009117static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
9118 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9119 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9120 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9121 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
9122 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
9123 0x0d, 1, 0x0, HDA_OUTPUT),
9124 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
9125 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
9126 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
9127 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9128 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009129 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9130 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9131 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9132 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9133 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009134 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009135 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9136 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009137 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009138 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009139 { } /* end */
9140};
9141
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009142static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
9143 /* Output mixers */
9144 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
9145 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
9146 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
9147 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
9148 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
9149 HDA_OUTPUT),
9150 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
9151 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
9152 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
9153 /* Output switches */
9154 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
9155 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
9156 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
9157 /* Boost mixers */
David Henningsson5f99f862011-01-04 15:24:24 +01009158 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
9159 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009160 /* Input mixers */
9161 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
9162 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
9163 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9164 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9165 { } /* end */
9166};
9167
Guido Günther3e1647c2009-06-05 00:47:26 +02009168static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
9169 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9170 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9171 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9172 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009173 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Guido Günther3e1647c2009-06-05 00:47:26 +02009174 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9175 { } /* end */
9176};
9177
Kailang Yange2757d52008-08-26 13:17:46 +02009178static struct hda_bind_ctls alc883_bind_cap_vol = {
9179 .ops = &snd_hda_bind_vol,
9180 .values = {
9181 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9182 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9183 0
9184 },
9185};
9186
9187static struct hda_bind_ctls alc883_bind_cap_switch = {
9188 .ops = &snd_hda_bind_sw,
9189 .values = {
9190 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9191 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9192 0
9193 },
9194};
9195
9196static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
9197 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9198 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9199 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9200 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9201 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9202 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009203 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009204 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009205 { } /* end */
9206};
9207
9208static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009209 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
9210 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
9211 {
9212 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9213 /* .name = "Capture Source", */
9214 .name = "Input Source",
9215 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009216 .info = alc_mux_enum_info,
9217 .get = alc_mux_enum_get,
9218 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02009219 },
9220 { } /* end */
9221};
9222
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009223static struct snd_kcontrol_new alc883_chmode_mixer[] = {
9224 {
9225 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9226 .name = "Channel Mode",
9227 .info = alc_ch_mode_info,
9228 .get = alc_ch_mode_get,
9229 .put = alc_ch_mode_put,
9230 },
9231 { } /* end */
9232};
9233
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009234/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009235static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009236{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009237 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009238
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009239 spec->autocfg.hp_pins[0] = 0x15;
9240 spec->autocfg.speaker_pins[0] = 0x14;
9241 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009242}
9243
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009244static struct hda_verb alc883_mitac_verbs[] = {
9245 /* HP */
9246 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9247 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9248 /* Subwoofer */
9249 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9250 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9251
9252 /* enable unsolicited event */
9253 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9254 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
9255
9256 { } /* end */
9257};
9258
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309259static struct hda_verb alc883_clevo_m540r_verbs[] = {
9260 /* HP */
9261 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9262 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9263 /* Int speaker */
9264 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9265
9266 /* enable unsolicited event */
9267 /*
9268 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9269 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9270 */
9271
9272 { } /* end */
9273};
9274
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009275static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009276 /* HP */
9277 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9278 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9279 /* Int speaker */
9280 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9281 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9282
9283 /* enable unsolicited event */
9284 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009285 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009286
9287 { } /* end */
9288};
9289
Jiang zhefb97dc62008-03-06 11:07:11 +01009290static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9291 /* HP */
9292 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9293 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9294 /* Subwoofer */
9295 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9296 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9297
9298 /* enable unsolicited event */
9299 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9300
9301 { } /* end */
9302};
9303
Sasha Alexandrc2592492009-06-16 14:52:54 -04009304static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009305 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9306 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9307
9308 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9309 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009310
David Heidelberger64a8be72009-06-08 16:15:18 +02009311/* Connect Line-Out side jack (SPDIF) to Side */
9312 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9313 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9314 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9315/* Connect Mic jack to CLFE */
9316 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9317 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9318 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9319/* Connect Line-in jack to Surround */
9320 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9321 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9322 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9323/* Connect HP out jack to Front */
9324 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9325 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9326 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009327
9328 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009329
9330 { } /* end */
9331};
9332
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009333static struct hda_verb alc883_lenovo_101e_verbs[] = {
9334 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9335 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9336 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9337 { } /* end */
9338};
9339
Kailang Yang272a5272007-05-14 11:00:38 +02009340static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9341 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9342 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9343 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9344 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9345 { } /* end */
9346};
9347
9348static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
9349 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9350 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9351 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9352 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9353 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9354 { } /* end */
9355};
9356
Kailang Yang189609a2007-08-20 11:31:23 +02009357static struct hda_verb alc883_haier_w66_verbs[] = {
9358 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9359 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9360
9361 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9362
9363 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9364 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9365 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9366 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9367 { } /* end */
9368};
9369
Kailang Yange2757d52008-08-26 13:17:46 +02009370static struct hda_verb alc888_lenovo_sky_verbs[] = {
9371 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9372 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9373 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9374 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9375 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9376 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9377 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9378 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9379 { } /* end */
9380};
9381
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009382static struct hda_verb alc888_6st_dell_verbs[] = {
9383 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9384 { }
9385};
9386
Guido Günther3e1647c2009-06-05 00:47:26 +02009387static struct hda_verb alc883_vaiott_verbs[] = {
9388 /* HP */
9389 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9390 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9391
9392 /* enable unsolicited event */
9393 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9394
9395 { } /* end */
9396};
9397
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009398static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009399{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009400 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009401
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009402 spec->autocfg.hp_pins[0] = 0x1b;
9403 spec->autocfg.speaker_pins[0] = 0x14;
9404 spec->autocfg.speaker_pins[1] = 0x16;
9405 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009406}
9407
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009408static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009409 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009410 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9411 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009412 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009413 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009414};
9415
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009416/*
9417 * 2ch mode
9418 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009419static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009420 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9421 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9422 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9423 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009424 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009425};
9426
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009427/*
9428 * 4ch mode
9429 */
9430static struct hda_verb alc888_3st_hp_4ch_init[] = {
9431 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9432 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9433 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9434 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9435 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9436 { } /* end */
9437};
9438
9439/*
9440 * 6ch mode
9441 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009442static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009443 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9444 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009445 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009446 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9447 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009448 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9449 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009450};
9451
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009452static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009453 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009454 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009455 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009456};
9457
Kailang Yang272a5272007-05-14 11:00:38 +02009458/* toggle front-jack and RCA according to the hp-jack state */
9459static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9460{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009461 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02009462
Takashi Iwai47fd8302007-08-10 17:11:07 +02009463 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9464 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9465 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9466 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009467}
9468
9469/* toggle RCA according to the front-jack state */
9470static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9471{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009472 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009473
Takashi Iwai47fd8302007-08-10 17:11:07 +02009474 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9475 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009476}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009477
Kailang Yang272a5272007-05-14 11:00:38 +02009478static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9479 unsigned int res)
9480{
9481 if ((res >> 26) == ALC880_HP_EVENT)
9482 alc888_lenovo_ms7195_front_automute(codec);
9483 if ((res >> 26) == ALC880_FRONT_EVENT)
9484 alc888_lenovo_ms7195_rca_automute(codec);
9485}
9486
Kailang Yang272a5272007-05-14 11:00:38 +02009487/* toggle speaker-output according to the hp-jack state */
Takashi Iwaidc4271702010-11-29 07:42:59 +01009488static void alc883_lenovo_nb0763_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009489{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009490 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009491
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009492 spec->autocfg.hp_pins[0] = 0x14;
9493 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009494}
9495
Kailang Yangccc656c2006-10-17 12:32:26 +02009496/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009497#define alc883_targa_init_hook alc882_targa_init_hook
9498#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009499
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009500static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009501{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009502 struct alc_spec *spec = codec->spec;
9503
9504 spec->autocfg.hp_pins[0] = 0x15;
9505 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009506}
9507
9508static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9509{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009510 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01009511 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009512}
9513
9514static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009515 unsigned int res)
9516{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009517 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009518 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01009519 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009520 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009521 default:
9522 alc_automute_amp_unsol_event(codec, res);
9523 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009524 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009525}
9526
Jiang zhefb97dc62008-03-06 11:07:11 +01009527/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009528static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009529{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009530 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009531
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009532 spec->autocfg.hp_pins[0] = 0x14;
9533 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009534}
9535
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009536static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009537{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009538 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009539
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009540 spec->autocfg.hp_pins[0] = 0x1b;
9541 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009542}
9543
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009544static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9545{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009546 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009547
Takashi Iwai47fd8302007-08-10 17:11:07 +02009548 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9549 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009550}
9551
9552static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9553{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009554 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009555
Takashi Iwai47fd8302007-08-10 17:11:07 +02009556 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9557 HDA_AMP_MUTE, bits);
9558 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9559 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009560}
9561
9562static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9563 unsigned int res)
9564{
9565 if ((res >> 26) == ALC880_HP_EVENT)
9566 alc883_lenovo_101e_all_automute(codec);
9567 if ((res >> 26) == ALC880_FRONT_EVENT)
9568 alc883_lenovo_101e_ispeaker_automute(codec);
9569}
9570
Takashi Iwai676a9b52007-08-16 15:23:35 +02009571/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009572static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009573{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009574 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009575
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009576 spec->autocfg.hp_pins[0] = 0x14;
9577 spec->autocfg.speaker_pins[0] = 0x15;
9578 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009579}
9580
Kailang Yangd1a991a2007-08-15 16:21:59 +02009581static struct hda_verb alc883_acer_eapd_verbs[] = {
9582 /* HP Pin: output 0 (0x0c) */
9583 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9584 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9585 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9586 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009587 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9588 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009589 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009590 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9591 /* eanable EAPD on medion laptop */
9592 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9593 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009594 /* enable unsolicited event */
9595 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009596 { }
9597};
9598
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009599static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009600{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009601 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009602
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009603 spec->autocfg.hp_pins[0] = 0x1b;
9604 spec->autocfg.speaker_pins[0] = 0x14;
9605 spec->autocfg.speaker_pins[1] = 0x15;
9606 spec->autocfg.speaker_pins[2] = 0x16;
9607 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009608}
9609
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009610static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009611{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009612 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009613
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009614 spec->autocfg.hp_pins[0] = 0x1b;
9615 spec->autocfg.speaker_pins[0] = 0x14;
9616 spec->autocfg.speaker_pins[1] = 0x15;
9617 spec->autocfg.speaker_pins[2] = 0x16;
9618 spec->autocfg.speaker_pins[3] = 0x17;
9619 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009620}
9621
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009622static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009623{
9624 struct alc_spec *spec = codec->spec;
9625
9626 spec->autocfg.hp_pins[0] = 0x15;
9627 spec->autocfg.speaker_pins[0] = 0x14;
9628 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009629}
9630
Kailang Yange2757d52008-08-26 13:17:46 +02009631static struct hda_verb alc888_asus_m90v_verbs[] = {
9632 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9633 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9634 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9635 /* enable unsolicited event */
9636 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9637 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9638 { } /* end */
9639};
9640
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009641static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009642{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009643 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009644
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009645 spec->autocfg.hp_pins[0] = 0x1b;
9646 spec->autocfg.speaker_pins[0] = 0x14;
9647 spec->autocfg.speaker_pins[1] = 0x15;
9648 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009649 spec->ext_mic.pin = 0x18;
9650 spec->int_mic.pin = 0x19;
9651 spec->ext_mic.mux_idx = 0;
9652 spec->int_mic.mux_idx = 1;
9653 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009654}
9655
9656static struct hda_verb alc888_asus_eee1601_verbs[] = {
9657 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9658 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9659 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9660 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9661 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9662 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9663 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9664 /* enable unsolicited event */
9665 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9666 { } /* end */
9667};
9668
Kailang Yange2757d52008-08-26 13:17:46 +02009669static void alc883_eee1601_inithook(struct hda_codec *codec)
9670{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009671 struct alc_spec *spec = codec->spec;
9672
9673 spec->autocfg.hp_pins[0] = 0x14;
9674 spec->autocfg.speaker_pins[0] = 0x1b;
9675 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009676}
9677
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009678static struct hda_verb alc889A_mb31_verbs[] = {
9679 /* Init rear pin (used as headphone output) */
9680 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9681 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9682 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9683 /* Init line pin (used as output in 4ch and 6ch mode) */
9684 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9685 /* Init line 2 pin (used as headphone out by default) */
9686 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9687 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9688 { } /* end */
9689};
9690
9691/* Mute speakers according to the headphone jack state */
9692static void alc889A_mb31_automute(struct hda_codec *codec)
9693{
9694 unsigned int present;
9695
9696 /* Mute only in 2ch or 4ch mode */
9697 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9698 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009699 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009700 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9701 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9702 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9703 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9704 }
9705}
9706
9707static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9708{
9709 if ((res >> 26) == ALC880_HP_EVENT)
9710 alc889A_mb31_automute(codec);
9711}
9712
Takashi Iwai4953550a2009-06-30 15:28:30 +02009713
Takashi Iwaicb53c622007-08-10 17:21:45 +02009714#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009715#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009716#endif
9717
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009718/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009719#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9720#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9721#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9722#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9723
9724static hda_nid_t alc883_slave_dig_outs[] = {
9725 ALC1200_DIGOUT_NID, 0,
9726};
9727
9728static hda_nid_t alc1200_slave_dig_outs[] = {
9729 ALC883_DIGOUT_NID, 0,
9730};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009731
9732/*
9733 * configuration and preset
9734 */
Takashi Iwaiea734962011-01-17 11:29:34 +01009735static const char * const alc882_models[ALC882_MODEL_LAST] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009736 [ALC882_3ST_DIG] = "3stack-dig",
9737 [ALC882_6ST_DIG] = "6stack-dig",
9738 [ALC882_ARIMA] = "arima",
9739 [ALC882_W2JC] = "w2jc",
9740 [ALC882_TARGA] = "targa",
9741 [ALC882_ASUS_A7J] = "asus-a7j",
9742 [ALC882_ASUS_A7M] = "asus-a7m",
9743 [ALC885_MACPRO] = "macpro",
9744 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009745 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009746 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009747 [ALC885_MBP3] = "mbp3",
9748 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009749 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009750 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009751 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9752 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009753 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009754 [ALC883_TARGA_DIG] = "targa-dig",
9755 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009756 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009757 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009758 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009759 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009760 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009761 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009762 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009763 [ALC883_MEDION] = "medion",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009764 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009765 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009766 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009767 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9768 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009769 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009770 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009771 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009772 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009773 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309774 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009775 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009776 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009777 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009778 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009779 [ALC889A_INTEL] = "intel-alc889a",
9780 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009781 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009782 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009783 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009784 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009785};
9786
Takashi Iwai4953550a2009-06-30 15:28:30 +02009787static struct snd_pci_quirk alc882_cfg_tbl[] = {
9788 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9789
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009790 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009791 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009792 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009793 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9794 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009795 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009796 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9797 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009798 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009799 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009800 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9801 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009802 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9803 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009804 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9805 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009806 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009807 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009808 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009809 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009810 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9811 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009812 /* default Acer -- disabled as it causes more problems.
9813 * model=auto should work fine now
9814 */
9815 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009816
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009817 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009818
Tobin Davisfebe3372007-06-12 11:27:46 +02009819 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009820 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9821 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009822 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009823 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009824 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009825
9826 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9827 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9828 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009829 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009830 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9831 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9832 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009833 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009834 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009835 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009836 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009837
9838 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009839 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009840 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009841 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009842 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9843 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009844 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009845 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009846 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9847
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009848 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9849 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9850 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009851 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009852 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009853 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009854 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009855 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009856 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9857 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9858 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9859 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9860 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9861 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009862 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009863 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9864 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9865 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009866 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009867 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009868 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9869 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009870 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009871 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009872 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009873 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009874 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009875 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009876 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009877 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009878 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009879
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009880 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009881 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009882 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9883 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309884 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009885 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009886 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009887 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009888 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009889 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009890 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009891 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009892 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009893 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009894 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009895 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9896 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009897 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Takashi Iwai959973b2008-11-05 11:30:56 +01009898 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009899 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009900 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009901
Jiang zhe17bba1b2008-06-04 12:11:07 +02009902 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9903 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009904 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009905 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9906 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9907 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009908 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009909
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009910 {}
9911};
9912
Takashi Iwai4953550a2009-06-30 15:28:30 +02009913/* codec SSID table for Intel Mac */
9914static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9915 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9916 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9917 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9918 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9919 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9920 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9921 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009922 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009923 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009924 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009925 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009926 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9927 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9928 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009929 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009930 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +10009931 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009932 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9933 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009934 */
9935 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009936 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009937 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009938 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009939};
9940
Takashi Iwai4953550a2009-06-30 15:28:30 +02009941static struct alc_config_preset alc882_presets[] = {
9942 [ALC882_3ST_DIG] = {
9943 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009944 .init_verbs = { alc882_base_init_verbs,
9945 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009946 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9947 .dac_nids = alc882_dac_nids,
9948 .dig_out_nid = ALC882_DIGOUT_NID,
9949 .dig_in_nid = ALC882_DIGIN_NID,
9950 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9951 .channel_mode = alc882_ch_modes,
9952 .need_dac_fix = 1,
9953 .input_mux = &alc882_capture_source,
9954 },
9955 [ALC882_6ST_DIG] = {
9956 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009957 .init_verbs = { alc882_base_init_verbs,
9958 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009959 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9960 .dac_nids = alc882_dac_nids,
9961 .dig_out_nid = ALC882_DIGOUT_NID,
9962 .dig_in_nid = ALC882_DIGIN_NID,
9963 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9964 .channel_mode = alc882_sixstack_modes,
9965 .input_mux = &alc882_capture_source,
9966 },
9967 [ALC882_ARIMA] = {
9968 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009969 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9970 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009971 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9972 .dac_nids = alc882_dac_nids,
9973 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9974 .channel_mode = alc882_sixstack_modes,
9975 .input_mux = &alc882_capture_source,
9976 },
9977 [ALC882_W2JC] = {
9978 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009979 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9980 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009981 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9982 .dac_nids = alc882_dac_nids,
9983 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9984 .channel_mode = alc880_threestack_modes,
9985 .need_dac_fix = 1,
9986 .input_mux = &alc882_capture_source,
9987 .dig_out_nid = ALC882_DIGOUT_NID,
9988 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009989 [ALC885_MBA21] = {
9990 .mixers = { alc885_mba21_mixer },
9991 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9992 .num_dacs = 2,
9993 .dac_nids = alc882_dac_nids,
9994 .channel_mode = alc885_mba21_ch_modes,
9995 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9996 .input_mux = &alc882_capture_source,
9997 .unsol_event = alc_automute_amp_unsol_event,
9998 .setup = alc885_mba21_setup,
9999 .init_hook = alc_automute_amp,
10000 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010001 [ALC885_MBP3] = {
10002 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
10003 .init_verbs = { alc885_mbp3_init_verbs,
10004 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010005 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010006 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010007 .hp_nid = 0x04,
10008 .channel_mode = alc885_mbp_4ch_modes,
10009 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010010 .input_mux = &alc882_capture_source,
10011 .dig_out_nid = ALC882_DIGOUT_NID,
10012 .dig_in_nid = ALC882_DIGIN_NID,
10013 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010014 .setup = alc885_mbp3_setup,
10015 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010016 },
10017 [ALC885_MB5] = {
10018 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
10019 .init_verbs = { alc885_mb5_init_verbs,
10020 alc880_gpio1_init_verbs },
10021 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10022 .dac_nids = alc882_dac_nids,
10023 .channel_mode = alc885_mb5_6ch_modes,
10024 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
10025 .input_mux = &mb5_capture_source,
10026 .dig_out_nid = ALC882_DIGOUT_NID,
10027 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010028 .unsol_event = alc_automute_amp_unsol_event,
10029 .setup = alc885_mb5_setup,
10030 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010031 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010032 [ALC885_MACMINI3] = {
10033 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
10034 .init_verbs = { alc885_macmini3_init_verbs,
10035 alc880_gpio1_init_verbs },
10036 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10037 .dac_nids = alc882_dac_nids,
10038 .channel_mode = alc885_macmini3_6ch_modes,
10039 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
10040 .input_mux = &macmini3_capture_source,
10041 .dig_out_nid = ALC882_DIGOUT_NID,
10042 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010043 .unsol_event = alc_automute_amp_unsol_event,
10044 .setup = alc885_macmini3_setup,
10045 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010046 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010047 [ALC885_MACPRO] = {
10048 .mixers = { alc882_macpro_mixer },
10049 .init_verbs = { alc882_macpro_init_verbs },
10050 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10051 .dac_nids = alc882_dac_nids,
10052 .dig_out_nid = ALC882_DIGOUT_NID,
10053 .dig_in_nid = ALC882_DIGIN_NID,
10054 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10055 .channel_mode = alc882_ch_modes,
10056 .input_mux = &alc882_capture_source,
10057 .init_hook = alc885_macpro_init_hook,
10058 },
10059 [ALC885_IMAC24] = {
10060 .mixers = { alc885_imac24_mixer },
10061 .init_verbs = { alc885_imac24_init_verbs },
10062 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10063 .dac_nids = alc882_dac_nids,
10064 .dig_out_nid = ALC882_DIGOUT_NID,
10065 .dig_in_nid = ALC882_DIGIN_NID,
10066 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10067 .channel_mode = alc882_ch_modes,
10068 .input_mux = &alc882_capture_source,
10069 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010070 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010071 .init_hook = alc885_imac24_init_hook,
10072 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010073 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010074 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010075 .init_verbs = { alc885_imac91_init_verbs,
10076 alc880_gpio1_init_verbs },
10077 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10078 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010079 .channel_mode = alc885_mba21_ch_modes,
10080 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10081 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010082 .dig_out_nid = ALC882_DIGOUT_NID,
10083 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010084 .unsol_event = alc_automute_amp_unsol_event,
10085 .setup = alc885_imac91_setup,
10086 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010087 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010088 [ALC882_TARGA] = {
10089 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010090 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +020010091 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010092 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10093 .dac_nids = alc882_dac_nids,
10094 .dig_out_nid = ALC882_DIGOUT_NID,
10095 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10096 .adc_nids = alc882_adc_nids,
10097 .capsrc_nids = alc882_capsrc_nids,
10098 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10099 .channel_mode = alc882_3ST_6ch_modes,
10100 .need_dac_fix = 1,
10101 .input_mux = &alc882_capture_source,
10102 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010103 .setup = alc882_targa_setup,
10104 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010105 },
10106 [ALC882_ASUS_A7J] = {
10107 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010108 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10109 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010110 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10111 .dac_nids = alc882_dac_nids,
10112 .dig_out_nid = ALC882_DIGOUT_NID,
10113 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10114 .adc_nids = alc882_adc_nids,
10115 .capsrc_nids = alc882_capsrc_nids,
10116 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10117 .channel_mode = alc882_3ST_6ch_modes,
10118 .need_dac_fix = 1,
10119 .input_mux = &alc882_capture_source,
10120 },
10121 [ALC882_ASUS_A7M] = {
10122 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010123 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10124 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010125 alc882_asus_a7m_verbs },
10126 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10127 .dac_nids = alc882_dac_nids,
10128 .dig_out_nid = ALC882_DIGOUT_NID,
10129 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10130 .channel_mode = alc880_threestack_modes,
10131 .need_dac_fix = 1,
10132 .input_mux = &alc882_capture_source,
10133 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010134 [ALC883_3ST_2ch_DIG] = {
10135 .mixers = { alc883_3ST_2ch_mixer },
10136 .init_verbs = { alc883_init_verbs },
10137 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10138 .dac_nids = alc883_dac_nids,
10139 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010140 .dig_in_nid = ALC883_DIGIN_NID,
10141 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10142 .channel_mode = alc883_3ST_2ch_modes,
10143 .input_mux = &alc883_capture_source,
10144 },
10145 [ALC883_3ST_6ch_DIG] = {
10146 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10147 .init_verbs = { alc883_init_verbs },
10148 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10149 .dac_nids = alc883_dac_nids,
10150 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010151 .dig_in_nid = ALC883_DIGIN_NID,
10152 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10153 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010154 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010155 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010156 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010157 [ALC883_3ST_6ch] = {
10158 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10159 .init_verbs = { alc883_init_verbs },
10160 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10161 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010162 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10163 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010164 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010165 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010166 },
Jiang zhe17bba1b2008-06-04 12:11:07 +020010167 [ALC883_3ST_6ch_INTEL] = {
10168 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
10169 .init_verbs = { alc883_init_verbs },
10170 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10171 .dac_nids = alc883_dac_nids,
10172 .dig_out_nid = ALC883_DIGOUT_NID,
10173 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010174 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +020010175 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
10176 .channel_mode = alc883_3ST_6ch_intel_modes,
10177 .need_dac_fix = 1,
10178 .input_mux = &alc883_3stack_6ch_intel,
10179 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010180 [ALC889A_INTEL] = {
10181 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020010182 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
10183 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010184 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10185 .dac_nids = alc883_dac_nids,
10186 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10187 .adc_nids = alc889_adc_nids,
10188 .dig_out_nid = ALC883_DIGOUT_NID,
10189 .dig_in_nid = ALC883_DIGIN_NID,
10190 .slave_dig_outs = alc883_slave_dig_outs,
10191 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10192 .channel_mode = alc889_8ch_intel_modes,
10193 .capsrc_nids = alc889_capsrc_nids,
10194 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010195 .setup = alc889_automute_setup,
10196 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010197 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010198 .need_dac_fix = 1,
10199 },
10200 [ALC889_INTEL] = {
10201 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
10202 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010203 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010204 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10205 .dac_nids = alc883_dac_nids,
10206 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10207 .adc_nids = alc889_adc_nids,
10208 .dig_out_nid = ALC883_DIGOUT_NID,
10209 .dig_in_nid = ALC883_DIGIN_NID,
10210 .slave_dig_outs = alc883_slave_dig_outs,
10211 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10212 .channel_mode = alc889_8ch_intel_modes,
10213 .capsrc_nids = alc889_capsrc_nids,
10214 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010215 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010216 .init_hook = alc889_intel_init_hook,
10217 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010218 .need_dac_fix = 1,
10219 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010220 [ALC883_6ST_DIG] = {
10221 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10222 .init_verbs = { alc883_init_verbs },
10223 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10224 .dac_nids = alc883_dac_nids,
10225 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010226 .dig_in_nid = ALC883_DIGIN_NID,
10227 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10228 .channel_mode = alc883_sixstack_modes,
10229 .input_mux = &alc883_capture_source,
10230 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010231 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010232 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010233 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10234 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010235 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10236 .dac_nids = alc883_dac_nids,
10237 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010238 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10239 .channel_mode = alc883_3ST_6ch_modes,
10240 .need_dac_fix = 1,
10241 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010242 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010243 .setup = alc882_targa_setup,
10244 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010245 },
10246 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010247 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010248 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10249 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010250 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10251 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010252 .adc_nids = alc883_adc_nids_alt,
10253 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010254 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010255 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010256 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10257 .channel_mode = alc883_3ST_2ch_modes,
10258 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010259 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010260 .setup = alc882_targa_setup,
10261 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010262 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010263 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010264 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10265 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010266 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010267 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010268 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10269 .dac_nids = alc883_dac_nids,
10270 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10271 .adc_nids = alc883_adc_nids_rev,
10272 .capsrc_nids = alc883_capsrc_nids_rev,
10273 .dig_out_nid = ALC883_DIGOUT_NID,
10274 .dig_in_nid = ALC883_DIGIN_NID,
10275 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10276 .channel_mode = alc883_4ST_8ch_modes,
10277 .need_dac_fix = 1,
10278 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010279 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010280 .setup = alc882_targa_setup,
10281 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010282 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010283 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010284 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010285 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10286 * and the headphone jack. Turn this on and rely on the
10287 * standard mute methods whenever the user wants to turn
10288 * these outputs off.
10289 */
10290 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10291 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10292 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010293 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10294 .channel_mode = alc883_3ST_2ch_modes,
10295 .input_mux = &alc883_capture_source,
10296 },
Tobin Davis2880a862007-08-07 11:50:26 +020010297 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010298 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010299 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010300 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10301 .dac_nids = alc883_dac_nids,
10302 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010303 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10304 .channel_mode = alc883_3ST_2ch_modes,
10305 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010306 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010307 .setup = alc883_acer_aspire_setup,
10308 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010309 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010310 [ALC888_ACER_ASPIRE_4930G] = {
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +010010311 .mixers = { alc888_acer_aspire_4930g_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010312 alc883_chmode_mixer },
10313 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10314 alc888_acer_aspire_4930g_verbs },
10315 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10316 .dac_nids = alc883_dac_nids,
10317 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10318 .adc_nids = alc883_adc_nids_rev,
10319 .capsrc_nids = alc883_capsrc_nids_rev,
10320 .dig_out_nid = ALC883_DIGOUT_NID,
10321 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10322 .channel_mode = alc883_3ST_6ch_modes,
10323 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010324 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010325 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010326 ARRAY_SIZE(alc888_2_capture_sources),
10327 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010328 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010329 .setup = alc888_acer_aspire_4930g_setup,
10330 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010331 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010332 [ALC888_ACER_ASPIRE_6530G] = {
10333 .mixers = { alc888_acer_aspire_6530_mixer },
10334 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10335 alc888_acer_aspire_6530g_verbs },
10336 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10337 .dac_nids = alc883_dac_nids,
10338 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10339 .adc_nids = alc883_adc_nids_rev,
10340 .capsrc_nids = alc883_capsrc_nids_rev,
10341 .dig_out_nid = ALC883_DIGOUT_NID,
10342 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10343 .channel_mode = alc883_3ST_2ch_modes,
10344 .num_mux_defs =
10345 ARRAY_SIZE(alc888_2_capture_sources),
10346 .input_mux = alc888_acer_aspire_6530_sources,
10347 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010348 .setup = alc888_acer_aspire_6530g_setup,
10349 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010350 },
Hector Martin3b315d72009-06-02 10:54:19 +020010351 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010352 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010353 alc883_chmode_mixer },
10354 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010355 alc889_acer_aspire_8930g_verbs,
10356 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010357 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10358 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010359 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10360 .adc_nids = alc889_adc_nids,
10361 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010362 .dig_out_nid = ALC883_DIGOUT_NID,
10363 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10364 .channel_mode = alc883_3ST_6ch_modes,
10365 .need_dac_fix = 1,
10366 .const_channel_count = 6,
10367 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010368 ARRAY_SIZE(alc889_capture_sources),
10369 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +020010370 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010371 .setup = alc889_acer_aspire_8930g_setup,
10372 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +010010373#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010374 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010375#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010376 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010377 [ALC888_ACER_ASPIRE_7730G] = {
10378 .mixers = { alc883_3ST_6ch_mixer,
10379 alc883_chmode_mixer },
10380 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10381 alc888_acer_aspire_7730G_verbs },
10382 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10383 .dac_nids = alc883_dac_nids,
10384 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10385 .adc_nids = alc883_adc_nids_rev,
10386 .capsrc_nids = alc883_capsrc_nids_rev,
10387 .dig_out_nid = ALC883_DIGOUT_NID,
10388 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10389 .channel_mode = alc883_3ST_6ch_modes,
10390 .need_dac_fix = 1,
10391 .const_channel_count = 6,
10392 .input_mux = &alc883_capture_source,
10393 .unsol_event = alc_automute_amp_unsol_event,
Denis Kuplyakovd9477202010-11-24 06:01:09 +010010394 .setup = alc888_acer_aspire_7730g_setup,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010395 .init_hook = alc_automute_amp,
10396 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010397 [ALC883_MEDION] = {
10398 .mixers = { alc883_fivestack_mixer,
10399 alc883_chmode_mixer },
10400 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010401 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010402 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10403 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010404 .adc_nids = alc883_adc_nids_alt,
10405 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010406 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010407 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10408 .channel_mode = alc883_sixstack_modes,
10409 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010410 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010411 [ALC883_MEDION_WIM2160] = {
10412 .mixers = { alc883_medion_wim2160_mixer },
10413 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10414 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10415 .dac_nids = alc883_dac_nids,
10416 .dig_out_nid = ALC883_DIGOUT_NID,
10417 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10418 .adc_nids = alc883_adc_nids,
10419 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10420 .channel_mode = alc883_3ST_2ch_modes,
10421 .input_mux = &alc883_capture_source,
10422 .unsol_event = alc_automute_amp_unsol_event,
10423 .setup = alc883_medion_wim2160_setup,
10424 .init_hook = alc_automute_amp,
10425 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010426 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010427 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010428 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10429 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10430 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010431 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10432 .channel_mode = alc883_3ST_2ch_modes,
10433 .input_mux = &alc883_capture_source,
10434 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010435 [ALC883_CLEVO_M540R] = {
10436 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10437 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10438 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10439 .dac_nids = alc883_dac_nids,
10440 .dig_out_nid = ALC883_DIGOUT_NID,
10441 .dig_in_nid = ALC883_DIGIN_NID,
10442 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10443 .channel_mode = alc883_3ST_6ch_clevo_modes,
10444 .need_dac_fix = 1,
10445 .input_mux = &alc883_capture_source,
10446 /* This machine has the hardware HP auto-muting, thus
10447 * we need no software mute via unsol event
10448 */
10449 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010450 [ALC883_CLEVO_M720] = {
10451 .mixers = { alc883_clevo_m720_mixer },
10452 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010453 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10454 .dac_nids = alc883_dac_nids,
10455 .dig_out_nid = ALC883_DIGOUT_NID,
10456 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10457 .channel_mode = alc883_3ST_2ch_modes,
10458 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010459 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010460 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010461 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010462 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010463 [ALC883_LENOVO_101E_2ch] = {
10464 .mixers = { alc883_lenovo_101e_2ch_mixer},
10465 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10466 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10467 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010468 .adc_nids = alc883_adc_nids_alt,
10469 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010470 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010471 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10472 .channel_mode = alc883_3ST_2ch_modes,
10473 .input_mux = &alc883_lenovo_101e_capture_source,
10474 .unsol_event = alc883_lenovo_101e_unsol_event,
10475 .init_hook = alc883_lenovo_101e_all_automute,
10476 },
Kailang Yang272a5272007-05-14 11:00:38 +020010477 [ALC883_LENOVO_NB0763] = {
10478 .mixers = { alc883_lenovo_nb0763_mixer },
10479 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10480 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10481 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010482 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10483 .channel_mode = alc883_3ST_2ch_modes,
10484 .need_dac_fix = 1,
10485 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010486 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwaidc4271702010-11-29 07:42:59 +010010487 .setup = alc883_lenovo_nb0763_setup,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010488 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010489 },
10490 [ALC888_LENOVO_MS7195_DIG] = {
10491 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10492 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10493 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10494 .dac_nids = alc883_dac_nids,
10495 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010496 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10497 .channel_mode = alc883_3ST_6ch_modes,
10498 .need_dac_fix = 1,
10499 .input_mux = &alc883_capture_source,
10500 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10501 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010502 },
10503 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010504 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010505 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10506 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10507 .dac_nids = alc883_dac_nids,
10508 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010509 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10510 .channel_mode = alc883_3ST_2ch_modes,
10511 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010512 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010513 .setup = alc883_haier_w66_setup,
10514 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010515 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010516 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010517 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010518 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010519 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10520 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010521 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10522 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010523 .need_dac_fix = 1,
10524 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010525 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010526 .setup = alc888_3st_hp_setup,
10527 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010528 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010529 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010530 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010531 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10532 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10533 .dac_nids = alc883_dac_nids,
10534 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010535 .dig_in_nid = ALC883_DIGIN_NID,
10536 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10537 .channel_mode = alc883_sixstack_modes,
10538 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010539 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010540 .setup = alc888_6st_dell_setup,
10541 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010542 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010543 [ALC883_MITAC] = {
10544 .mixers = { alc883_mitac_mixer },
10545 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10546 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10547 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010548 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10549 .channel_mode = alc883_3ST_2ch_modes,
10550 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010551 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010552 .setup = alc883_mitac_setup,
10553 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010554 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010555 [ALC883_FUJITSU_PI2515] = {
10556 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10557 .init_verbs = { alc883_init_verbs,
10558 alc883_2ch_fujitsu_pi2515_verbs},
10559 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10560 .dac_nids = alc883_dac_nids,
10561 .dig_out_nid = ALC883_DIGOUT_NID,
10562 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10563 .channel_mode = alc883_3ST_2ch_modes,
10564 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010565 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010566 .setup = alc883_2ch_fujitsu_pi2515_setup,
10567 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010568 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010569 [ALC888_FUJITSU_XA3530] = {
10570 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10571 .init_verbs = { alc883_init_verbs,
10572 alc888_fujitsu_xa3530_verbs },
10573 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10574 .dac_nids = alc883_dac_nids,
10575 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10576 .adc_nids = alc883_adc_nids_rev,
10577 .capsrc_nids = alc883_capsrc_nids_rev,
10578 .dig_out_nid = ALC883_DIGOUT_NID,
10579 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10580 .channel_mode = alc888_4ST_8ch_intel_modes,
10581 .num_mux_defs =
10582 ARRAY_SIZE(alc888_2_capture_sources),
10583 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010584 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010585 .setup = alc888_fujitsu_xa3530_setup,
10586 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010587 },
Kailang Yange2757d52008-08-26 13:17:46 +020010588 [ALC888_LENOVO_SKY] = {
10589 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10590 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10591 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10592 .dac_nids = alc883_dac_nids,
10593 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010594 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10595 .channel_mode = alc883_sixstack_modes,
10596 .need_dac_fix = 1,
10597 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010598 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010599 .setup = alc888_lenovo_sky_setup,
10600 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010601 },
10602 [ALC888_ASUS_M90V] = {
10603 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10604 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10605 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10606 .dac_nids = alc883_dac_nids,
10607 .dig_out_nid = ALC883_DIGOUT_NID,
10608 .dig_in_nid = ALC883_DIGIN_NID,
10609 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10610 .channel_mode = alc883_3ST_6ch_modes,
10611 .need_dac_fix = 1,
10612 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010613 .unsol_event = alc_sku_unsol_event,
10614 .setup = alc883_mode2_setup,
10615 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010616 },
10617 [ALC888_ASUS_EEE1601] = {
10618 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010619 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010620 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10621 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10622 .dac_nids = alc883_dac_nids,
10623 .dig_out_nid = ALC883_DIGOUT_NID,
10624 .dig_in_nid = ALC883_DIGIN_NID,
10625 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10626 .channel_mode = alc883_3ST_2ch_modes,
10627 .need_dac_fix = 1,
10628 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010629 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010630 .init_hook = alc883_eee1601_inithook,
10631 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010632 [ALC1200_ASUS_P5Q] = {
10633 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10634 .init_verbs = { alc883_init_verbs },
10635 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10636 .dac_nids = alc883_dac_nids,
10637 .dig_out_nid = ALC1200_DIGOUT_NID,
10638 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010639 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010640 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10641 .channel_mode = alc883_sixstack_modes,
10642 .input_mux = &alc883_capture_source,
10643 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010644 [ALC889A_MB31] = {
10645 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10646 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10647 alc880_gpio1_init_verbs },
10648 .adc_nids = alc883_adc_nids,
10649 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010650 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010651 .dac_nids = alc883_dac_nids,
10652 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10653 .channel_mode = alc889A_mb31_6ch_modes,
10654 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10655 .input_mux = &alc889A_mb31_capture_source,
10656 .dig_out_nid = ALC883_DIGOUT_NID,
10657 .unsol_event = alc889A_mb31_unsol_event,
10658 .init_hook = alc889A_mb31_automute,
10659 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010660 [ALC883_SONY_VAIO_TT] = {
10661 .mixers = { alc883_vaiott_mixer },
10662 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10663 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10664 .dac_nids = alc883_dac_nids,
10665 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10666 .channel_mode = alc883_3ST_2ch_modes,
10667 .input_mux = &alc883_capture_source,
10668 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010669 .setup = alc883_vaiott_setup,
10670 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010671 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010672};
10673
10674
10675/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010676 * Pin config fixes
10677 */
10678enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010679 PINFIX_ABIT_AW9D_MAX,
10680 PINFIX_PB_M5210,
David Henningssonc3d226a2010-10-14 15:42:08 +020010681 PINFIX_ACER_ASPIRE_7736,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010682};
10683
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010684static const struct alc_fixup alc882_fixups[] = {
10685 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010686 .type = ALC_FIXUP_PINS,
10687 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020010688 { 0x15, 0x01080104 }, /* side */
10689 { 0x16, 0x01011012 }, /* rear */
10690 { 0x17, 0x01016011 }, /* clfe */
10691 { }
10692 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010693 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010694 [PINFIX_PB_M5210] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010695 .type = ALC_FIXUP_VERBS,
10696 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020010697 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10698 {}
10699 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020010700 },
David Henningssonc3d226a2010-10-14 15:42:08 +020010701 [PINFIX_ACER_ASPIRE_7736] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010702 .type = ALC_FIXUP_SKU,
10703 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonc3d226a2010-10-14 15:42:08 +020010704 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010705};
10706
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010707static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010708 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010709 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
David Henningssonc3d226a2010-10-14 15:42:08 +020010710 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010711 {}
10712};
10713
10714/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010715 * BIOS auto configuration
10716 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010717static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10718 const struct auto_pin_cfg *cfg)
10719{
10720 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10721}
10722
Takashi Iwai4953550a2009-06-30 15:28:30 +020010723static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010724 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010725 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010726{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010727 int idx;
10728
Takashi Iwai489008c2010-04-07 09:06:00 +020010729 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010730 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010731
Takashi Iwai489008c2010-04-07 09:06:00 +020010732 if (dac == 0x25)
10733 idx = 4;
10734 else if (dac >= 0x02 && dac <= 0x05)
10735 idx = dac - 2;
10736 else
10737 return;
10738 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010739}
10740
Takashi Iwai4953550a2009-06-30 15:28:30 +020010741static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010742{
10743 struct alc_spec *spec = codec->spec;
10744 int i;
10745
10746 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010747 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010748 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010749 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010750 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010751 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010752 }
10753}
10754
Takashi Iwai4953550a2009-06-30 15:28:30 +020010755static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010756{
10757 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010758 hda_nid_t pin, dac;
Takashi Iwai5855fb82010-09-16 18:24:02 +020010759 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010760
Takashi Iwai5855fb82010-09-16 18:24:02 +020010761 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
10762 pin = spec->autocfg.hp_pins[i];
10763 if (!pin)
10764 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010765 dac = spec->multiout.hp_nid;
10766 if (!dac)
10767 dac = spec->multiout.dac_nids[0]; /* to front */
10768 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10769 }
Takashi Iwai5855fb82010-09-16 18:24:02 +020010770 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
10771 pin = spec->autocfg.speaker_pins[i];
10772 if (!pin)
10773 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010774 dac = spec->multiout.extra_out_nid[0];
10775 if (!dac)
10776 dac = spec->multiout.dac_nids[0]; /* to front */
10777 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10778 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010779}
10780
Takashi Iwai4953550a2009-06-30 15:28:30 +020010781static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010782{
10783 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010784 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010785 int i;
10786
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010787 for (i = 0; i < cfg->num_inputs; i++) {
10788 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai30ea0982010-09-16 18:47:56 +020010789 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010790 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10791 snd_hda_codec_write(codec, nid, 0,
10792 AC_VERB_SET_AMP_GAIN_MUTE,
10793 AMP_OUT_MUTE);
10794 }
10795}
10796
10797static void alc882_auto_init_input_src(struct hda_codec *codec)
10798{
10799 struct alc_spec *spec = codec->spec;
10800 int c;
10801
10802 for (c = 0; c < spec->num_adc_nids; c++) {
10803 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10804 hda_nid_t nid = spec->capsrc_nids[c];
10805 unsigned int mux_idx;
10806 const struct hda_input_mux *imux;
10807 int conns, mute, idx, item;
10808
10809 conns = snd_hda_get_connections(codec, nid, conn_list,
10810 ARRAY_SIZE(conn_list));
10811 if (conns < 0)
10812 continue;
10813 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10814 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010815 if (!imux->num_items && mux_idx > 0)
10816 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010817 for (idx = 0; idx < conns; idx++) {
10818 /* if the current connection is the selected one,
10819 * unmute it as default - otherwise mute it
10820 */
10821 mute = AMP_IN_MUTE(idx);
10822 for (item = 0; item < imux->num_items; item++) {
10823 if (imux->items[item].index == idx) {
10824 if (spec->cur_mux[c] == item)
10825 mute = AMP_IN_UNMUTE(idx);
10826 break;
10827 }
10828 }
10829 /* check if we have a selector or mixer
10830 * we could check for the widget type instead, but
10831 * just check for Amp-In presence (in case of mixer
10832 * without amp-in there is something wrong, this
10833 * function shouldn't be used or capsrc nid is wrong)
10834 */
10835 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010836 snd_hda_codec_write(codec, nid, 0,
10837 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010838 mute);
10839 else if (mute != AMP_IN_MUTE(idx))
10840 snd_hda_codec_write(codec, nid, 0,
10841 AC_VERB_SET_CONNECT_SEL,
10842 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010843 }
10844 }
10845}
10846
Takashi Iwai4953550a2009-06-30 15:28:30 +020010847/* add mic boosts if needed */
10848static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010849{
10850 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010851 struct auto_pin_cfg *cfg = &spec->autocfg;
David Henningsson5322bf22011-01-05 11:03:56 +010010852 int i, err;
Takashi Iwai53e8c322010-12-17 15:23:41 +010010853 int type_idx = 0;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010854 hda_nid_t nid;
David Henningsson5322bf22011-01-05 11:03:56 +010010855 const char *prev_label = NULL;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010856
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010857 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020010858 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010859 break;
10860 nid = cfg->inputs[i].pin;
10861 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
David Henningsson5322bf22011-01-05 11:03:56 +010010862 const char *label;
10863 char boost_label[32];
10864
10865 label = hda_get_autocfg_input_label(codec, cfg, i);
10866 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai53e8c322010-12-17 15:23:41 +010010867 type_idx++;
10868 else
10869 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +010010870 prev_label = label;
10871
10872 snprintf(boost_label, sizeof(boost_label),
10873 "%s Boost Volume", label);
10874 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10875 boost_label, type_idx,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010876 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010877 if (err < 0)
10878 return err;
10879 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010880 }
10881 return 0;
10882}
10883
10884/* almost identical with ALC880 parser... */
10885static int alc882_parse_auto_config(struct hda_codec *codec)
10886{
10887 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010888 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020010889 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010890
Takashi Iwai05f5f472009-08-25 13:10:18 +020010891 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10892 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010893 if (err < 0)
10894 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010895 if (!spec->autocfg.line_outs)
10896 return 0; /* can't find valid BIOS pin config */
10897
10898 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10899 if (err < 0)
10900 return err;
Takashi Iwai569ed342011-01-19 10:14:46 +010010901 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010902 if (err < 0)
10903 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010904 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10905 "Headphone");
10906 if (err < 0)
10907 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010908 err = alc880_auto_create_extra_out(spec,
10909 spec->autocfg.speaker_pins[0],
10910 "Speaker");
10911 if (err < 0)
10912 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010913 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10914 if (err < 0)
10915 return err;
10916
10917 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10918
Takashi Iwai757899a2010-07-30 10:48:14 +020010919 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010920
10921 if (spec->kctls.list)
10922 add_mixer(spec, spec->kctls.list);
10923
10924 add_verb(spec, alc883_auto_init_verbs);
10925 /* if ADC 0x07 is available, initialize it, too */
10926 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10927 add_verb(spec, alc882_adc1_init_verbs);
10928
10929 spec->num_mux_defs = 1;
10930 spec->input_mux = &spec->private_imux[0];
10931
Kailang Yang6227cdc2010-02-25 08:36:52 +010010932 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010933
10934 err = alc_auto_add_mic_boost(codec);
10935 if (err < 0)
10936 return err;
10937
Takashi Iwai776e1842007-08-29 15:07:11 +020010938 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010939}
10940
10941/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010942static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010943{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010944 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010945 alc882_auto_init_multi_out(codec);
10946 alc882_auto_init_hp_out(codec);
10947 alc882_auto_init_analog_input(codec);
10948 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020010949 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010950 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010951 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010952}
10953
Takashi Iwai4953550a2009-06-30 15:28:30 +020010954static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010955{
10956 struct alc_spec *spec;
10957 int err, board_config;
10958
10959 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10960 if (spec == NULL)
10961 return -ENOMEM;
10962
10963 codec->spec = spec;
10964
Takashi Iwai4953550a2009-06-30 15:28:30 +020010965 switch (codec->vendor_id) {
10966 case 0x10ec0882:
10967 case 0x10ec0885:
10968 break;
10969 default:
10970 /* ALC883 and variants */
10971 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10972 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010973 }
10974
Takashi Iwai4953550a2009-06-30 15:28:30 +020010975 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10976 alc882_models,
10977 alc882_cfg_tbl);
10978
10979 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10980 board_config = snd_hda_check_board_codec_sid_config(codec,
10981 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10982
10983 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010984 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010985 codec->chip_name);
10986 board_config = ALC882_AUTO;
10987 }
10988
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010989 if (board_config == ALC882_AUTO) {
10990 alc_pick_fixup(codec, NULL, alc882_fixup_tbl, alc882_fixups);
10991 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
10992 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010993
David Henningsson90622912010-10-14 14:50:18 +020010994 alc_auto_parse_customize_define(codec);
10995
Takashi Iwai4953550a2009-06-30 15:28:30 +020010996 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010997 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010998 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010999 if (err < 0) {
11000 alc_free(codec);
11001 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011002 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011003 printk(KERN_INFO
11004 "hda_codec: Cannot set up configuration "
11005 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020011006 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011007 }
11008 }
11009
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011010 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020011011 err = snd_hda_attach_beep_device(codec, 0x1);
11012 if (err < 0) {
11013 alc_free(codec);
11014 return err;
11015 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011016 }
11017
Takashi Iwai4953550a2009-06-30 15:28:30 +020011018 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011019 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011020
Takashi Iwai4953550a2009-06-30 15:28:30 +020011021 spec->stream_analog_playback = &alc882_pcm_analog_playback;
11022 spec->stream_analog_capture = &alc882_pcm_analog_capture;
11023 /* FIXME: setup DAC5 */
11024 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
11025 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
11026
11027 spec->stream_digital_playback = &alc882_pcm_digital_playback;
11028 spec->stream_digital_capture = &alc882_pcm_digital_capture;
11029
Takashi Iwai4953550a2009-06-30 15:28:30 +020011030 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011031 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011032 spec->num_adc_nids = 0;
11033 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011034 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011035 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011036 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020011037 hda_nid_t nid = alc882_adc_nids[i];
11038 unsigned int wcap = get_wcaps(codec, nid);
11039 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011040 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020011041 if (wcap != AC_WID_AUD_IN)
11042 continue;
11043 spec->private_adc_nids[spec->num_adc_nids] = nid;
11044 err = snd_hda_get_connections(codec, nid, &cap, 1);
11045 if (err < 0)
11046 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011047 err = snd_hda_get_connections(codec, cap, items,
11048 ARRAY_SIZE(items));
11049 if (err < 0)
11050 continue;
11051 for (j = 0; j < imux->num_items; j++)
11052 if (imux->items[j].index >= err)
11053 break;
11054 if (j < imux->num_items)
11055 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011056 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
11057 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011058 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011059 spec->adc_nids = spec->private_adc_nids;
11060 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020011061 }
11062
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011063 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010011064
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011065 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010011066 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011067
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011068 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020011069
Takashi Iwai2134ea42008-01-10 16:53:55 +010011070 spec->vmaster_nid = 0x0c;
11071
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011072 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011073 if (board_config == ALC882_AUTO)
11074 spec->init_hook = alc882_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020011075
11076 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020011077#ifdef CONFIG_SND_HDA_POWER_SAVE
11078 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020011079 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011080#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011081
11082 return 0;
11083}
11084
Takashi Iwai4953550a2009-06-30 15:28:30 +020011085
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011086/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011087 * ALC262 support
11088 */
11089
11090#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
11091#define ALC262_DIGIN_NID ALC880_DIGIN_NID
11092
11093#define alc262_dac_nids alc260_dac_nids
11094#define alc262_adc_nids alc882_adc_nids
11095#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010011096#define alc262_capsrc_nids alc882_capsrc_nids
11097#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010011098
11099#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010011100#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010011101
Kailang Yang4e555fe2008-08-26 13:05:55 +020011102static hda_nid_t alc262_dmic_adc_nids[1] = {
11103 /* ADC0 */
11104 0x09
11105};
11106
11107static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
11108
Kailang Yangdf694da2005-12-05 19:42:22 +010011109static struct snd_kcontrol_new alc262_base_mixer[] = {
11110 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11111 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11112 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11113 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11114 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11115 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11116 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11117 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011118 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011119 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11120 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011121 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011122 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
11123 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11124 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
11125 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011126 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010011127};
11128
Takashi Iwaice875f02008-01-28 18:17:43 +010011129/* update HP, line and mono-out pins according to the master switch */
11130static void alc262_hp_master_update(struct hda_codec *codec)
11131{
11132 struct alc_spec *spec = codec->spec;
11133 int val = spec->master_sw;
11134
11135 /* HP & line-out */
11136 snd_hda_codec_write_cache(codec, 0x1b, 0,
11137 AC_VERB_SET_PIN_WIDGET_CONTROL,
11138 val ? PIN_HP : 0);
11139 snd_hda_codec_write_cache(codec, 0x15, 0,
11140 AC_VERB_SET_PIN_WIDGET_CONTROL,
11141 val ? PIN_HP : 0);
11142 /* mono (speaker) depending on the HP jack sense */
11143 val = val && !spec->jack_present;
11144 snd_hda_codec_write_cache(codec, 0x16, 0,
11145 AC_VERB_SET_PIN_WIDGET_CONTROL,
11146 val ? PIN_OUT : 0);
11147}
11148
11149static void alc262_hp_bpc_automute(struct hda_codec *codec)
11150{
11151 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011152
11153 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010011154 alc262_hp_master_update(codec);
11155}
11156
11157static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
11158{
11159 if ((res >> 26) != ALC880_HP_EVENT)
11160 return;
11161 alc262_hp_bpc_automute(codec);
11162}
11163
11164static void alc262_hp_wildwest_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, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010011169 alc262_hp_master_update(codec);
11170}
11171
11172static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
11173 unsigned int res)
11174{
11175 if ((res >> 26) != ALC880_HP_EVENT)
11176 return;
11177 alc262_hp_wildwest_automute(codec);
11178}
11179
Takashi Iwaib72519b2009-05-08 14:31:55 +020011180#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010011181
11182static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
11183 struct snd_ctl_elem_value *ucontrol)
11184{
11185 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11186 struct alc_spec *spec = codec->spec;
11187 int val = !!*ucontrol->value.integer.value;
11188
11189 if (val == spec->master_sw)
11190 return 0;
11191 spec->master_sw = val;
11192 alc262_hp_master_update(codec);
11193 return 1;
11194}
11195
Takashi Iwaib72519b2009-05-08 14:31:55 +020011196#define ALC262_HP_MASTER_SWITCH \
11197 { \
11198 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11199 .name = "Master Playback Switch", \
11200 .info = snd_ctl_boolean_mono_info, \
11201 .get = alc262_hp_master_sw_get, \
11202 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011203 }, \
11204 { \
11205 .iface = NID_MAPPING, \
11206 .name = "Master Playback Switch", \
11207 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020011208 }
11209
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011210
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011211static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011212 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011213 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11214 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11215 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011216 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11217 HDA_OUTPUT),
11218 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11219 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011220 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11221 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011222 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011223 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11224 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011225 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011226 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11227 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11228 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11229 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011230 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
11231 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
11232 { } /* end */
11233};
11234
Kailang Yangcd7509a2007-01-26 18:33:17 +010011235static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011236 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010011237 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11238 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11239 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11240 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011241 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11242 HDA_OUTPUT),
11243 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11244 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011245 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11246 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011247 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011248 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11249 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11250 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11251 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011252 { } /* end */
11253};
11254
11255static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11256 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11257 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011258 HDA_CODEC_VOLUME("Rear Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011259 { } /* end */
11260};
11261
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011262/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011263static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011264{
11265 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011266
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011267 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011268 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011269}
11270
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011271static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011272 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11273 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011274 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11275 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11276 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11277 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011278 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011279 { } /* end */
11280};
11281
11282static struct hda_verb alc262_hp_t5735_verbs[] = {
11283 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11284 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11285
11286 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11287 { }
11288};
11289
Kailang Yang8c427222008-01-10 13:03:59 +010011290static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011291 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11292 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011293 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11294 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011295 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11296 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11297 { } /* end */
11298};
11299
11300static struct hda_verb alc262_hp_rp5700_verbs[] = {
11301 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11302 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11303 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11304 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11305 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11306 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11307 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11308 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11309 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11310 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11311 {}
11312};
11313
11314static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11315 .num_items = 1,
11316 .items = {
11317 { "Line", 0x1 },
11318 },
11319};
11320
Takashi Iwai42171c12009-05-08 14:11:43 +020011321/* bind hp and internal speaker mute (with plug check) as master switch */
11322static void alc262_hippo_master_update(struct hda_codec *codec)
11323{
11324 struct alc_spec *spec = codec->spec;
11325 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11326 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11327 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11328 unsigned int mute;
11329
11330 /* HP */
11331 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11332 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11333 HDA_AMP_MUTE, mute);
11334 /* mute internal speaker per jack sense */
11335 if (spec->jack_present)
11336 mute = HDA_AMP_MUTE;
11337 if (line_nid)
11338 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11339 HDA_AMP_MUTE, mute);
11340 if (speaker_nid && speaker_nid != line_nid)
11341 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11342 HDA_AMP_MUTE, mute);
11343}
11344
11345#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
11346
11347static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11348 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020011349{
11350 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020011351 struct alc_spec *spec = codec->spec;
11352 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011353
Takashi Iwai42171c12009-05-08 14:11:43 +020011354 if (val == spec->master_sw)
11355 return 0;
11356 spec->master_sw = val;
11357 alc262_hippo_master_update(codec);
11358 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011359}
Takashi Iwai5b319542007-07-26 11:49:22 +020011360
Takashi Iwai42171c12009-05-08 14:11:43 +020011361#define ALC262_HIPPO_MASTER_SWITCH \
11362 { \
11363 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11364 .name = "Master Playback Switch", \
11365 .info = snd_ctl_boolean_mono_info, \
11366 .get = alc262_hippo_master_sw_get, \
11367 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011368 }, \
11369 { \
11370 .iface = NID_MAPPING, \
11371 .name = "Master Playback Switch", \
11372 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11373 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011374 }
11375
11376static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11377 ALC262_HIPPO_MASTER_SWITCH,
11378 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11379 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11380 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11381 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11382 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11383 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11384 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011385 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011386 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11387 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011388 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011389 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11390 { } /* end */
11391};
11392
11393static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11394 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11395 ALC262_HIPPO_MASTER_SWITCH,
11396 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11397 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11398 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11399 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11400 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11401 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011402 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011403 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11404 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011405 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011406 { } /* end */
11407};
11408
11409/* mute/unmute internal speaker according to the hp jack and mute state */
11410static void alc262_hippo_automute(struct hda_codec *codec)
11411{
11412 struct alc_spec *spec = codec->spec;
11413 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020011414
Wu Fengguang864f92b2009-11-18 12:38:02 +080011415 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020011416 alc262_hippo_master_update(codec);
11417}
11418
11419static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11420{
11421 if ((res >> 26) != ALC880_HP_EVENT)
11422 return;
11423 alc262_hippo_automute(codec);
11424}
11425
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011426static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011427{
11428 struct alc_spec *spec = codec->spec;
11429
11430 spec->autocfg.hp_pins[0] = 0x15;
11431 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011432}
11433
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011434static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011435{
11436 struct alc_spec *spec = codec->spec;
11437
11438 spec->autocfg.hp_pins[0] = 0x1b;
11439 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011440}
11441
11442
Kailang Yang272a5272007-05-14 11:00:38 +020011443static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011444 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011445 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011446 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11447 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11448 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11449 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11450 { } /* end */
11451};
11452
Kailang Yang83c34212007-07-05 11:43:05 +020011453static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011454 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11455 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011456 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11457 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11458 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11459 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11460 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11461 { } /* end */
11462};
Kailang Yang272a5272007-05-14 11:00:38 +020011463
Tony Vroonba340e82009-02-02 19:01:30 +000011464static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11465 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11466 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11467 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11468 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11469 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11470 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11471 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11472 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011473 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011474 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11475 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011476 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011477 { } /* end */
11478};
11479
11480static struct hda_verb alc262_tyan_verbs[] = {
11481 /* Headphone automute */
11482 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11483 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11484 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11485
11486 /* P11 AUX_IN, white 4-pin connector */
11487 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11488 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11489 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11490 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11491
11492 {}
11493};
11494
11495/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011496static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011497{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011498 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011499
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011500 spec->autocfg.hp_pins[0] = 0x1b;
11501 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011502}
11503
Tony Vroonba340e82009-02-02 19:01:30 +000011504
Kailang Yangdf694da2005-12-05 19:42:22 +010011505#define alc262_capture_mixer alc882_capture_mixer
11506#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11507
11508/*
11509 * generic initialization of ADC, input mixers and output mixers
11510 */
11511static struct hda_verb alc262_init_verbs[] = {
11512 /*
11513 * Unmute ADC0-2 and set the default input to mic-in
11514 */
11515 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11516 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11517 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11518 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11519 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11520 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11521
Takashi Iwaicb53c622007-08-10 17:21:45 +020011522 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011523 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011524 * Note: PASD motherboards uses the Line In 2 as the input for
11525 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011526 */
11527 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011528 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11529 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11530 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11531 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11532 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011533
11534 /*
11535 * Set up output mixers (0x0c - 0x0e)
11536 */
11537 /* set vol=0 to output mixers */
11538 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11539 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11540 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11541 /* set up input amps for analog loopback */
11542 /* Amp Indices: DAC = 0, mixer = 1 */
11543 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11544 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11545 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11546 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11547 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11548 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11549
11550 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11551 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11552 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11553 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11554 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11555 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11556
11557 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11558 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11559 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11560 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11561 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011562
Kailang Yangdf694da2005-12-05 19:42:22 +010011563 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11564 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011565
Kailang Yangdf694da2005-12-05 19:42:22 +010011566 /* FIXME: use matrix-type input source selection */
11567 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11568 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11569 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11570 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11571 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11572 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11573 /* Input mixer2 */
11574 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11575 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11576 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11577 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11578 /* Input mixer3 */
11579 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11580 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11581 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011582 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011583
11584 { }
11585};
11586
Kailang Yang4e555fe2008-08-26 13:05:55 +020011587static struct hda_verb alc262_eapd_verbs[] = {
11588 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11589 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11590 { }
11591};
11592
Kailang Yangccc656c2006-10-17 12:32:26 +020011593static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11594 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11595 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11596 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11597
11598 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11599 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11600 {}
11601};
11602
Kailang Yang272a5272007-05-14 11:00:38 +020011603static struct hda_verb alc262_sony_unsol_verbs[] = {
11604 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11605 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11606 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11607
11608 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11609 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011610 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011611};
11612
Kailang Yang4e555fe2008-08-26 13:05:55 +020011613static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11614 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11615 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11616 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11617 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11618 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011619 { } /* end */
11620};
11621
11622static struct hda_verb alc262_toshiba_s06_verbs[] = {
11623 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11624 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11625 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11626 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11627 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11628 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11629 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11630 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11631 {}
11632};
11633
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011634static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011635{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011636 struct alc_spec *spec = codec->spec;
11637
11638 spec->autocfg.hp_pins[0] = 0x15;
11639 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011640 spec->ext_mic.pin = 0x18;
11641 spec->ext_mic.mux_idx = 0;
11642 spec->int_mic.pin = 0x12;
11643 spec->int_mic.mux_idx = 9;
11644 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011645}
11646
Takashi Iwai834be882006-03-01 14:16:17 +010011647/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011648 * nec model
11649 * 0x15 = headphone
11650 * 0x16 = internal speaker
11651 * 0x18 = external mic
11652 */
11653
11654static struct snd_kcontrol_new alc262_nec_mixer[] = {
11655 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11656 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11657
11658 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11659 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011660 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011661
11662 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11663 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11664 { } /* end */
11665};
11666
11667static struct hda_verb alc262_nec_verbs[] = {
11668 /* Unmute Speaker */
11669 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11670
11671 /* Headphone */
11672 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11673 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11674
11675 /* External mic to headphone */
11676 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11677 /* External mic to speaker */
11678 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11679 {}
11680};
11681
11682/*
Takashi Iwai834be882006-03-01 14:16:17 +010011683 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011684 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11685 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011686 */
11687
11688#define ALC_HP_EVENT 0x37
11689
11690static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11691 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11692 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011693 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11694 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011695 {}
11696};
11697
Jiang zhe0e31daf2008-03-20 12:12:39 +010011698static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11699 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11700 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11701 {}
11702};
11703
Daniel T Chene2595322009-12-19 18:19:02 -050011704static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11705 /* Front Mic pin: input vref at 50% */
11706 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11707 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11708 {}
11709};
11710
Takashi Iwai834be882006-03-01 14:16:17 +010011711static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011712 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011713 .items = {
11714 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010011715 { "Internal Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011716 { "CD", 0x4 },
11717 },
11718};
11719
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011720static struct hda_input_mux alc262_HP_capture_source = {
11721 .num_items = 5,
11722 .items = {
11723 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011724 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011725 { "Line", 0x2 },
11726 { "CD", 0x4 },
11727 { "AUX IN", 0x6 },
11728 },
11729};
11730
zhejiangaccbe492007-08-31 12:36:05 +020011731static struct hda_input_mux alc262_HP_D7000_capture_source = {
11732 .num_items = 4,
11733 .items = {
11734 { "Mic", 0x0 },
11735 { "Front Mic", 0x2 },
11736 { "Line", 0x1 },
11737 { "CD", 0x4 },
11738 },
11739};
11740
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011741/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011742static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11743{
11744 struct alc_spec *spec = codec->spec;
11745 unsigned int mute;
11746
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011747 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011748 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11749 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011750 spec->sense_updated = 1;
11751 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011752 /* unmute internal speaker only if both HPs are unplugged and
11753 * master switch is on
11754 */
11755 if (spec->jack_present)
11756 mute = HDA_AMP_MUTE;
11757 else
Takashi Iwai834be882006-03-01 14:16:17 +010011758 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011759 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11760 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011761}
11762
11763/* unsolicited event for HP jack sensing */
11764static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11765 unsigned int res)
11766{
11767 if ((res >> 26) != ALC_HP_EVENT)
11768 return;
11769 alc262_fujitsu_automute(codec, 1);
11770}
11771
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011772static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11773{
11774 alc262_fujitsu_automute(codec, 1);
11775}
11776
Takashi Iwai834be882006-03-01 14:16:17 +010011777/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011778static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11779 .ops = &snd_hda_bind_vol,
11780 .values = {
11781 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11782 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11783 0
11784 },
11785};
Takashi Iwai834be882006-03-01 14:16:17 +010011786
Jiang zhe0e31daf2008-03-20 12:12:39 +010011787/* mute/unmute internal speaker according to the hp jack and mute state */
11788static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11789{
11790 struct alc_spec *spec = codec->spec;
11791 unsigned int mute;
11792
11793 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011794 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011795 spec->sense_updated = 1;
11796 }
11797 if (spec->jack_present) {
11798 /* mute internal speaker */
11799 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11800 HDA_AMP_MUTE, HDA_AMP_MUTE);
11801 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11802 HDA_AMP_MUTE, HDA_AMP_MUTE);
11803 } else {
11804 /* unmute internal speaker if necessary */
11805 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11806 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11807 HDA_AMP_MUTE, mute);
11808 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11809 HDA_AMP_MUTE, mute);
11810 }
11811}
11812
11813/* unsolicited event for HP jack sensing */
11814static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11815 unsigned int res)
11816{
11817 if ((res >> 26) != ALC_HP_EVENT)
11818 return;
11819 alc262_lenovo_3000_automute(codec, 1);
11820}
11821
Takashi Iwai8de56b72009-07-24 16:51:47 +020011822static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11823 int dir, int idx, long *valp)
11824{
11825 int i, change = 0;
11826
11827 for (i = 0; i < 2; i++, valp++)
11828 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11829 HDA_AMP_MUTE,
11830 *valp ? 0 : HDA_AMP_MUTE);
11831 return change;
11832}
11833
Takashi Iwai834be882006-03-01 14:16:17 +010011834/* bind hp and internal speaker mute (with plug check) */
11835static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11836 struct snd_ctl_elem_value *ucontrol)
11837{
11838 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11839 long *valp = ucontrol->value.integer.value;
11840 int change;
11841
Takashi Iwai8de56b72009-07-24 16:51:47 +020011842 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11843 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011844 if (change)
11845 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011846 return change;
11847}
11848
11849static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011850 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011851 {
11852 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11853 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011854 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011855 .info = snd_hda_mixer_amp_switch_info,
11856 .get = snd_hda_mixer_amp_switch_get,
11857 .put = alc262_fujitsu_master_sw_put,
11858 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11859 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011860 {
11861 .iface = NID_MAPPING,
11862 .name = "Master Playback Switch",
11863 .private_value = 0x1b,
11864 },
Takashi Iwai834be882006-03-01 14:16:17 +010011865 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11866 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011867 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011868 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11869 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011870 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010011871 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11872 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011873 { } /* end */
11874};
11875
Jiang zhe0e31daf2008-03-20 12:12:39 +010011876/* bind hp and internal speaker mute (with plug check) */
11877static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11878 struct snd_ctl_elem_value *ucontrol)
11879{
11880 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11881 long *valp = ucontrol->value.integer.value;
11882 int change;
11883
Takashi Iwai8de56b72009-07-24 16:51:47 +020011884 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011885 if (change)
11886 alc262_lenovo_3000_automute(codec, 0);
11887 return change;
11888}
11889
11890static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11891 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11892 {
11893 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11894 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011895 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011896 .info = snd_hda_mixer_amp_switch_info,
11897 .get = snd_hda_mixer_amp_switch_get,
11898 .put = alc262_lenovo_3000_master_sw_put,
11899 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11900 },
11901 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11902 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011903 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011904 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11905 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011906 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010011907 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11908 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011909 { } /* end */
11910};
11911
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011912static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11913 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011914 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011915 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11916 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011917 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011918 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11919 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011920 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011921 { } /* end */
11922};
11923
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011924/* additional init verbs for Benq laptops */
11925static struct hda_verb alc262_EAPD_verbs[] = {
11926 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11927 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11928 {}
11929};
11930
Kailang Yang83c34212007-07-05 11:43:05 +020011931static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11932 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11933 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11934
11935 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11936 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11937 {}
11938};
11939
Tobin Davisf651b502007-10-26 12:40:47 +020011940/* Samsung Q1 Ultra Vista model setup */
11941static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011942 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11943 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011944 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11945 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011946 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
11947 HDA_CODEC_VOLUME("Headphone Mic Boost Volume", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011948 { } /* end */
11949};
11950
11951static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011952 /* output mixer */
11953 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11954 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11955 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11956 /* speaker */
11957 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11958 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11959 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11960 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11961 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011962 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011963 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11964 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11965 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11966 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11967 /* internal mic */
11968 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11969 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11970 /* ADC, choose mic */
11971 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11972 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11973 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11974 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11975 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11976 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11977 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11978 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11979 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11980 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011981 {}
11982};
11983
Tobin Davisf651b502007-10-26 12:40:47 +020011984/* mute/unmute internal speaker according to the hp jack and mute state */
11985static void alc262_ultra_automute(struct hda_codec *codec)
11986{
11987 struct alc_spec *spec = codec->spec;
11988 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011989
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011990 mute = 0;
11991 /* auto-mute only when HP is used as HP */
11992 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011993 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011994 if (spec->jack_present)
11995 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011996 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011997 /* mute/unmute internal speaker */
11998 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11999 HDA_AMP_MUTE, mute);
12000 /* mute/unmute HP */
12001 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12002 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020012003}
12004
12005/* unsolicited event for HP jack sensing */
12006static void alc262_ultra_unsol_event(struct hda_codec *codec,
12007 unsigned int res)
12008{
12009 if ((res >> 26) != ALC880_HP_EVENT)
12010 return;
12011 alc262_ultra_automute(codec);
12012}
12013
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012014static struct hda_input_mux alc262_ultra_capture_source = {
12015 .num_items = 2,
12016 .items = {
12017 { "Mic", 0x1 },
12018 { "Headphone", 0x7 },
12019 },
12020};
12021
12022static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
12023 struct snd_ctl_elem_value *ucontrol)
12024{
12025 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12026 struct alc_spec *spec = codec->spec;
12027 int ret;
12028
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012029 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012030 if (!ret)
12031 return 0;
12032 /* reprogram the HP pin as mic or HP according to the input source */
12033 snd_hda_codec_write_cache(codec, 0x15, 0,
12034 AC_VERB_SET_PIN_WIDGET_CONTROL,
12035 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
12036 alc262_ultra_automute(codec); /* mute/unmute HP */
12037 return ret;
12038}
12039
12040static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
12041 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
12042 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
12043 {
12044 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12045 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012046 .info = alc_mux_enum_info,
12047 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012048 .put = alc262_ultra_mux_enum_put,
12049 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010012050 {
12051 .iface = NID_MAPPING,
12052 .name = "Capture Source",
12053 .private_value = 0x15,
12054 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012055 { } /* end */
12056};
12057
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012058/* We use two mixers depending on the output pin; 0x16 is a mono output
12059 * and thus it's bound with a different mixer.
12060 * This function returns which mixer amp should be used.
12061 */
12062static int alc262_check_volbit(hda_nid_t nid)
12063{
12064 if (!nid)
12065 return 0;
12066 else if (nid == 0x16)
12067 return 2;
12068 else
12069 return 1;
12070}
12071
12072static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012073 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012074{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012075 unsigned long val;
12076 int vbit;
12077
12078 vbit = alc262_check_volbit(nid);
12079 if (!vbit)
12080 return 0;
12081 if (*vbits & vbit) /* a volume control for this mixer already there */
12082 return 0;
12083 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012084 if (vbit == 2)
12085 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
12086 else
12087 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012088 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012089}
12090
12091static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012092 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012093{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012094 unsigned long val;
12095
12096 if (!nid)
12097 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012098 if (nid == 0x16)
12099 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
12100 else
12101 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012102 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012103}
12104
Kailang Yangdf694da2005-12-05 19:42:22 +010012105/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012106static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
12107 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012108{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012109 const char *pfx;
12110 int vbits;
Takashi Iwai033688a2010-09-08 15:47:09 +020012111 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010012112
12113 spec->multiout.num_dacs = 1; /* only use one dac */
12114 spec->multiout.dac_nids = spec->private_dac_nids;
12115 spec->multiout.dac_nids[0] = 2;
12116
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010012117 pfx = alc_get_line_out_pfx(cfg, true);
12118 if (!pfx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012119 pfx = "Front";
Takashi Iwai033688a2010-09-08 15:47:09 +020012120 for (i = 0; i < 2; i++) {
12121 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
12122 if (err < 0)
12123 return err;
12124 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12125 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
12126 "Speaker", i);
12127 if (err < 0)
12128 return err;
12129 }
12130 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12131 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
12132 "Headphone", i);
12133 if (err < 0)
12134 return err;
12135 }
12136 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012137
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012138 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
12139 alc262_check_volbit(cfg->speaker_pins[0]) |
12140 alc262_check_volbit(cfg->hp_pins[0]);
12141 if (vbits == 1 || vbits == 2)
12142 pfx = "Master"; /* only one mixer is used */
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012143 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020012144 for (i = 0; i < 2; i++) {
12145 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
12146 &vbits, i);
12147 if (err < 0)
12148 return err;
12149 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12150 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
12151 "Speaker", &vbits, i);
12152 if (err < 0)
12153 return err;
12154 }
12155 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12156 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
12157 "Headphone", &vbits, i);
12158 if (err < 0)
12159 return err;
12160 }
12161 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012162 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010012163}
12164
Takashi Iwai05f5f472009-08-25 13:10:18 +020012165#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010012166 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010012167
12168/*
12169 * generic initialization of ADC, input mixers and output mixers
12170 */
12171static struct hda_verb alc262_volume_init_verbs[] = {
12172 /*
12173 * Unmute ADC0-2 and set the default input to mic-in
12174 */
12175 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12176 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12177 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12178 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12179 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12180 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12181
Takashi Iwaicb53c622007-08-10 17:21:45 +020012182 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010012183 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012184 * Note: PASD motherboards uses the Line In 2 as the input for
12185 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010012186 */
12187 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012188 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12189 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12190 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12191 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12192 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012193
12194 /*
12195 * Set up output mixers (0x0c - 0x0f)
12196 */
12197 /* set vol=0 to output mixers */
12198 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12199 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12200 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020012201
Kailang Yangdf694da2005-12-05 19:42:22 +010012202 /* set up input amps for analog loopback */
12203 /* Amp Indices: DAC = 0, mixer = 1 */
12204 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12205 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12206 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12207 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12208 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12209 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12210
12211 /* FIXME: use matrix-type input source selection */
12212 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12213 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12214 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12215 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12216 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12217 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12218 /* Input mixer2 */
12219 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12220 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12221 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12222 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12223 /* Input mixer3 */
12224 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12225 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12226 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12227 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12228
12229 { }
12230};
12231
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012232static struct hda_verb alc262_HP_BPC_init_verbs[] = {
12233 /*
12234 * Unmute ADC0-2 and set the default input to mic-in
12235 */
12236 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12237 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12238 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12239 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12240 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12241 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12242
Takashi Iwaicb53c622007-08-10 17:21:45 +020012243 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012244 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012245 * Note: PASD motherboards uses the Line In 2 as the input for
12246 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012247 */
12248 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012249 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12250 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12251 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12252 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12253 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12254 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12255 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012256
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012257 /*
12258 * Set up output mixers (0x0c - 0x0e)
12259 */
12260 /* set vol=0 to output mixers */
12261 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12262 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12263 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12264
12265 /* set up input amps for analog loopback */
12266 /* Amp Indices: DAC = 0, mixer = 1 */
12267 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12268 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12269 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12270 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12271 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12272 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12273
Takashi Iwaice875f02008-01-28 18:17:43 +010012274 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012275 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12276 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12277
12278 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12279 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12280
12281 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12282 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12283
12284 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12285 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12286 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12287 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12288 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12289
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012290 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012291 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12292 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012293 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012294 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12295 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12296
12297
12298 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012299 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12300 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012301 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012302 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12303 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12304 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12305 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12306 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12307 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12308 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12309 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012310 /* Input mixer2 */
12311 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012312 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12313 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12314 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12315 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12316 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12317 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12318 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12319 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012320 /* Input mixer3 */
12321 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012322 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12323 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12324 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12325 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12326 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12327 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12328 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12329 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012330
Takashi Iwaice875f02008-01-28 18:17:43 +010012331 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12332
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012333 { }
12334};
12335
Kailang Yangcd7509a2007-01-26 18:33:17 +010012336static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12337 /*
12338 * Unmute ADC0-2 and set the default input to mic-in
12339 */
12340 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12341 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12342 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12343 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12344 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12345 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12346
Takashi Iwaicb53c622007-08-10 17:21:45 +020012347 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012348 * mixer widget
12349 * Note: PASD motherboards uses the Line In 2 as the input for front
12350 * panel mic (mic 2)
12351 */
12352 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012353 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12354 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12355 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12356 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12357 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12358 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12359 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12360 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012361 /*
12362 * Set up output mixers (0x0c - 0x0e)
12363 */
12364 /* set vol=0 to output mixers */
12365 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12366 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12367 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12368
12369 /* set up input amps for analog loopback */
12370 /* Amp Indices: DAC = 0, mixer = 1 */
12371 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12372 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12373 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12374 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12375 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12376 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12377
12378
12379 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12380 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12381 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12382 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12383 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12384 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12385 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12386
12387 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12388 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12389
12390 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12391 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12392
12393 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12394 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12395 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12396 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12397 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12398 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12399
12400 /* FIXME: use matrix-type input source selection */
12401 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12402 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12403 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12404 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12405 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12406 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12407 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12408 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12409 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12410 /* Input mixer2 */
12411 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12412 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12413 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12414 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12415 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12416 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12417 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12418 /* Input mixer3 */
12419 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12420 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12421 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12422 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12423 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12424 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12425 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12426
Takashi Iwaice875f02008-01-28 18:17:43 +010012427 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12428
Kailang Yangcd7509a2007-01-26 18:33:17 +010012429 { }
12430};
12431
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012432static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12433
12434 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12435 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12436 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12437
12438 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12439 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12440 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12441 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12442
12443 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12444 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12445 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12446 {}
12447};
12448
Takashi Iwai18675e42010-09-08 15:55:44 +020012449/*
12450 * Pin config fixes
12451 */
12452enum {
12453 PINFIX_FSC_H270,
12454};
12455
12456static const struct alc_fixup alc262_fixups[] = {
12457 [PINFIX_FSC_H270] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012458 .type = ALC_FIXUP_PINS,
12459 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai18675e42010-09-08 15:55:44 +020012460 { 0x14, 0x99130110 }, /* speaker */
12461 { 0x15, 0x0221142f }, /* front HP */
12462 { 0x1b, 0x0121141f }, /* rear HP */
12463 { }
12464 }
12465 },
Takashi Iwai18675e42010-09-08 15:55:44 +020012466};
12467
12468static struct snd_pci_quirk alc262_fixup_tbl[] = {
12469 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12470 {}
12471};
12472
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012473
Takashi Iwaicb53c622007-08-10 17:21:45 +020012474#ifdef CONFIG_SND_HDA_POWER_SAVE
12475#define alc262_loopbacks alc880_loopbacks
12476#endif
12477
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012478/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012479#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12480#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12481#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12482#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12483
12484/*
12485 * BIOS auto configuration
12486 */
12487static int alc262_parse_auto_config(struct hda_codec *codec)
12488{
12489 struct alc_spec *spec = codec->spec;
12490 int err;
12491 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12492
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012493 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12494 alc262_ignore);
12495 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012496 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012497 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012498 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012499 spec->multiout.max_channels = 2;
12500 spec->no_analog = 1;
12501 goto dig_only;
12502 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012503 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012504 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012505 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12506 if (err < 0)
12507 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012508 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012509 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012510 return err;
12511
12512 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12513
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012514 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012515 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012516
Takashi Iwai603c4012008-07-30 15:01:44 +020012517 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012518 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012519
Takashi Iwaid88897e2008-10-31 15:01:37 +010012520 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012521 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012522 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012523
Takashi Iwai776e1842007-08-29 15:07:11 +020012524 err = alc_auto_add_mic_boost(codec);
12525 if (err < 0)
12526 return err;
12527
Kailang Yang6227cdc2010-02-25 08:36:52 +010012528 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012529
Kailang Yangdf694da2005-12-05 19:42:22 +010012530 return 1;
12531}
12532
12533#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12534#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12535#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012536#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012537
12538
12539/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012540static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012541{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012542 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012543 alc262_auto_init_multi_out(codec);
12544 alc262_auto_init_hp_out(codec);
12545 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012546 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012547 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012548 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012549 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012550}
12551
12552/*
12553 * configuration and preset
12554 */
Takashi Iwaiea734962011-01-17 11:29:34 +010012555static const char * const alc262_models[ALC262_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012556 [ALC262_BASIC] = "basic",
12557 [ALC262_HIPPO] = "hippo",
12558 [ALC262_HIPPO_1] = "hippo_1",
12559 [ALC262_FUJITSU] = "fujitsu",
12560 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012561 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012562 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012563 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012564 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012565 [ALC262_BENQ_T31] = "benq-t31",
12566 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012567 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012568 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012569 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012570 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012571 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012572 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012573 [ALC262_AUTO] = "auto",
12574};
12575
12576static struct snd_pci_quirk alc262_cfg_tbl[] = {
12577 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012578 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012579 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12580 ALC262_HP_BPC),
12581 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12582 ALC262_HP_BPC),
Takashi Iwai5734a072011-01-19 17:07:12 +010012583 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1500, "HP z series",
12584 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012585 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12586 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012587 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012588 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012589 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012590 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012591 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012592 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012593 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012594 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012595 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12596 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12597 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012598 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12599 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012600 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012601 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012602 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012603 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012604 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012605 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012606 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012607 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012608#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012609 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12610 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012611#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012612 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012613 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012614 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012615 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012616 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012617 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012618 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12619 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012620 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012621 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012622 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012623 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012624 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012625 {}
12626};
12627
12628static struct alc_config_preset alc262_presets[] = {
12629 [ALC262_BASIC] = {
12630 .mixers = { alc262_base_mixer },
12631 .init_verbs = { alc262_init_verbs },
12632 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12633 .dac_nids = alc262_dac_nids,
12634 .hp_nid = 0x03,
12635 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12636 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012637 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012638 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012639 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012640 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012641 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012642 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12643 .dac_nids = alc262_dac_nids,
12644 .hp_nid = 0x03,
12645 .dig_out_nid = ALC262_DIGOUT_NID,
12646 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12647 .channel_mode = alc262_modes,
12648 .input_mux = &alc262_capture_source,
12649 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012650 .setup = alc262_hippo_setup,
12651 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012652 },
12653 [ALC262_HIPPO_1] = {
12654 .mixers = { alc262_hippo1_mixer },
12655 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12656 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12657 .dac_nids = alc262_dac_nids,
12658 .hp_nid = 0x02,
12659 .dig_out_nid = ALC262_DIGOUT_NID,
12660 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12661 .channel_mode = alc262_modes,
12662 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012663 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012664 .setup = alc262_hippo1_setup,
12665 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012666 },
Takashi Iwai834be882006-03-01 14:16:17 +010012667 [ALC262_FUJITSU] = {
12668 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012669 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12670 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012671 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12672 .dac_nids = alc262_dac_nids,
12673 .hp_nid = 0x03,
12674 .dig_out_nid = ALC262_DIGOUT_NID,
12675 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12676 .channel_mode = alc262_modes,
12677 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012678 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012679 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012680 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012681 [ALC262_HP_BPC] = {
12682 .mixers = { alc262_HP_BPC_mixer },
12683 .init_verbs = { alc262_HP_BPC_init_verbs },
12684 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12685 .dac_nids = alc262_dac_nids,
12686 .hp_nid = 0x03,
12687 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12688 .channel_mode = alc262_modes,
12689 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012690 .unsol_event = alc262_hp_bpc_unsol_event,
12691 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012692 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012693 [ALC262_HP_BPC_D7000_WF] = {
12694 .mixers = { alc262_HP_BPC_WildWest_mixer },
12695 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12696 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12697 .dac_nids = alc262_dac_nids,
12698 .hp_nid = 0x03,
12699 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12700 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012701 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012702 .unsol_event = alc262_hp_wildwest_unsol_event,
12703 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012704 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012705 [ALC262_HP_BPC_D7000_WL] = {
12706 .mixers = { alc262_HP_BPC_WildWest_mixer,
12707 alc262_HP_BPC_WildWest_option_mixer },
12708 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12709 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12710 .dac_nids = alc262_dac_nids,
12711 .hp_nid = 0x03,
12712 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12713 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012714 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012715 .unsol_event = alc262_hp_wildwest_unsol_event,
12716 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012717 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012718 [ALC262_HP_TC_T5735] = {
12719 .mixers = { alc262_hp_t5735_mixer },
12720 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12721 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12722 .dac_nids = alc262_dac_nids,
12723 .hp_nid = 0x03,
12724 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12725 .channel_mode = alc262_modes,
12726 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012727 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012728 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012729 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012730 },
12731 [ALC262_HP_RP5700] = {
12732 .mixers = { alc262_hp_rp5700_mixer },
12733 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12734 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12735 .dac_nids = alc262_dac_nids,
12736 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12737 .channel_mode = alc262_modes,
12738 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012739 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012740 [ALC262_BENQ_ED8] = {
12741 .mixers = { alc262_base_mixer },
12742 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12743 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12744 .dac_nids = alc262_dac_nids,
12745 .hp_nid = 0x03,
12746 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12747 .channel_mode = alc262_modes,
12748 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012749 },
Kailang Yang272a5272007-05-14 11:00:38 +020012750 [ALC262_SONY_ASSAMD] = {
12751 .mixers = { alc262_sony_mixer },
12752 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12753 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12754 .dac_nids = alc262_dac_nids,
12755 .hp_nid = 0x02,
12756 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12757 .channel_mode = alc262_modes,
12758 .input_mux = &alc262_capture_source,
12759 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012760 .setup = alc262_hippo_setup,
12761 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012762 },
12763 [ALC262_BENQ_T31] = {
12764 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012765 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12766 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012767 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12768 .dac_nids = alc262_dac_nids,
12769 .hp_nid = 0x03,
12770 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12771 .channel_mode = alc262_modes,
12772 .input_mux = &alc262_capture_source,
12773 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012774 .setup = alc262_hippo_setup,
12775 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012776 },
Tobin Davisf651b502007-10-26 12:40:47 +020012777 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012778 .mixers = { alc262_ultra_mixer },
12779 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012780 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012781 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12782 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012783 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12784 .channel_mode = alc262_modes,
12785 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012786 .adc_nids = alc262_adc_nids, /* ADC0 */
12787 .capsrc_nids = alc262_capsrc_nids,
12788 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012789 .unsol_event = alc262_ultra_unsol_event,
12790 .init_hook = alc262_ultra_automute,
12791 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012792 [ALC262_LENOVO_3000] = {
12793 .mixers = { alc262_lenovo_3000_mixer },
12794 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012795 alc262_lenovo_3000_unsol_verbs,
12796 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012797 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12798 .dac_nids = alc262_dac_nids,
12799 .hp_nid = 0x03,
12800 .dig_out_nid = ALC262_DIGOUT_NID,
12801 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12802 .channel_mode = alc262_modes,
12803 .input_mux = &alc262_fujitsu_capture_source,
12804 .unsol_event = alc262_lenovo_3000_unsol_event,
12805 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012806 [ALC262_NEC] = {
12807 .mixers = { alc262_nec_mixer },
12808 .init_verbs = { alc262_nec_verbs },
12809 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12810 .dac_nids = alc262_dac_nids,
12811 .hp_nid = 0x03,
12812 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12813 .channel_mode = alc262_modes,
12814 .input_mux = &alc262_capture_source,
12815 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012816 [ALC262_TOSHIBA_S06] = {
12817 .mixers = { alc262_toshiba_s06_mixer },
12818 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12819 alc262_eapd_verbs },
12820 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12821 .capsrc_nids = alc262_dmic_capsrc_nids,
12822 .dac_nids = alc262_dac_nids,
12823 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012824 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012825 .dig_out_nid = ALC262_DIGOUT_NID,
12826 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12827 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012828 .unsol_event = alc_sku_unsol_event,
12829 .setup = alc262_toshiba_s06_setup,
12830 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012831 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012832 [ALC262_TOSHIBA_RX1] = {
12833 .mixers = { alc262_toshiba_rx1_mixer },
12834 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12835 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12836 .dac_nids = alc262_dac_nids,
12837 .hp_nid = 0x03,
12838 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12839 .channel_mode = alc262_modes,
12840 .input_mux = &alc262_capture_source,
12841 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012842 .setup = alc262_hippo_setup,
12843 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012844 },
Tony Vroonba340e82009-02-02 19:01:30 +000012845 [ALC262_TYAN] = {
12846 .mixers = { alc262_tyan_mixer },
12847 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12848 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12849 .dac_nids = alc262_dac_nids,
12850 .hp_nid = 0x02,
12851 .dig_out_nid = ALC262_DIGOUT_NID,
12852 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12853 .channel_mode = alc262_modes,
12854 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012855 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012856 .setup = alc262_tyan_setup,
12857 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012858 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012859};
12860
12861static int patch_alc262(struct hda_codec *codec)
12862{
12863 struct alc_spec *spec;
12864 int board_config;
12865 int err;
12866
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012867 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012868 if (spec == NULL)
12869 return -ENOMEM;
12870
12871 codec->spec = spec;
12872#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012873 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12874 * under-run
12875 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012876 {
12877 int tmp;
12878 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12879 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12880 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12881 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12882 }
12883#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012884 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012885
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012886 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12887
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012888 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12889 alc262_models,
12890 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012891
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012892 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012893 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12894 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012895 board_config = ALC262_AUTO;
12896 }
12897
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012898 if (board_config == ALC262_AUTO) {
12899 alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups);
12900 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
12901 }
Takashi Iwai18675e42010-09-08 15:55:44 +020012902
Kailang Yangdf694da2005-12-05 19:42:22 +010012903 if (board_config == ALC262_AUTO) {
12904 /* automatic parse from the BIOS config */
12905 err = alc262_parse_auto_config(codec);
12906 if (err < 0) {
12907 alc_free(codec);
12908 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012909 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012910 printk(KERN_INFO
12911 "hda_codec: Cannot set up configuration "
12912 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012913 board_config = ALC262_BASIC;
12914 }
12915 }
12916
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012917 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012918 err = snd_hda_attach_beep_device(codec, 0x1);
12919 if (err < 0) {
12920 alc_free(codec);
12921 return err;
12922 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012923 }
12924
Kailang Yangdf694da2005-12-05 19:42:22 +010012925 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012926 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012927
Kailang Yangdf694da2005-12-05 19:42:22 +010012928 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12929 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012930
Kailang Yangdf694da2005-12-05 19:42:22 +010012931 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12932 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12933
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012934 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012935 int i;
12936 /* check whether the digital-mic has to be supported */
12937 for (i = 0; i < spec->input_mux->num_items; i++) {
12938 if (spec->input_mux->items[i].index >= 9)
12939 break;
12940 }
12941 if (i < spec->input_mux->num_items) {
12942 /* use only ADC0 */
12943 spec->adc_nids = alc262_dmic_adc_nids;
12944 spec->num_adc_nids = 1;
12945 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012946 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012947 /* all analog inputs */
12948 /* check whether NID 0x07 is valid */
12949 unsigned int wcap = get_wcaps(codec, 0x07);
12950
12951 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012952 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012953 if (wcap != AC_WID_AUD_IN) {
12954 spec->adc_nids = alc262_adc_nids_alt;
12955 spec->num_adc_nids =
12956 ARRAY_SIZE(alc262_adc_nids_alt);
12957 spec->capsrc_nids = alc262_capsrc_nids_alt;
12958 } else {
12959 spec->adc_nids = alc262_adc_nids;
12960 spec->num_adc_nids =
12961 ARRAY_SIZE(alc262_adc_nids);
12962 spec->capsrc_nids = alc262_capsrc_nids;
12963 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012964 }
12965 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012966 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012967 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012968 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010012969 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012970
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012971 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai18675e42010-09-08 15:55:44 +020012972
Takashi Iwai2134ea42008-01-10 16:53:55 +010012973 spec->vmaster_nid = 0x0c;
12974
Kailang Yangdf694da2005-12-05 19:42:22 +010012975 codec->patch_ops = alc_patch_ops;
12976 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012977 spec->init_hook = alc262_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020012978
12979 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020012980#ifdef CONFIG_SND_HDA_POWER_SAVE
12981 if (!spec->loopback.amplist)
12982 spec->loopback.amplist = alc262_loopbacks;
12983#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012984
Kailang Yangdf694da2005-12-05 19:42:22 +010012985 return 0;
12986}
12987
Kailang Yangdf694da2005-12-05 19:42:22 +010012988/*
Kailang Yanga361d842007-06-05 12:30:55 +020012989 * ALC268 channel source setting (2 channel)
12990 */
12991#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12992#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012993
Kailang Yanga361d842007-06-05 12:30:55 +020012994static hda_nid_t alc268_dac_nids[2] = {
12995 /* front, hp */
12996 0x02, 0x03
12997};
12998
12999static hda_nid_t alc268_adc_nids[2] = {
13000 /* ADC0-1 */
13001 0x08, 0x07
13002};
13003
13004static hda_nid_t alc268_adc_nids_alt[1] = {
13005 /* ADC0 */
13006 0x08
13007};
13008
Takashi Iwaie1406342008-02-11 18:32:32 +010013009static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
13010
Kailang Yanga361d842007-06-05 12:30:55 +020013011static struct snd_kcontrol_new alc268_base_mixer[] = {
13012 /* output mixer control */
13013 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13014 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13015 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13016 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013017 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13018 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13019 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020013020 { }
13021};
13022
Takashi Iwai42171c12009-05-08 14:11:43 +020013023static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
13024 /* output mixer control */
13025 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13026 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13027 ALC262_HIPPO_MASTER_SWITCH,
David Henningsson5f99f862011-01-04 15:24:24 +010013028 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13029 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13030 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020013031 { }
13032};
13033
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013034/* bind Beep switches of both NID 0x0f and 0x10 */
13035static struct hda_bind_ctls alc268_bind_beep_sw = {
13036 .ops = &snd_hda_bind_sw,
13037 .values = {
13038 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
13039 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
13040 0
13041 },
13042};
13043
13044static struct snd_kcontrol_new alc268_beep_mixer[] = {
13045 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
13046 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
13047 { }
13048};
13049
Kailang Yangd1a991a2007-08-15 16:21:59 +020013050static struct hda_verb alc268_eapd_verbs[] = {
13051 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13052 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13053 { }
13054};
13055
Takashi Iwaid2738092007-08-16 14:59:45 +020013056/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020013057static struct hda_verb alc268_toshiba_verbs[] = {
13058 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13059 { } /* end */
13060};
13061
13062/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020013063/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020013064static struct hda_bind_ctls alc268_acer_bind_master_vol = {
13065 .ops = &snd_hda_bind_vol,
13066 .values = {
13067 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
13068 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
13069 0
13070 },
13071};
13072
Takashi Iwai889c4392007-08-23 18:56:52 +020013073/* mute/unmute internal speaker according to the hp jack and mute state */
13074static void alc268_acer_automute(struct hda_codec *codec, int force)
13075{
13076 struct alc_spec *spec = codec->spec;
13077 unsigned int mute;
13078
13079 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080013080 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020013081 spec->sense_updated = 1;
13082 }
13083 if (spec->jack_present)
13084 mute = HDA_AMP_MUTE; /* mute internal speaker */
13085 else /* unmute internal speaker if necessary */
13086 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13087 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13088 HDA_AMP_MUTE, mute);
13089}
13090
13091
13092/* bind hp and internal speaker mute (with plug check) */
13093static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
13094 struct snd_ctl_elem_value *ucontrol)
13095{
13096 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
13097 long *valp = ucontrol->value.integer.value;
13098 int change;
13099
Takashi Iwai8de56b72009-07-24 16:51:47 +020013100 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020013101 if (change)
13102 alc268_acer_automute(codec, 0);
13103 return change;
13104}
Takashi Iwaid2738092007-08-16 14:59:45 +020013105
Kailang Yang8ef355d2008-08-26 13:10:22 +020013106static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
13107 /* output mixer control */
13108 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13109 {
13110 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13111 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013112 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013113 .info = snd_hda_mixer_amp_switch_info,
13114 .get = snd_hda_mixer_amp_switch_get,
13115 .put = alc268_acer_master_sw_put,
13116 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13117 },
13118 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
13119 { }
13120};
13121
Takashi Iwaid2738092007-08-16 14:59:45 +020013122static struct snd_kcontrol_new alc268_acer_mixer[] = {
13123 /* output mixer control */
13124 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13125 {
13126 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13127 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013128 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020013129 .info = snd_hda_mixer_amp_switch_info,
13130 .get = snd_hda_mixer_amp_switch_get,
13131 .put = alc268_acer_master_sw_put,
13132 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13133 },
David Henningsson5f99f862011-01-04 15:24:24 +010013134 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13135 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
13136 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020013137 { }
13138};
13139
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013140static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
13141 /* output mixer control */
13142 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13143 {
13144 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13145 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013146 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013147 .info = snd_hda_mixer_amp_switch_info,
13148 .get = snd_hda_mixer_amp_switch_get,
13149 .put = alc268_acer_master_sw_put,
13150 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13151 },
David Henningsson5f99f862011-01-04 15:24:24 +010013152 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13153 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013154 { }
13155};
13156
Kailang Yang8ef355d2008-08-26 13:10:22 +020013157static struct hda_verb alc268_acer_aspire_one_verbs[] = {
13158 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13159 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13160 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13161 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13162 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
13163 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
13164 { }
13165};
13166
Takashi Iwaid2738092007-08-16 14:59:45 +020013167static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013168 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
13169 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020013170 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13171 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013172 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13173 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020013174 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13175 { }
13176};
13177
13178/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020013179#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013180#define alc268_toshiba_setup alc262_hippo_setup
13181#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020013182
13183static void alc268_acer_unsol_event(struct hda_codec *codec,
13184 unsigned int res)
13185{
Takashi Iwai889c4392007-08-23 18:56:52 +020013186 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020013187 return;
13188 alc268_acer_automute(codec, 1);
13189}
13190
Takashi Iwai889c4392007-08-23 18:56:52 +020013191static void alc268_acer_init_hook(struct hda_codec *codec)
13192{
13193 alc268_acer_automute(codec, 1);
13194}
13195
Kailang Yang8ef355d2008-08-26 13:10:22 +020013196/* toggle speaker-output according to the hp-jack state */
13197static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
13198{
13199 unsigned int present;
13200 unsigned char bits;
13201
Wu Fengguang864f92b2009-11-18 12:38:02 +080013202 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013203 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013204 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013205 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013206 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013207 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013208}
13209
Kailang Yang8ef355d2008-08-26 13:10:22 +020013210static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
13211 unsigned int res)
13212{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013213 switch (res >> 26) {
13214 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020013215 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013216 break;
13217 case ALC880_MIC_EVENT:
13218 alc_mic_automute(codec);
13219 break;
13220 }
13221}
13222
13223static void alc268_acer_lc_setup(struct hda_codec *codec)
13224{
13225 struct alc_spec *spec = codec->spec;
13226 spec->ext_mic.pin = 0x18;
13227 spec->ext_mic.mux_idx = 0;
13228 spec->int_mic.pin = 0x12;
13229 spec->int_mic.mux_idx = 6;
13230 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013231}
13232
13233static void alc268_acer_lc_init_hook(struct hda_codec *codec)
13234{
13235 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013236 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013237}
13238
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013239static struct snd_kcontrol_new alc268_dell_mixer[] = {
13240 /* output mixer control */
13241 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13242 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13243 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13244 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013245 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13246 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013247 { }
13248};
13249
13250static struct hda_verb alc268_dell_verbs[] = {
13251 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13252 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13253 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013254 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013255 { }
13256};
13257
13258/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013259static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013260{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013261 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013262
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013263 spec->autocfg.hp_pins[0] = 0x15;
13264 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013265 spec->ext_mic.pin = 0x18;
13266 spec->ext_mic.mux_idx = 0;
13267 spec->int_mic.pin = 0x19;
13268 spec->int_mic.mux_idx = 1;
13269 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013270}
13271
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013272static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
13273 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13274 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13275 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13276 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13277 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13278 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013279 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13280 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013281 { }
13282};
13283
13284static struct hda_verb alc267_quanta_il1_verbs[] = {
13285 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13286 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13287 { }
13288};
13289
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013290static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013291{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013292 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013293 spec->autocfg.hp_pins[0] = 0x15;
13294 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013295 spec->ext_mic.pin = 0x18;
13296 spec->ext_mic.mux_idx = 0;
13297 spec->int_mic.pin = 0x19;
13298 spec->int_mic.mux_idx = 1;
13299 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013300}
13301
Kailang Yanga361d842007-06-05 12:30:55 +020013302/*
13303 * generic initialization of ADC, input mixers and output mixers
13304 */
13305static struct hda_verb alc268_base_init_verbs[] = {
13306 /* Unmute DAC0-1 and set vol = 0 */
13307 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013308 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013309
13310 /*
13311 * Set up output mixers (0x0c - 0x0e)
13312 */
13313 /* set vol=0 to output mixers */
13314 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013315 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13316
13317 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13318 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13319
13320 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13321 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13322 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13323 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13324 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13325 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13326 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13327 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13328
13329 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13330 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13331 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13332 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013333 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013334
13335 /* set PCBEEP vol = 0, mute connections */
13336 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13337 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13338 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013339
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013340 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013341
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013342 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13343 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13344 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13345 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013346
Kailang Yanga361d842007-06-05 12:30:55 +020013347 { }
13348};
13349
13350/*
13351 * generic initialization of ADC, input mixers and output mixers
13352 */
13353static struct hda_verb alc268_volume_init_verbs[] = {
13354 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013355 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13356 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013357
13358 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13359 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13360 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13361 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13362 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13363
Kailang Yanga361d842007-06-05 12:30:55 +020013364 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013365 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13366 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13367
13368 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013369 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013370
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013371 /* set PCBEEP vol = 0, mute connections */
13372 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13373 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13374 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013375
13376 { }
13377};
13378
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013379static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13380 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13381 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13382 { } /* end */
13383};
13384
Kailang Yanga361d842007-06-05 12:30:55 +020013385static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13386 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13387 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013388 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013389 { } /* end */
13390};
13391
13392static struct snd_kcontrol_new alc268_capture_mixer[] = {
13393 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13394 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13395 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13396 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013397 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013398 { } /* end */
13399};
13400
13401static struct hda_input_mux alc268_capture_source = {
13402 .num_items = 4,
13403 .items = {
13404 { "Mic", 0x0 },
13405 { "Front Mic", 0x1 },
13406 { "Line", 0x2 },
13407 { "CD", 0x3 },
13408 },
13409};
13410
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013411static struct hda_input_mux alc268_acer_capture_source = {
13412 .num_items = 3,
13413 .items = {
13414 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013415 { "Internal Mic", 0x1 },
13416 { "Line", 0x2 },
13417 },
13418};
13419
13420static struct hda_input_mux alc268_acer_dmic_capture_source = {
13421 .num_items = 3,
13422 .items = {
13423 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013424 { "Internal Mic", 0x6 },
13425 { "Line", 0x2 },
13426 },
13427};
13428
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013429#ifdef CONFIG_SND_DEBUG
13430static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013431 /* Volume widgets */
13432 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13433 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13434 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13435 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13436 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13437 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13438 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13439 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13440 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13441 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13442 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13443 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13444 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013445 /* The below appears problematic on some hardwares */
13446 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013447 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13448 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13449 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13450 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13451
13452 /* Modes for retasking pin widgets */
13453 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13454 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13455 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13456 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13457
13458 /* Controls for GPIO pins, assuming they are configured as outputs */
13459 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13460 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13461 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13462 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13463
13464 /* Switches to allow the digital SPDIF output pin to be enabled.
13465 * The ALC268 does not have an SPDIF input.
13466 */
13467 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13468
13469 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13470 * this output to turn on an external amplifier.
13471 */
13472 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13473 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13474
13475 { } /* end */
13476};
13477#endif
13478
Kailang Yanga361d842007-06-05 12:30:55 +020013479/* create input playback/capture controls for the given pin */
13480static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13481 const char *ctlname, int idx)
13482{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013483 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013484 int err;
13485
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013486 switch (nid) {
13487 case 0x14:
13488 case 0x16:
13489 dac = 0x02;
13490 break;
13491 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013492 case 0x1a: /* ALC259/269 only */
13493 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013494 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013495 dac = 0x03;
13496 break;
13497 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013498 snd_printd(KERN_WARNING "hda_codec: "
13499 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013500 return 0;
13501 }
13502 if (spec->multiout.dac_nids[0] != dac &&
13503 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013504 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013505 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013506 HDA_OUTPUT));
13507 if (err < 0)
13508 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013509 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13510 }
13511
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013512 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013513 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013514 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013515 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013516 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013517 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013518 if (err < 0)
13519 return err;
13520 return 0;
13521}
13522
13523/* add playback controls from the parsed DAC table */
13524static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13525 const struct auto_pin_cfg *cfg)
13526{
13527 hda_nid_t nid;
13528 int err;
13529
Kailang Yanga361d842007-06-05 12:30:55 +020013530 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013531
13532 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013533 if (nid) {
13534 const char *name;
13535 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13536 name = "Speaker";
13537 else
13538 name = "Front";
13539 err = alc268_new_analog_output(spec, nid, name, 0);
13540 if (err < 0)
13541 return err;
13542 }
Kailang Yanga361d842007-06-05 12:30:55 +020013543
13544 nid = cfg->speaker_pins[0];
13545 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013546 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013547 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13548 if (err < 0)
13549 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013550 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013551 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13552 if (err < 0)
13553 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013554 }
13555 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013556 if (nid) {
13557 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13558 if (err < 0)
13559 return err;
13560 }
Kailang Yanga361d842007-06-05 12:30:55 +020013561
13562 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13563 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013564 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013565 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013566 if (err < 0)
13567 return err;
13568 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013569 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013570}
13571
13572/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013573static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013574 const struct auto_pin_cfg *cfg)
13575{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013576 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013577}
13578
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013579static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13580 hda_nid_t nid, int pin_type)
13581{
13582 int idx;
13583
13584 alc_set_pin_output(codec, nid, pin_type);
13585 if (nid == 0x14 || nid == 0x16)
13586 idx = 0;
13587 else
13588 idx = 1;
13589 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13590}
13591
13592static void alc268_auto_init_multi_out(struct hda_codec *codec)
13593{
13594 struct alc_spec *spec = codec->spec;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013595 int i;
13596
13597 for (i = 0; i < spec->autocfg.line_outs; i++) {
13598 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013599 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13600 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13601 }
13602}
13603
13604static void alc268_auto_init_hp_out(struct hda_codec *codec)
13605{
13606 struct alc_spec *spec = codec->spec;
13607 hda_nid_t pin;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013608 int i;
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013609
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013610 for (i = 0; i < spec->autocfg.hp_outs; i++) {
13611 pin = spec->autocfg.hp_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013612 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013613 }
13614 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
13615 pin = spec->autocfg.speaker_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013616 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013617 }
13618 if (spec->autocfg.mono_out_pin)
13619 snd_hda_codec_write(codec, spec->autocfg.mono_out_pin, 0,
13620 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013621}
13622
Kailang Yanga361d842007-06-05 12:30:55 +020013623static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13624{
13625 struct alc_spec *spec = codec->spec;
13626 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13627 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13628 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13629 unsigned int dac_vol1, dac_vol2;
13630
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013631 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013632 snd_hda_codec_write(codec, speaker_nid, 0,
13633 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013634 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013635 snd_hda_codec_write(codec, 0x0f, 0,
13636 AC_VERB_SET_AMP_GAIN_MUTE,
13637 AMP_IN_UNMUTE(1));
13638 snd_hda_codec_write(codec, 0x10, 0,
13639 AC_VERB_SET_AMP_GAIN_MUTE,
13640 AMP_IN_UNMUTE(1));
13641 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013642 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013643 snd_hda_codec_write(codec, 0x0f, 0,
13644 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13645 snd_hda_codec_write(codec, 0x10, 0,
13646 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13647 }
13648
13649 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013650 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013651 dac_vol2 = AMP_OUT_ZERO;
13652 else if (line_nid == 0x15)
13653 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013654 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013655 dac_vol2 = AMP_OUT_ZERO;
13656 else if (hp_nid == 0x15)
13657 dac_vol1 = AMP_OUT_ZERO;
13658 if (line_nid != 0x16 || hp_nid != 0x16 ||
13659 spec->autocfg.line_out_pins[1] != 0x16 ||
13660 spec->autocfg.line_out_pins[2] != 0x16)
13661 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13662
13663 snd_hda_codec_write(codec, 0x02, 0,
13664 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13665 snd_hda_codec_write(codec, 0x03, 0,
13666 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13667}
13668
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013669/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013670#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13671#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013672#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013673#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13674
13675/*
13676 * BIOS auto configuration
13677 */
13678static int alc268_parse_auto_config(struct hda_codec *codec)
13679{
13680 struct alc_spec *spec = codec->spec;
13681 int err;
13682 static hda_nid_t alc268_ignore[] = { 0 };
13683
13684 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13685 alc268_ignore);
13686 if (err < 0)
13687 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013688 if (!spec->autocfg.line_outs) {
13689 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13690 spec->multiout.max_channels = 2;
13691 spec->no_analog = 1;
13692 goto dig_only;
13693 }
Kailang Yanga361d842007-06-05 12:30:55 +020013694 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013695 }
Kailang Yanga361d842007-06-05 12:30:55 +020013696 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13697 if (err < 0)
13698 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013699 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013700 if (err < 0)
13701 return err;
13702
13703 spec->multiout.max_channels = 2;
13704
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013705 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013706 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013707 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013708 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013709 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013710
Takashi Iwai892981f2009-03-02 08:04:35 +010013711 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013712 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013713
Takashi Iwaid88897e2008-10-31 15:01:37 +010013714 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013715 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013716 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013717
Takashi Iwai776e1842007-08-29 15:07:11 +020013718 err = alc_auto_add_mic_boost(codec);
13719 if (err < 0)
13720 return err;
13721
Kailang Yang6227cdc2010-02-25 08:36:52 +010013722 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013723
Kailang Yanga361d842007-06-05 12:30:55 +020013724 return 1;
13725}
13726
Kailang Yanga361d842007-06-05 12:30:55 +020013727#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13728
13729/* init callback for auto-configuration model -- overriding the default init */
13730static void alc268_auto_init(struct hda_codec *codec)
13731{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013732 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013733 alc268_auto_init_multi_out(codec);
13734 alc268_auto_init_hp_out(codec);
13735 alc268_auto_init_mono_speaker_out(codec);
13736 alc268_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013737 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013738 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013739 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013740}
13741
13742/*
13743 * configuration and preset
13744 */
Takashi Iwaiea734962011-01-17 11:29:34 +010013745static const char * const alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013746 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013747 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013748 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013749 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013750 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013751 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013752 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013753 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013754#ifdef CONFIG_SND_DEBUG
13755 [ALC268_TEST] = "test",
13756#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013757 [ALC268_AUTO] = "auto",
13758};
13759
13760static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013761 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013762 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013763 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013764 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013765 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013766 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13767 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013768 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013769 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13770 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013771 /* almost compatible with toshiba but with optional digital outs;
13772 * auto-probing seems working fine
13773 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013774 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013775 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013776 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013777 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013778 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013779 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013780 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013781 {}
13782};
13783
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013784/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13785static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13786 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13787 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13788 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13789 ALC268_TOSHIBA),
13790 {}
13791};
13792
Kailang Yanga361d842007-06-05 12:30:55 +020013793static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013794 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013795 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13796 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013797 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13798 alc267_quanta_il1_verbs },
13799 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13800 .dac_nids = alc268_dac_nids,
13801 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13802 .adc_nids = alc268_adc_nids_alt,
13803 .hp_nid = 0x03,
13804 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13805 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013806 .unsol_event = alc_sku_unsol_event,
13807 .setup = alc267_quanta_il1_setup,
13808 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013809 },
Kailang Yanga361d842007-06-05 12:30:55 +020013810 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013811 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13812 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013813 .init_verbs = { alc268_base_init_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,
Takashi Iwaie1406342008-02-11 18:32:32 +010013818 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013819 .hp_nid = 0x03,
13820 .dig_out_nid = ALC268_DIGOUT_NID,
13821 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13822 .channel_mode = alc268_modes,
13823 .input_mux = &alc268_capture_source,
13824 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013825 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013826 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013827 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013828 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13829 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013830 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13831 .dac_nids = alc268_dac_nids,
13832 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13833 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013834 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013835 .hp_nid = 0x03,
13836 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13837 .channel_mode = alc268_modes,
13838 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013839 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013840 .setup = alc268_toshiba_setup,
13841 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013842 },
13843 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013844 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013845 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013846 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13847 alc268_acer_verbs },
13848 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13849 .dac_nids = alc268_dac_nids,
13850 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13851 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013852 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013853 .hp_nid = 0x02,
13854 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13855 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013856 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013857 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013858 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013859 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013860 [ALC268_ACER_DMIC] = {
13861 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13862 alc268_beep_mixer },
13863 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13864 alc268_acer_verbs },
13865 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13866 .dac_nids = alc268_dac_nids,
13867 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13868 .adc_nids = alc268_adc_nids_alt,
13869 .capsrc_nids = alc268_capsrc_nids,
13870 .hp_nid = 0x02,
13871 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13872 .channel_mode = alc268_modes,
13873 .input_mux = &alc268_acer_dmic_capture_source,
13874 .unsol_event = alc268_acer_unsol_event,
13875 .init_hook = alc268_acer_init_hook,
13876 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013877 [ALC268_ACER_ASPIRE_ONE] = {
13878 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013879 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013880 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013881 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13882 alc268_acer_aspire_one_verbs },
13883 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13884 .dac_nids = alc268_dac_nids,
13885 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13886 .adc_nids = alc268_adc_nids_alt,
13887 .capsrc_nids = alc268_capsrc_nids,
13888 .hp_nid = 0x03,
13889 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13890 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013891 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013892 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013893 .init_hook = alc268_acer_lc_init_hook,
13894 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013895 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013896 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13897 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013898 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13899 alc268_dell_verbs },
13900 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13901 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013902 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13903 .adc_nids = alc268_adc_nids_alt,
13904 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013905 .hp_nid = 0x02,
13906 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13907 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013908 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013909 .setup = alc268_dell_setup,
13910 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013911 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013912 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013913 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13914 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013915 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13916 alc268_toshiba_verbs },
13917 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13918 .dac_nids = alc268_dac_nids,
13919 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13920 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013921 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013922 .hp_nid = 0x03,
13923 .dig_out_nid = ALC268_DIGOUT_NID,
13924 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13925 .channel_mode = alc268_modes,
13926 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013927 .setup = alc268_toshiba_setup,
13928 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013929 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013930#ifdef CONFIG_SND_DEBUG
13931 [ALC268_TEST] = {
13932 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13933 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13934 alc268_volume_init_verbs },
13935 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13936 .dac_nids = alc268_dac_nids,
13937 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13938 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013939 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013940 .hp_nid = 0x03,
13941 .dig_out_nid = ALC268_DIGOUT_NID,
13942 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13943 .channel_mode = alc268_modes,
13944 .input_mux = &alc268_capture_source,
13945 },
13946#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013947};
13948
13949static int patch_alc268(struct hda_codec *codec)
13950{
13951 struct alc_spec *spec;
13952 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013953 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013954
Julia Lawallef86f582009-12-19 08:18:03 +010013955 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013956 if (spec == NULL)
13957 return -ENOMEM;
13958
13959 codec->spec = spec;
13960
13961 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13962 alc268_models,
13963 alc268_cfg_tbl);
13964
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013965 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13966 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013967 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013968
Kailang Yanga361d842007-06-05 12:30:55 +020013969 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013970 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13971 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013972 board_config = ALC268_AUTO;
13973 }
13974
13975 if (board_config == ALC268_AUTO) {
13976 /* automatic parse from the BIOS config */
13977 err = alc268_parse_auto_config(codec);
13978 if (err < 0) {
13979 alc_free(codec);
13980 return err;
13981 } else if (!err) {
13982 printk(KERN_INFO
13983 "hda_codec: Cannot set up configuration "
13984 "from BIOS. Using base mode...\n");
13985 board_config = ALC268_3ST;
13986 }
13987 }
13988
13989 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013990 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013991
Kailang Yanga361d842007-06-05 12:30:55 +020013992 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13993 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013994 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013995
Kailang Yanga361d842007-06-05 12:30:55 +020013996 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13997
Takashi Iwai22971e32009-02-10 11:56:44 +010013998 has_beep = 0;
13999 for (i = 0; i < spec->num_mixers; i++) {
14000 if (spec->mixers[i] == alc268_beep_mixer) {
14001 has_beep = 1;
14002 break;
14003 }
14004 }
14005
14006 if (has_beep) {
14007 err = snd_hda_attach_beep_device(codec, 0x1);
14008 if (err < 0) {
14009 alc_free(codec);
14010 return err;
14011 }
14012 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
14013 /* override the amp caps for beep generator */
14014 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014015 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
14016 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
14017 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
14018 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010014019 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014020
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014021 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014022 /* check whether NID 0x07 is valid */
14023 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010014024 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020014025
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014026 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014027 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020014028 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014029 if (spec->auto_mic ||
14030 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014031 spec->adc_nids = alc268_adc_nids_alt;
14032 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014033 if (spec->auto_mic)
14034 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014035 if (spec->auto_mic || spec->input_mux->num_items == 1)
14036 add_mixer(spec, alc268_capture_nosrc_mixer);
14037 else
14038 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014039 } else {
14040 spec->adc_nids = alc268_adc_nids;
14041 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010014042 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020014043 }
Takashi Iwai85860c02008-02-19 15:00:15 +010014044 /* set default input source */
14045 for (i = 0; i < spec->num_adc_nids; i++)
14046 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
14047 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030014048 i < spec->num_mux_defs ?
14049 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010014050 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020014051 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010014052
14053 spec->vmaster_nid = 0x02;
14054
Kailang Yanga361d842007-06-05 12:30:55 +020014055 codec->patch_ops = alc_patch_ops;
14056 if (board_config == ALC268_AUTO)
14057 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020014058
Kailang Yangbf1b0222010-10-21 08:49:56 +020014059 alc_init_jacks(codec);
14060
Kailang Yanga361d842007-06-05 12:30:55 +020014061 return 0;
14062}
14063
14064/*
Kailang Yangf6a92242007-12-13 16:52:54 +010014065 * ALC269 channel source setting (2 channel)
14066 */
14067#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
14068
14069#define alc269_dac_nids alc260_dac_nids
14070
14071static hda_nid_t alc269_adc_nids[1] = {
14072 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020014073 0x08,
14074};
14075
Takashi Iwaie01bf502008-08-21 16:25:07 +020014076static hda_nid_t alc269_capsrc_nids[1] = {
14077 0x23,
14078};
14079
Kailang Yang84898e82010-02-04 14:16:14 +010014080static hda_nid_t alc269vb_adc_nids[1] = {
14081 /* ADC1 */
14082 0x09,
14083};
14084
14085static hda_nid_t alc269vb_capsrc_nids[1] = {
14086 0x22,
14087};
14088
Takashi Iwai66946352010-03-29 17:21:45 +020014089static hda_nid_t alc269_adc_candidates[] = {
14090 0x08, 0x09, 0x07,
14091};
Takashi Iwaie01bf502008-08-21 16:25:07 +020014092
Kailang Yangf6a92242007-12-13 16:52:54 +010014093#define alc269_modes alc260_modes
14094#define alc269_capture_source alc880_lg_lw_capture_source
14095
14096static struct snd_kcontrol_new alc269_base_mixer[] = {
14097 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14098 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14099 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14100 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14101 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14102 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014103 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014104 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14105 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014106 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014107 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14108 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
14109 { } /* end */
14110};
14111
Kailang Yang60db6b52008-08-26 13:13:00 +020014112static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
14113 /* output mixer control */
14114 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14115 {
14116 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14117 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014118 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020014119 .info = snd_hda_mixer_amp_switch_info,
14120 .get = snd_hda_mixer_amp_switch_get,
14121 .put = alc268_acer_master_sw_put,
14122 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14123 },
14124 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14125 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014126 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014127 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14128 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014129 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014130 { }
14131};
14132
Tony Vroon64154832008-11-06 15:08:49 +000014133static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
14134 /* output mixer control */
14135 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14136 {
14137 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14138 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014139 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000014140 .info = snd_hda_mixer_amp_switch_info,
14141 .get = snd_hda_mixer_amp_switch_get,
14142 .put = alc268_acer_master_sw_put,
14143 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14144 },
14145 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14146 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014147 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014148 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14149 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014150 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014151 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
14152 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014153 HDA_CODEC_VOLUME("Dock Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014154 { }
14155};
14156
Kailang Yang84898e82010-02-04 14:16:14 +010014157static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020014158 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014159 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020014160 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014161 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020014162 { } /* end */
14163};
14164
Kailang Yang84898e82010-02-04 14:16:14 +010014165static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
14166 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14167 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14168 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14169 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14170 { } /* end */
14171};
14172
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014173static struct snd_kcontrol_new alc269_asus_mixer[] = {
14174 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14175 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
14176 { } /* end */
14177};
14178
Kailang Yangf6a92242007-12-13 16:52:54 +010014179/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010014180static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
14181 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14182 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014183 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14184 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014185 { } /* end */
14186};
14187
14188static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020014189 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14190 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014191 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010014192 { } /* end */
14193};
14194
Kailang Yang84898e82010-02-04 14:16:14 +010014195static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
14196 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14197 HDA_CODEC_MUTE("Capture Switch", 0x09, 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 alc269vb_laptop_digital_capture_mixer[] = {
14204 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14205 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014206 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014207 { } /* end */
14208};
14209
Takashi Iwai26f5df22008-11-03 17:39:46 +010014210/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010014211#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020014212
Kailang Yang60db6b52008-08-26 13:13:00 +020014213static struct hda_verb alc269_quanta_fl1_verbs[] = {
14214 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14215 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14216 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14217 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14218 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14219 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14220 { }
14221};
14222
Tony Vroon64154832008-11-06 15:08:49 +000014223static struct hda_verb alc269_lifebook_verbs[] = {
14224 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14225 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
14226 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14227 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14228 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14229 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14230 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14231 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14232 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14233 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14234 { }
14235};
14236
Kailang Yang60db6b52008-08-26 13:13:00 +020014237/* toggle speaker-output according to the hp-jack state */
14238static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
14239{
14240 unsigned int present;
14241 unsigned char bits;
14242
Wu Fengguang864f92b2009-11-18 12:38:02 +080014243 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014244 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014245 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014246 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014247 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014248 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014249
14250 snd_hda_codec_write(codec, 0x20, 0,
14251 AC_VERB_SET_COEF_INDEX, 0x0c);
14252 snd_hda_codec_write(codec, 0x20, 0,
14253 AC_VERB_SET_PROC_COEF, 0x680);
14254
14255 snd_hda_codec_write(codec, 0x20, 0,
14256 AC_VERB_SET_COEF_INDEX, 0x0c);
14257 snd_hda_codec_write(codec, 0x20, 0,
14258 AC_VERB_SET_PROC_COEF, 0x480);
14259}
14260
Tony Vroon64154832008-11-06 15:08:49 +000014261/* toggle speaker-output according to the hp-jacks state */
14262static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
14263{
14264 unsigned int present;
14265 unsigned char bits;
14266
14267 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014268 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000014269
14270 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014271 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000014272
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014273 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000014274 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014275 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014276 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014277 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014278
14279 snd_hda_codec_write(codec, 0x20, 0,
14280 AC_VERB_SET_COEF_INDEX, 0x0c);
14281 snd_hda_codec_write(codec, 0x20, 0,
14282 AC_VERB_SET_PROC_COEF, 0x680);
14283
14284 snd_hda_codec_write(codec, 0x20, 0,
14285 AC_VERB_SET_COEF_INDEX, 0x0c);
14286 snd_hda_codec_write(codec, 0x20, 0,
14287 AC_VERB_SET_PROC_COEF, 0x480);
14288}
14289
Tony Vroon64154832008-11-06 15:08:49 +000014290static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14291{
14292 unsigned int present_laptop;
14293 unsigned int present_dock;
14294
Wu Fengguang864f92b2009-11-18 12:38:02 +080014295 present_laptop = snd_hda_jack_detect(codec, 0x18);
14296 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014297
14298 /* Laptop mic port overrides dock mic port, design decision */
14299 if (present_dock)
14300 snd_hda_codec_write(codec, 0x23, 0,
14301 AC_VERB_SET_CONNECT_SEL, 0x3);
14302 if (present_laptop)
14303 snd_hda_codec_write(codec, 0x23, 0,
14304 AC_VERB_SET_CONNECT_SEL, 0x0);
14305 if (!present_dock && !present_laptop)
14306 snd_hda_codec_write(codec, 0x23, 0,
14307 AC_VERB_SET_CONNECT_SEL, 0x1);
14308}
14309
Kailang Yang60db6b52008-08-26 13:13:00 +020014310static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14311 unsigned int res)
14312{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014313 switch (res >> 26) {
14314 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014315 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014316 break;
14317 case ALC880_MIC_EVENT:
14318 alc_mic_automute(codec);
14319 break;
14320 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014321}
14322
Tony Vroon64154832008-11-06 15:08:49 +000014323static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14324 unsigned int res)
14325{
14326 if ((res >> 26) == ALC880_HP_EVENT)
14327 alc269_lifebook_speaker_automute(codec);
14328 if ((res >> 26) == ALC880_MIC_EVENT)
14329 alc269_lifebook_mic_autoswitch(codec);
14330}
14331
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014332static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14333{
14334 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014335 spec->autocfg.hp_pins[0] = 0x15;
14336 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014337 spec->ext_mic.pin = 0x18;
14338 spec->ext_mic.mux_idx = 0;
14339 spec->int_mic.pin = 0x19;
14340 spec->int_mic.mux_idx = 1;
14341 spec->auto_mic = 1;
14342}
14343
Kailang Yang60db6b52008-08-26 13:13:00 +020014344static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14345{
14346 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014347 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014348}
14349
Tony Vroon64154832008-11-06 15:08:49 +000014350static void alc269_lifebook_init_hook(struct hda_codec *codec)
14351{
14352 alc269_lifebook_speaker_automute(codec);
14353 alc269_lifebook_mic_autoswitch(codec);
14354}
14355
Kailang Yang84898e82010-02-04 14:16:14 +010014356static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014357 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14358 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14359 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14360 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14361 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14362 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14363 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14364 {}
14365};
14366
Kailang Yang84898e82010-02-04 14:16:14 +010014367static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014368 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14369 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14370 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14371 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14372 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14373 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14374 {}
14375};
14376
Kailang Yang84898e82010-02-04 14:16:14 +010014377static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14378 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14379 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14380 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14381 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14382 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14383 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14384 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14385 {}
14386};
14387
14388static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14389 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14390 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14391 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14392 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14393 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14394 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14395 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14396 {}
14397};
14398
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014399static struct hda_verb alc271_acer_dmic_verbs[] = {
14400 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14401 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14402 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14403 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14404 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14405 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14406 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14407 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14408 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14409 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14410 { }
14411};
14412
Kailang Yang60db6b52008-08-26 13:13:00 +020014413/* toggle speaker-output according to the hp-jack state */
14414static void alc269_speaker_automute(struct hda_codec *codec)
14415{
Kailang Yangebb83ee2009-12-17 12:23:00 +010014416 struct alc_spec *spec = codec->spec;
14417 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020014418 unsigned int present;
14419 unsigned char bits;
14420
Kailang Yangebb83ee2009-12-17 12:23:00 +010014421 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014422 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014423 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014424 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014425 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014426 HDA_AMP_MUTE, bits);
Takashi Iwaicd372fb2011-03-03 14:40:14 +010014427 snd_hda_input_jack_report(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020014428}
14429
Kailang Yang60db6b52008-08-26 13:13:00 +020014430/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010014431static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020014432 unsigned int res)
14433{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014434 switch (res >> 26) {
14435 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014436 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014437 break;
14438 case ALC880_MIC_EVENT:
14439 alc_mic_automute(codec);
14440 break;
14441 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014442}
14443
Kailang Yang226b1ec2010-04-09 11:01:20 +020014444static void alc269_laptop_amic_setup(struct hda_codec *codec)
14445{
14446 struct alc_spec *spec = codec->spec;
14447 spec->autocfg.hp_pins[0] = 0x15;
14448 spec->autocfg.speaker_pins[0] = 0x14;
14449 spec->ext_mic.pin = 0x18;
14450 spec->ext_mic.mux_idx = 0;
14451 spec->int_mic.pin = 0x19;
14452 spec->int_mic.mux_idx = 1;
14453 spec->auto_mic = 1;
14454}
14455
Kailang Yang84898e82010-02-04 14:16:14 +010014456static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014457{
14458 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014459 spec->autocfg.hp_pins[0] = 0x15;
14460 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014461 spec->ext_mic.pin = 0x18;
14462 spec->ext_mic.mux_idx = 0;
14463 spec->int_mic.pin = 0x12;
14464 spec->int_mic.mux_idx = 5;
14465 spec->auto_mic = 1;
14466}
14467
Kailang Yang226b1ec2010-04-09 11:01:20 +020014468static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014469{
14470 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014471 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014472 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014473 spec->ext_mic.pin = 0x18;
14474 spec->ext_mic.mux_idx = 0;
14475 spec->int_mic.pin = 0x19;
14476 spec->int_mic.mux_idx = 1;
14477 spec->auto_mic = 1;
14478}
14479
Kailang Yang226b1ec2010-04-09 11:01:20 +020014480static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14481{
14482 struct alc_spec *spec = codec->spec;
14483 spec->autocfg.hp_pins[0] = 0x21;
14484 spec->autocfg.speaker_pins[0] = 0x14;
14485 spec->ext_mic.pin = 0x18;
14486 spec->ext_mic.mux_idx = 0;
14487 spec->int_mic.pin = 0x12;
14488 spec->int_mic.mux_idx = 6;
14489 spec->auto_mic = 1;
14490}
14491
Kailang Yang84898e82010-02-04 14:16:14 +010014492static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020014493{
14494 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014495 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014496}
14497
Kailang Yangf6a92242007-12-13 16:52:54 +010014498/*
14499 * generic initialization of ADC, input mixers and output mixers
14500 */
14501static struct hda_verb alc269_init_verbs[] = {
14502 /*
14503 * Unmute ADC0 and set the default input to mic-in
14504 */
Kailang Yang84898e82010-02-04 14:16:14 +010014505 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014506
14507 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014508 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014509 */
14510 /* set vol=0 to output mixers */
14511 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14512 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14513
14514 /* set up input amps for analog loopback */
14515 /* Amp Indices: DAC = 0, mixer = 1 */
14516 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14517 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14518 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14519 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14520 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14521 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14522
14523 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14524 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14525 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14526 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14527 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14528 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14529 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14530
14531 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14532 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014533
Kailang Yang84898e82010-02-04 14:16:14 +010014534 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014535 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14536 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014537 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014538
14539 /* set EAPD */
14540 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014541 { }
14542};
14543
14544static struct hda_verb alc269vb_init_verbs[] = {
14545 /*
14546 * Unmute ADC0 and set the default input to mic-in
14547 */
14548 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14549
14550 /*
14551 * Set up output mixers (0x02 - 0x03)
14552 */
14553 /* set vol=0 to output mixers */
14554 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14555 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14556
14557 /* set up input amps for analog loopback */
14558 /* Amp Indices: DAC = 0, mixer = 1 */
14559 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14560 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14561 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14562 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14563 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14564 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14565
14566 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14567 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14568 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14569 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14570 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14571 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14572 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14573
14574 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14575 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14576
14577 /* FIXME: use Mux-type input source selection */
14578 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14579 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14580 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14581
14582 /* set EAPD */
14583 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014584 { }
14585};
14586
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014587#define alc269_auto_create_multi_out_ctls \
14588 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014589#define alc269_auto_create_input_ctls \
14590 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014591
14592#ifdef CONFIG_SND_HDA_POWER_SAVE
14593#define alc269_loopbacks alc880_loopbacks
14594#endif
14595
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014596/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014597#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14598#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14599#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14600#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14601
Takashi Iwaif03d3112009-03-05 14:18:16 +010014602static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14603 .substreams = 1,
14604 .channels_min = 2,
14605 .channels_max = 8,
14606 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14607 /* NID is set in alc_build_pcms */
14608 .ops = {
14609 .open = alc880_playback_pcm_open,
14610 .prepare = alc880_playback_pcm_prepare,
14611 .cleanup = alc880_playback_pcm_cleanup
14612 },
14613};
14614
14615static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14616 .substreams = 1,
14617 .channels_min = 2,
14618 .channels_max = 2,
14619 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14620 /* NID is set in alc_build_pcms */
14621};
14622
Takashi Iwaiad358792010-03-30 18:00:59 +020014623#ifdef CONFIG_SND_HDA_POWER_SAVE
14624static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14625{
14626 switch (codec->subsystem_id) {
14627 case 0x103c1586:
14628 return 1;
14629 }
14630 return 0;
14631}
14632
14633static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14634{
14635 /* update mute-LED according to the speaker mute state */
14636 if (nid == 0x01 || nid == 0x14) {
14637 int pinval;
14638 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14639 HDA_AMP_MUTE)
14640 pinval = 0x24;
14641 else
14642 pinval = 0x20;
14643 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a542010-03-30 18:03:44 +020014644 snd_hda_codec_update_cache(codec, 0x19, 0,
14645 AC_VERB_SET_PIN_WIDGET_CONTROL,
14646 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014647 }
14648 return alc_check_power_status(codec, nid);
14649}
14650#endif /* CONFIG_SND_HDA_POWER_SAVE */
14651
Takashi Iwai840b64c2010-07-13 22:49:01 +020014652static int alc275_setup_dual_adc(struct hda_codec *codec)
14653{
14654 struct alc_spec *spec = codec->spec;
14655
14656 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14657 return 0;
14658 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14659 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14660 if (spec->ext_mic.pin <= 0x12) {
14661 spec->private_adc_nids[0] = 0x08;
14662 spec->private_adc_nids[1] = 0x11;
14663 spec->private_capsrc_nids[0] = 0x23;
14664 spec->private_capsrc_nids[1] = 0x22;
14665 } else {
14666 spec->private_adc_nids[0] = 0x11;
14667 spec->private_adc_nids[1] = 0x08;
14668 spec->private_capsrc_nids[0] = 0x22;
14669 spec->private_capsrc_nids[1] = 0x23;
14670 }
14671 spec->adc_nids = spec->private_adc_nids;
14672 spec->capsrc_nids = spec->private_capsrc_nids;
14673 spec->num_adc_nids = 2;
14674 spec->dual_adc_switch = 1;
14675 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14676 spec->adc_nids[0], spec->adc_nids[1]);
14677 return 1;
14678 }
14679 return 0;
14680}
14681
Takashi Iwaid433a672010-09-20 15:11:54 +020014682/* different alc269-variants */
14683enum {
14684 ALC269_TYPE_NORMAL,
Kailang Yang48c88e82010-11-23 08:56:16 +010014685 ALC269_TYPE_ALC258,
Takashi Iwaid433a672010-09-20 15:11:54 +020014686 ALC269_TYPE_ALC259,
Kailang Yang48c88e82010-11-23 08:56:16 +010014687 ALC269_TYPE_ALC269VB,
14688 ALC269_TYPE_ALC270,
Takashi Iwaid433a672010-09-20 15:11:54 +020014689 ALC269_TYPE_ALC271X,
14690};
14691
Kailang Yangf6a92242007-12-13 16:52:54 +010014692/*
14693 * BIOS auto configuration
14694 */
14695static int alc269_parse_auto_config(struct hda_codec *codec)
14696{
14697 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014698 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014699 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14700
14701 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14702 alc269_ignore);
14703 if (err < 0)
14704 return err;
14705
14706 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14707 if (err < 0)
14708 return err;
Takashi Iwaif3550d12010-09-20 15:09:03 +020014709 if (spec->codec_variant == ALC269_TYPE_NORMAL)
14710 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
14711 else
14712 err = alc_auto_create_input_ctls(codec, &spec->autocfg, 0,
14713 0x22, 0);
Kailang Yangf6a92242007-12-13 16:52:54 +010014714 if (err < 0)
14715 return err;
14716
14717 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14718
Takashi Iwai757899a2010-07-30 10:48:14 +020014719 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014720
Takashi Iwai603c4012008-07-30 15:01:44 +020014721 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014722 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014723
Takashi Iwaid433a672010-09-20 15:11:54 +020014724 if (spec->codec_variant != ALC269_TYPE_NORMAL) {
Kailang Yang84898e82010-02-04 14:16:14 +010014725 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014726 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014727 } else {
14728 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014729 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014730 }
14731
Kailang Yangf6a92242007-12-13 16:52:54 +010014732 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014733 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014734
14735 if (!alc275_setup_dual_adc(codec))
14736 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14737 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014738
Takashi Iwaie01bf502008-08-21 16:25:07 +020014739 /* set default input source */
Takashi Iwai840b64c2010-07-13 22:49:01 +020014740 if (!spec->dual_adc_switch)
Takashi Iwai748cce42010-08-04 07:37:39 +020014741 select_or_unmute_capsrc(codec, spec->capsrc_nids[0],
14742 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014743
14744 err = alc_auto_add_mic_boost(codec);
14745 if (err < 0)
14746 return err;
14747
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014748 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014749 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014750
Kailang Yangf6a92242007-12-13 16:52:54 +010014751 return 1;
14752}
14753
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014754#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14755#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014756#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14757
14758
14759/* init callback for auto-configuration model -- overriding the default init */
14760static void alc269_auto_init(struct hda_codec *codec)
14761{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014762 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014763 alc269_auto_init_multi_out(codec);
14764 alc269_auto_init_hp_out(codec);
14765 alc269_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014766 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014767 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014768 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014769}
14770
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014771#ifdef SND_HDA_NEEDS_RESUME
14772static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
14773{
14774 int val = alc_read_coef_idx(codec, 0x04);
14775 if (power_up)
14776 val |= 1 << 11;
14777 else
14778 val &= ~(1 << 11);
14779 alc_write_coef_idx(codec, 0x04, val);
14780}
14781
Kailang Yang977ddd62010-09-15 10:02:29 +020014782#ifdef CONFIG_SND_HDA_POWER_SAVE
14783static int alc269_suspend(struct hda_codec *codec, pm_message_t state)
14784{
14785 struct alc_spec *spec = codec->spec;
Kailang Yang977ddd62010-09-15 10:02:29 +020014786
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014787 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017)
14788 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014789 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014790 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014791 msleep(150);
14792 }
14793
14794 alc_shutup(codec);
14795 if (spec && spec->power_hook)
14796 spec->power_hook(codec);
14797 return 0;
14798}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014799#endif /* CONFIG_SND_HDA_POWER_SAVE */
14800
Kailang Yang977ddd62010-09-15 10:02:29 +020014801static int alc269_resume(struct hda_codec *codec)
14802{
Kailang Yang977ddd62010-09-15 10:02:29 +020014803 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014804 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014805 msleep(150);
14806 }
14807
14808 codec->patch_ops.init(codec);
14809
14810 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014811 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014812 msleep(200);
14813 }
14814
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014815 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018)
14816 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014817
14818 snd_hda_codec_resume_amp(codec);
14819 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +020014820 hda_call_check_power_status(codec, 0x01);
Kailang Yang977ddd62010-09-15 10:02:29 +020014821 return 0;
14822}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014823#endif /* SND_HDA_NEEDS_RESUME */
Kailang Yang977ddd62010-09-15 10:02:29 +020014824
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014825static void alc269_fixup_hweq(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014826 const struct alc_fixup *fix, int action)
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014827{
14828 int coef;
14829
Takashi Iwai58701122011-01-13 15:41:45 +010014830 if (action != ALC_FIXUP_ACT_INIT)
Takashi Iwai9fb1ef22011-01-13 14:40:43 +010014831 return;
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014832 coef = alc_read_coef_idx(codec, 0x1e);
14833 alc_write_coef_idx(codec, 0x1e, coef | 0x80);
14834}
14835
Takashi Iwaiff818c22010-04-12 08:59:25 +020014836enum {
14837 ALC269_FIXUP_SONY_VAIO,
Takashi Iwai74dc8902011-01-13 14:14:41 +010014838 ALC275_FIXUP_SONY_VAIO_GPIO2,
David Henningsson145a9022010-09-16 10:07:53 +020014839 ALC269_FIXUP_DELL_M101Z,
David Henningsson022c92b2010-12-17 20:43:04 +010014840 ALC269_FIXUP_SKU_IGNORE,
David Henningssonac612402010-12-15 09:18:18 +010014841 ALC269_FIXUP_ASUS_G73JW,
Kailang Yang357f9152011-01-12 08:12:52 +010014842 ALC269_FIXUP_LENOVO_EAPD,
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014843 ALC275_FIXUP_SONY_HWEQ,
Takashi Iwaiff818c22010-04-12 08:59:25 +020014844};
14845
Takashi Iwaiff818c22010-04-12 08:59:25 +020014846static const struct alc_fixup alc269_fixups[] = {
14847 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014848 .type = ALC_FIXUP_VERBS,
14849 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020014850 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14851 {}
14852 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014853 },
Takashi Iwai74dc8902011-01-13 14:14:41 +010014854 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014855 .type = ALC_FIXUP_VERBS,
14856 .v.verbs = (const struct hda_verb[]) {
Kailang Yang27855912010-12-21 09:09:53 +010014857 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
14858 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
14859 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
14860 { }
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014861 },
14862 .chained = true,
14863 .chain_id = ALC269_FIXUP_SONY_VAIO
Kailang Yang27855912010-12-21 09:09:53 +010014864 },
David Henningsson145a9022010-09-16 10:07:53 +020014865 [ALC269_FIXUP_DELL_M101Z] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014866 .type = ALC_FIXUP_VERBS,
14867 .v.verbs = (const struct hda_verb[]) {
David Henningsson145a9022010-09-16 10:07:53 +020014868 /* Enables internal speaker */
14869 {0x20, AC_VERB_SET_COEF_INDEX, 13},
14870 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
14871 {}
14872 }
14873 },
David Henningsson022c92b2010-12-17 20:43:04 +010014874 [ALC269_FIXUP_SKU_IGNORE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014875 .type = ALC_FIXUP_SKU,
14876 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonfe67b242010-12-15 08:01:46 +010014877 },
David Henningssonac612402010-12-15 09:18:18 +010014878 [ALC269_FIXUP_ASUS_G73JW] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014879 .type = ALC_FIXUP_PINS,
14880 .v.pins = (const struct alc_pincfg[]) {
David Henningssonac612402010-12-15 09:18:18 +010014881 { 0x17, 0x99130111 }, /* subwoofer */
14882 { }
14883 }
14884 },
Kailang Yang357f9152011-01-12 08:12:52 +010014885 [ALC269_FIXUP_LENOVO_EAPD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014886 .type = ALC_FIXUP_VERBS,
14887 .v.verbs = (const struct hda_verb[]) {
Kailang Yang357f9152011-01-12 08:12:52 +010014888 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
14889 {}
14890 }
14891 },
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014892 [ALC275_FIXUP_SONY_HWEQ] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014893 .type = ALC_FIXUP_FUNC,
14894 .v.func = alc269_fixup_hweq,
14895 .chained = true,
14896 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014897 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014898};
14899
14900static struct snd_pci_quirk alc269_fixup_tbl[] = {
Takashi Iwai74dc8902011-01-13 14:14:41 +010014901 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014902 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
14903 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
Takashi Iwai7039c742010-12-23 16:35:34 +010014904 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningsson145a9022010-09-16 10:07:53 +020014905 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
David Henningsson022c92b2010-12-17 20:43:04 +010014906 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
David Henningssonded9f522011-01-26 11:46:12 +010014907 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
14908 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
14909 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
14910 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
David Henningssonac612402010-12-15 09:18:18 +010014911 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
Kailang Yang357f9152011-01-12 08:12:52 +010014912 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014913 {}
14914};
14915
14916
Kailang Yangf6a92242007-12-13 16:52:54 +010014917/*
14918 * configuration and preset
14919 */
Takashi Iwaiea734962011-01-17 11:29:34 +010014920static const char * const alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014921 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014922 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014923 [ALC269_AMIC] = "laptop-amic",
14924 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014925 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014926 [ALC269_LIFEBOOK] = "lifebook",
14927 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014928};
14929
14930static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014931 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014932 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014933 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014934 ALC269_AMIC),
14935 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14936 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14937 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14938 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14939 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14940 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14941 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14942 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14943 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
Chih-Wei Huangc790ad32011-02-25 11:14:31 +080014944 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269VB_AMIC),
Kailang Yang84898e82010-02-04 14:16:14 +010014945 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14946 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14947 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14948 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14949 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14950 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14951 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14952 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14953 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14954 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14955 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14956 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14957 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14958 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14959 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14960 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14961 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14962 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14963 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14964 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14965 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14966 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14967 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14968 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14969 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14970 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014971 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014972 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014973 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014974 ALC269_DMIC),
14975 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14976 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014977 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014978 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014979 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14980 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14981 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14982 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14983 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14984 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014985 {}
14986};
14987
14988static struct alc_config_preset alc269_presets[] = {
14989 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014990 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014991 .init_verbs = { alc269_init_verbs },
14992 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14993 .dac_nids = alc269_dac_nids,
14994 .hp_nid = 0x03,
14995 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14996 .channel_mode = alc269_modes,
14997 .input_mux = &alc269_capture_source,
14998 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014999 [ALC269_QUANTA_FL1] = {
15000 .mixers = { alc269_quanta_fl1_mixer },
15001 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
15002 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15003 .dac_nids = alc269_dac_nids,
15004 .hp_nid = 0x03,
15005 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15006 .channel_mode = alc269_modes,
15007 .input_mux = &alc269_capture_source,
15008 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015009 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020015010 .init_hook = alc269_quanta_fl1_init_hook,
15011 },
Kailang Yang84898e82010-02-04 14:16:14 +010015012 [ALC269_AMIC] = {
15013 .mixers = { alc269_laptop_mixer },
15014 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020015015 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015016 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015017 .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,
Kailang Yang84898e82010-02-04 14:16:14 +010015022 .unsol_event = alc269_laptop_unsol_event,
15023 .setup = alc269_laptop_amic_setup,
15024 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015025 },
Kailang Yang84898e82010-02-04 14:16:14 +010015026 [ALC269_DMIC] = {
15027 .mixers = { alc269_laptop_mixer },
15028 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020015029 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015030 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015031 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15032 .dac_nids = alc269_dac_nids,
15033 .hp_nid = 0x03,
15034 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15035 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015036 .unsol_event = alc269_laptop_unsol_event,
15037 .setup = alc269_laptop_dmic_setup,
15038 .init_hook = alc269_laptop_inithook,
15039 },
15040 [ALC269VB_AMIC] = {
15041 .mixers = { alc269vb_laptop_mixer },
15042 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
15043 .init_verbs = { alc269vb_init_verbs,
15044 alc269vb_laptop_amic_init_verbs },
15045 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15046 .dac_nids = alc269_dac_nids,
15047 .hp_nid = 0x03,
15048 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15049 .channel_mode = alc269_modes,
15050 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020015051 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010015052 .init_hook = alc269_laptop_inithook,
15053 },
15054 [ALC269VB_DMIC] = {
15055 .mixers = { alc269vb_laptop_mixer },
15056 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15057 .init_verbs = { alc269vb_init_verbs,
15058 alc269vb_laptop_dmic_init_verbs },
15059 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15060 .dac_nids = alc269_dac_nids,
15061 .hp_nid = 0x03,
15062 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15063 .channel_mode = alc269_modes,
15064 .unsol_event = alc269_laptop_unsol_event,
15065 .setup = alc269vb_laptop_dmic_setup,
15066 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015067 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015068 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015069 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010015070 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015071 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015072 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015073 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15074 .dac_nids = alc269_dac_nids,
15075 .hp_nid = 0x03,
15076 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15077 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015078 .unsol_event = alc269_laptop_unsol_event,
15079 .setup = alc269_laptop_dmic_setup,
15080 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015081 },
Tony Vroon64154832008-11-06 15:08:49 +000015082 [ALC269_LIFEBOOK] = {
15083 .mixers = { alc269_lifebook_mixer },
15084 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
15085 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15086 .dac_nids = alc269_dac_nids,
15087 .hp_nid = 0x03,
15088 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15089 .channel_mode = alc269_modes,
15090 .input_mux = &alc269_capture_source,
15091 .unsol_event = alc269_lifebook_unsol_event,
15092 .init_hook = alc269_lifebook_init_hook,
15093 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020015094 [ALC271_ACER] = {
15095 .mixers = { alc269_asus_mixer },
15096 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15097 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
15098 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15099 .dac_nids = alc269_dac_nids,
15100 .adc_nids = alc262_dmic_adc_nids,
15101 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
15102 .capsrc_nids = alc262_dmic_capsrc_nids,
15103 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15104 .channel_mode = alc269_modes,
15105 .input_mux = &alc269_capture_source,
15106 .dig_out_nid = ALC880_DIGOUT_NID,
15107 .unsol_event = alc_sku_unsol_event,
15108 .setup = alc269vb_laptop_dmic_setup,
15109 .init_hook = alc_inithook,
15110 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015111};
15112
Kailang Yang977ddd62010-09-15 10:02:29 +020015113static int alc269_fill_coef(struct hda_codec *codec)
15114{
15115 int val;
15116
15117 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
15118 alc_write_coef_idx(codec, 0xf, 0x960b);
15119 alc_write_coef_idx(codec, 0xe, 0x8817);
15120 }
15121
15122 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
15123 alc_write_coef_idx(codec, 0xf, 0x960b);
15124 alc_write_coef_idx(codec, 0xe, 0x8814);
15125 }
15126
15127 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
15128 val = alc_read_coef_idx(codec, 0x04);
15129 /* Power up output pin */
15130 alc_write_coef_idx(codec, 0x04, val | (1<<11));
15131 }
15132
15133 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
15134 val = alc_read_coef_idx(codec, 0xd);
15135 if ((val & 0x0c00) >> 10 != 0x1) {
15136 /* Capless ramp up clock control */
15137 alc_write_coef_idx(codec, 0xd, val | 1<<10);
15138 }
15139 val = alc_read_coef_idx(codec, 0x17);
15140 if ((val & 0x01c0) >> 6 != 0x4) {
15141 /* Class D power on reset */
15142 alc_write_coef_idx(codec, 0x17, val | 1<<7);
15143 }
15144 }
15145 return 0;
15146}
15147
Kailang Yangf6a92242007-12-13 16:52:54 +010015148static int patch_alc269(struct hda_codec *codec)
15149{
15150 struct alc_spec *spec;
Kailang Yang48c88e82010-11-23 08:56:16 +010015151 int board_config, coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010015152 int err;
15153
15154 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15155 if (spec == NULL)
15156 return -ENOMEM;
15157
15158 codec->spec = spec;
15159
Kailang Yangda00c242010-03-19 11:23:45 +010015160 alc_auto_parse_customize_define(codec);
15161
Kailang Yangc793bec2010-12-21 09:14:13 +010015162 if (codec->vendor_id == 0x10ec0269) {
15163 coef = alc_read_coef_idx(codec, 0);
15164 if ((coef & 0x00f0) == 0x0010) {
15165 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
15166 spec->cdefine.platform_type == 1) {
15167 alc_codec_rename(codec, "ALC271X");
15168 spec->codec_variant = ALC269_TYPE_ALC271X;
15169 } else if ((coef & 0xf000) == 0x1000) {
15170 spec->codec_variant = ALC269_TYPE_ALC270;
15171 } else if ((coef & 0xf000) == 0x2000) {
15172 alc_codec_rename(codec, "ALC259");
15173 spec->codec_variant = ALC269_TYPE_ALC259;
15174 } else if ((coef & 0xf000) == 0x3000) {
15175 alc_codec_rename(codec, "ALC258");
15176 spec->codec_variant = ALC269_TYPE_ALC258;
15177 } else {
15178 alc_codec_rename(codec, "ALC269VB");
15179 spec->codec_variant = ALC269_TYPE_ALC269VB;
15180 }
15181 } else
15182 alc_fix_pll_init(codec, 0x20, 0x04, 15);
15183 alc269_fill_coef(codec);
15184 }
Kailang Yang977ddd62010-09-15 10:02:29 +020015185
Kailang Yangf6a92242007-12-13 16:52:54 +010015186 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
15187 alc269_models,
15188 alc269_cfg_tbl);
15189
15190 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015191 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15192 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010015193 board_config = ALC269_AUTO;
15194 }
15195
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015196 if (board_config == ALC269_AUTO) {
15197 alc_pick_fixup(codec, NULL, alc269_fixup_tbl, alc269_fixups);
15198 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
15199 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020015200
Kailang Yangf6a92242007-12-13 16:52:54 +010015201 if (board_config == ALC269_AUTO) {
15202 /* automatic parse from the BIOS config */
15203 err = alc269_parse_auto_config(codec);
15204 if (err < 0) {
15205 alc_free(codec);
15206 return err;
15207 } else if (!err) {
15208 printk(KERN_INFO
15209 "hda_codec: Cannot set up configuration "
15210 "from BIOS. Using base mode...\n");
15211 board_config = ALC269_BASIC;
15212 }
15213 }
15214
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015215 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020015216 err = snd_hda_attach_beep_device(codec, 0x1);
15217 if (err < 0) {
15218 alc_free(codec);
15219 return err;
15220 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015221 }
15222
Kailang Yangf6a92242007-12-13 16:52:54 +010015223 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015224 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010015225
Kailang Yang84898e82010-02-04 14:16:14 +010015226 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010015227 /* Due to a hardware problem on Lenovo Ideadpad, we need to
15228 * fix the sample rate of analog I/O to 44.1kHz
15229 */
15230 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
15231 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020015232 } else if (spec->dual_adc_switch) {
15233 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15234 /* switch ADC dynamically */
15235 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010015236 } else {
15237 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15238 spec->stream_analog_capture = &alc269_pcm_analog_capture;
15239 }
Kailang Yangf6a92242007-12-13 16:52:54 +010015240 spec->stream_digital_playback = &alc269_pcm_digital_playback;
15241 spec->stream_digital_capture = &alc269_pcm_digital_capture;
15242
Takashi Iwai66946352010-03-29 17:21:45 +020015243 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
Kailang Yang1657cbd2010-11-23 08:53:32 +010015244 if (spec->codec_variant == ALC269_TYPE_NORMAL) {
Takashi Iwai66946352010-03-29 17:21:45 +020015245 spec->adc_nids = alc269_adc_nids;
15246 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
15247 spec->capsrc_nids = alc269_capsrc_nids;
15248 } else {
15249 spec->adc_nids = alc269vb_adc_nids;
15250 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
15251 spec->capsrc_nids = alc269vb_capsrc_nids;
15252 }
Kailang Yang84898e82010-02-04 14:16:14 +010015253 }
15254
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015255 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015256 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015257 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010015258 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010015259
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015260 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaiff818c22010-04-12 08:59:25 +020015261
Takashi Iwai100d5eb2009-08-10 11:55:51 +020015262 spec->vmaster_nid = 0x02;
15263
Kailang Yangf6a92242007-12-13 16:52:54 +010015264 codec->patch_ops = alc_patch_ops;
Kailang Yang977ddd62010-09-15 10:02:29 +020015265#ifdef CONFIG_SND_HDA_POWER_SAVE
15266 codec->patch_ops.suspend = alc269_suspend;
15267#endif
15268#ifdef SND_HDA_NEEDS_RESUME
15269 codec->patch_ops.resume = alc269_resume;
15270#endif
Kailang Yangf6a92242007-12-13 16:52:54 +010015271 if (board_config == ALC269_AUTO)
15272 spec->init_hook = alc269_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020015273
15274 alc_init_jacks(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010015275#ifdef CONFIG_SND_HDA_POWER_SAVE
15276 if (!spec->loopback.amplist)
15277 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020015278 if (alc269_mic2_for_mute_led(codec))
15279 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010015280#endif
15281
15282 return 0;
15283}
15284
15285/*
Kailang Yangdf694da2005-12-05 19:42:22 +010015286 * ALC861 channel source setting (2/6 channel selection for 3-stack)
15287 */
15288
15289/*
15290 * set the path ways for 2 channel output
15291 * need to set the codec line out and mic 1 pin widgets to inputs
15292 */
15293static struct hda_verb alc861_threestack_ch2_init[] = {
15294 /* set pin widget 1Ah (line in) for input */
15295 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015296 /* set pin widget 18h (mic1/2) for input, for mic also enable
15297 * the vref
15298 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015299 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15300
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015301 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15302#if 0
15303 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15304 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15305#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015306 { } /* end */
15307};
15308/*
15309 * 6ch mode
15310 * need to set the codec line out and mic 1 pin widgets to outputs
15311 */
15312static struct hda_verb alc861_threestack_ch6_init[] = {
15313 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15314 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15315 /* set pin widget 18h (mic1) for output (CLFE)*/
15316 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15317
15318 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015319 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015320
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015321 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15322#if 0
15323 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15324 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15325#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015326 { } /* end */
15327};
15328
15329static struct hda_channel_mode alc861_threestack_modes[2] = {
15330 { 2, alc861_threestack_ch2_init },
15331 { 6, alc861_threestack_ch6_init },
15332};
Takashi Iwai22309c32006-08-09 16:57:28 +020015333/* Set mic1 as input and unmute the mixer */
15334static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
15335 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15336 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15337 { } /* end */
15338};
15339/* Set mic1 as output and mute mixer */
15340static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
15341 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15342 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15343 { } /* end */
15344};
15345
15346static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
15347 { 2, alc861_uniwill_m31_ch2_init },
15348 { 4, alc861_uniwill_m31_ch4_init },
15349};
Kailang Yangdf694da2005-12-05 19:42:22 +010015350
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015351/* Set mic1 and line-in as input and unmute the mixer */
15352static struct hda_verb alc861_asus_ch2_init[] = {
15353 /* set pin widget 1Ah (line in) for input */
15354 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015355 /* set pin widget 18h (mic1/2) for input, for mic also enable
15356 * the vref
15357 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015358 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15359
15360 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15361#if 0
15362 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15363 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15364#endif
15365 { } /* end */
15366};
15367/* Set mic1 nad line-in as output and mute mixer */
15368static struct hda_verb alc861_asus_ch6_init[] = {
15369 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15370 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15371 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15372 /* set pin widget 18h (mic1) for output (CLFE)*/
15373 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15374 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15375 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
15376 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
15377
15378 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15379#if 0
15380 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15381 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15382#endif
15383 { } /* end */
15384};
15385
15386static struct hda_channel_mode alc861_asus_modes[2] = {
15387 { 2, alc861_asus_ch2_init },
15388 { 6, alc861_asus_ch6_init },
15389};
15390
Kailang Yangdf694da2005-12-05 19:42:22 +010015391/* patch-ALC861 */
15392
15393static struct snd_kcontrol_new alc861_base_mixer[] = {
15394 /* output mixer control */
15395 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15396 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15397 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15398 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15399 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15400
15401 /*Input mixer control */
15402 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15403 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15404 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15405 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15406 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15407 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15408 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15409 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15410 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15411 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015412
Kailang Yangdf694da2005-12-05 19:42:22 +010015413 { } /* end */
15414};
15415
15416static struct snd_kcontrol_new alc861_3ST_mixer[] = {
15417 /* output mixer control */
15418 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15419 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15420 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15421 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15422 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15423
15424 /* Input mixer control */
15425 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15426 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15427 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15428 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15429 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15430 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15431 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15432 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15433 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15434 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015435
Kailang Yangdf694da2005-12-05 19:42:22 +010015436 {
15437 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15438 .name = "Channel Mode",
15439 .info = alc_ch_mode_info,
15440 .get = alc_ch_mode_get,
15441 .put = alc_ch_mode_put,
15442 .private_value = ARRAY_SIZE(alc861_threestack_modes),
15443 },
15444 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015445};
15446
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015447static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015448 /* output mixer control */
15449 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15450 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15451 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015452
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015453 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015454};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015455
Takashi Iwai22309c32006-08-09 16:57:28 +020015456static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
15457 /* output mixer control */
15458 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15459 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15460 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15461 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15462 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15463
15464 /* Input mixer control */
15465 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15466 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15467 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15468 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15469 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15470 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15471 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15472 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15473 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15474 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015475
Takashi Iwai22309c32006-08-09 16:57:28 +020015476 {
15477 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15478 .name = "Channel Mode",
15479 .info = alc_ch_mode_info,
15480 .get = alc_ch_mode_get,
15481 .put = alc_ch_mode_put,
15482 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15483 },
15484 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015485};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015486
15487static struct snd_kcontrol_new alc861_asus_mixer[] = {
15488 /* output mixer control */
15489 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15490 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15491 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15492 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15493 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15494
15495 /* Input mixer control */
15496 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15497 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15498 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15499 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15500 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15501 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15502 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15503 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15504 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015505 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15506
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015507 {
15508 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15509 .name = "Channel Mode",
15510 .info = alc_ch_mode_info,
15511 .get = alc_ch_mode_get,
15512 .put = alc_ch_mode_put,
15513 .private_value = ARRAY_SIZE(alc861_asus_modes),
15514 },
15515 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015516};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015517
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015518/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015519static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015520 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15521 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015522 { }
15523};
15524
Kailang Yangdf694da2005-12-05 19:42:22 +010015525/*
15526 * generic initialization of ADC, input mixers and output mixers
15527 */
15528static struct hda_verb alc861_base_init_verbs[] = {
15529 /*
15530 * Unmute ADC0 and set the default input to mic-in
15531 */
15532 /* port-A for surround (rear panel) */
15533 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15534 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15535 /* port-B for mic-in (rear panel) with vref */
15536 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15537 /* port-C for line-in (rear panel) */
15538 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15539 /* port-D for Front */
15540 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15541 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15542 /* port-E for HP out (front panel) */
15543 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15544 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015545 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015546 /* port-F for mic-in (front panel) with vref */
15547 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15548 /* port-G for CLFE (rear panel) */
15549 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15550 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15551 /* port-H for side (rear panel) */
15552 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15553 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15554 /* CD-in */
15555 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15556 /* route front mic to ADC1*/
15557 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15558 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015559
Kailang Yangdf694da2005-12-05 19:42:22 +010015560 /* Unmute DAC0~3 & spdif out*/
15561 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15562 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15563 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15564 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15565 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015566
Kailang Yangdf694da2005-12-05 19:42:22 +010015567 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15568 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15569 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15570 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15571 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015572
Kailang Yangdf694da2005-12-05 19:42:22 +010015573 /* Unmute Stereo Mixer 15 */
15574 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15575 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15576 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015577 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015578
15579 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15580 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15581 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15582 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15583 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15584 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15585 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15586 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015587 /* hp used DAC 3 (Front) */
15588 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015589 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15590
15591 { }
15592};
15593
15594static struct hda_verb alc861_threestack_init_verbs[] = {
15595 /*
15596 * Unmute ADC0 and set the default input to mic-in
15597 */
15598 /* port-A for surround (rear panel) */
15599 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15600 /* port-B for mic-in (rear panel) with vref */
15601 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15602 /* port-C for line-in (rear panel) */
15603 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15604 /* port-D for Front */
15605 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15606 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15607 /* port-E for HP out (front panel) */
15608 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15609 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015610 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015611 /* port-F for mic-in (front panel) with vref */
15612 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15613 /* port-G for CLFE (rear panel) */
15614 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15615 /* port-H for side (rear panel) */
15616 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15617 /* CD-in */
15618 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15619 /* route front mic to ADC1*/
15620 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15621 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15622 /* Unmute DAC0~3 & spdif out*/
15623 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15624 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15625 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15626 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15627 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015628
Kailang Yangdf694da2005-12-05 19:42:22 +010015629 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15630 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15631 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15632 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15633 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015634
Kailang Yangdf694da2005-12-05 19:42:22 +010015635 /* Unmute Stereo Mixer 15 */
15636 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15637 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15638 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015639 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015640
15641 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15642 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15643 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15644 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15645 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15646 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15647 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15648 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015649 /* hp used DAC 3 (Front) */
15650 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015651 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15652 { }
15653};
Takashi Iwai22309c32006-08-09 16:57:28 +020015654
15655static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15656 /*
15657 * Unmute ADC0 and set the default input to mic-in
15658 */
15659 /* port-A for surround (rear panel) */
15660 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15661 /* port-B for mic-in (rear panel) with vref */
15662 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15663 /* port-C for line-in (rear panel) */
15664 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15665 /* port-D for Front */
15666 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15667 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15668 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015669 /* this has to be set to VREF80 */
15670 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015671 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015672 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015673 /* port-F for mic-in (front panel) with vref */
15674 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15675 /* port-G for CLFE (rear panel) */
15676 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15677 /* port-H for side (rear panel) */
15678 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15679 /* CD-in */
15680 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15681 /* route front mic to ADC1*/
15682 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15683 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15684 /* Unmute DAC0~3 & spdif out*/
15685 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15686 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15687 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15688 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15689 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015690
Takashi Iwai22309c32006-08-09 16:57:28 +020015691 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15692 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15693 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15694 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15695 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015696
Takashi Iwai22309c32006-08-09 16:57:28 +020015697 /* Unmute Stereo Mixer 15 */
15698 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15699 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15700 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015701 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015702
15703 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15704 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15705 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15706 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15707 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15708 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15709 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15710 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015711 /* hp used DAC 3 (Front) */
15712 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015713 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15714 { }
15715};
15716
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015717static struct hda_verb alc861_asus_init_verbs[] = {
15718 /*
15719 * Unmute ADC0 and set the default input to mic-in
15720 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015721 /* port-A for surround (rear panel)
15722 * according to codec#0 this is the HP jack
15723 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015724 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15725 /* route front PCM to HP */
15726 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15727 /* port-B for mic-in (rear panel) with vref */
15728 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15729 /* port-C for line-in (rear panel) */
15730 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15731 /* port-D for Front */
15732 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15733 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15734 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015735 /* this has to be set to VREF80 */
15736 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015737 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015738 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015739 /* port-F for mic-in (front panel) with vref */
15740 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15741 /* port-G for CLFE (rear panel) */
15742 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15743 /* port-H for side (rear panel) */
15744 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15745 /* CD-in */
15746 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15747 /* route front mic to ADC1*/
15748 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15749 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15750 /* Unmute DAC0~3 & spdif out*/
15751 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15752 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15753 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15754 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15755 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15756 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15757 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15758 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15759 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15760 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015761
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015762 /* Unmute Stereo Mixer 15 */
15763 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15764 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15765 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015766 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015767
15768 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15769 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15770 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15771 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15772 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15773 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15774 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15775 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015776 /* hp used DAC 3 (Front) */
15777 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015778 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15779 { }
15780};
15781
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015782/* additional init verbs for ASUS laptops */
15783static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15784 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15785 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15786 { }
15787};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015788
Kailang Yangdf694da2005-12-05 19:42:22 +010015789/*
15790 * generic initialization of ADC, input mixers and output mixers
15791 */
15792static struct hda_verb alc861_auto_init_verbs[] = {
15793 /*
15794 * Unmute ADC0 and set the default input to mic-in
15795 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015796 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015797 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015798
Kailang Yangdf694da2005-12-05 19:42:22 +010015799 /* Unmute DAC0~3 & spdif out*/
15800 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15801 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15802 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15803 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15804 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015805
Kailang Yangdf694da2005-12-05 19:42:22 +010015806 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15807 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15808 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15809 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15810 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015811
Kailang Yangdf694da2005-12-05 19:42:22 +010015812 /* Unmute Stereo Mixer 15 */
15813 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15814 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15815 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15816 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15817
Takashi Iwai1c209302009-07-22 15:17:45 +020015818 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15819 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15820 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15821 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15822 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15823 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15824 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15825 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015826
15827 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15828 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015829 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15830 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015831 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15832 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015833 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15834 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015835
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015836 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015837
15838 { }
15839};
15840
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015841static struct hda_verb alc861_toshiba_init_verbs[] = {
15842 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015843
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015844 { }
15845};
15846
15847/* toggle speaker-output according to the hp-jack state */
15848static void alc861_toshiba_automute(struct hda_codec *codec)
15849{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015850 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015851
Takashi Iwai47fd8302007-08-10 17:11:07 +020015852 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15853 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15854 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15855 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015856}
15857
15858static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15859 unsigned int res)
15860{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015861 if ((res >> 26) == ALC880_HP_EVENT)
15862 alc861_toshiba_automute(codec);
15863}
15864
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015865/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015866#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15867#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15868#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15869#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15870
15871
15872#define ALC861_DIGOUT_NID 0x07
15873
15874static struct hda_channel_mode alc861_8ch_modes[1] = {
15875 { 8, NULL }
15876};
15877
15878static hda_nid_t alc861_dac_nids[4] = {
15879 /* front, surround, clfe, side */
15880 0x03, 0x06, 0x05, 0x04
15881};
15882
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015883static hda_nid_t alc660_dac_nids[3] = {
15884 /* front, clfe, surround */
15885 0x03, 0x05, 0x06
15886};
15887
Kailang Yangdf694da2005-12-05 19:42:22 +010015888static hda_nid_t alc861_adc_nids[1] = {
15889 /* ADC0-2 */
15890 0x08,
15891};
15892
15893static struct hda_input_mux alc861_capture_source = {
15894 .num_items = 5,
15895 .items = {
15896 { "Mic", 0x0 },
15897 { "Front Mic", 0x3 },
15898 { "Line", 0x1 },
15899 { "CD", 0x4 },
15900 { "Mixer", 0x5 },
15901 },
15902};
15903
Takashi Iwai1c209302009-07-22 15:17:45 +020015904static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15905{
15906 struct alc_spec *spec = codec->spec;
15907 hda_nid_t mix, srcs[5];
15908 int i, j, num;
15909
15910 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15911 return 0;
15912 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15913 if (num < 0)
15914 return 0;
15915 for (i = 0; i < num; i++) {
15916 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015917 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015918 if (type != AC_WID_AUD_OUT)
15919 continue;
15920 for (j = 0; j < spec->multiout.num_dacs; j++)
15921 if (spec->multiout.dac_nids[j] == srcs[i])
15922 break;
15923 if (j >= spec->multiout.num_dacs)
15924 return srcs[i];
15925 }
15926 return 0;
15927}
15928
Kailang Yangdf694da2005-12-05 19:42:22 +010015929/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015930static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015931 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015932{
Takashi Iwai1c209302009-07-22 15:17:45 +020015933 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015934 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015935 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015936
15937 spec->multiout.dac_nids = spec->private_dac_nids;
15938 for (i = 0; i < cfg->line_outs; i++) {
15939 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015940 dac = alc861_look_for_dac(codec, nid);
15941 if (!dac)
15942 continue;
15943 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015944 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015945 return 0;
15946}
15947
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015948static int __alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15949 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015950{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015951 return __add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015952 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15953}
15954
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015955#define alc861_create_out_sw(codec, pfx, nid, chs) \
15956 __alc861_create_out_sw(codec, pfx, nid, 0, chs)
15957
Takashi Iwai1c209302009-07-22 15:17:45 +020015958/* add playback controls from the parsed DAC table */
15959static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15960 const struct auto_pin_cfg *cfg)
15961{
15962 struct alc_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +010015963 static const char * const chname[4] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015964 "Front", "Surround", NULL /*CLFE*/, "Side"
15965 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015966 const char *pfx = alc_get_line_out_pfx(cfg, true);
Kailang Yangdf694da2005-12-05 19:42:22 +010015967 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015968 int i, err;
15969
Kailang Yangdf694da2005-12-05 19:42:22 +010015970 for (i = 0; i < cfg->line_outs; i++) {
15971 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015972 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015973 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015974 if (!pfx && i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015975 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015976 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015977 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015978 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015979 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015980 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015981 return err;
15982 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015983 const char *name = pfx;
15984 if (!name)
15985 name = chname[i];
15986 err = __alc861_create_out_sw(codec, name, nid, i, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015987 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015988 return err;
15989 }
15990 }
15991 return 0;
15992}
15993
Takashi Iwai1c209302009-07-22 15:17:45 +020015994static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015995{
Takashi Iwai1c209302009-07-22 15:17:45 +020015996 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015997 int err;
15998 hda_nid_t nid;
15999
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016000 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010016001 return 0;
16002
16003 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020016004 nid = alc861_look_for_dac(codec, pin);
16005 if (nid) {
16006 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
16007 if (err < 0)
16008 return err;
16009 spec->multiout.hp_nid = nid;
16010 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016011 }
16012 return 0;
16013}
16014
16015/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016016static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016017 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010016018{
Takashi Iwai05f5f472009-08-25 13:10:18 +020016019 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010016020}
16021
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016022static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
16023 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020016024 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010016025{
Takashi Iwai1c209302009-07-22 15:17:45 +020016026 hda_nid_t mix, srcs[5];
16027 int i, num;
16028
Jacek Luczak564c5be2008-05-03 18:41:23 +020016029 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
16030 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020016031 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020016032 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020016033 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
16034 return;
16035 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
16036 if (num < 0)
16037 return;
16038 for (i = 0; i < num; i++) {
16039 unsigned int mute;
16040 if (srcs[i] == dac || srcs[i] == 0x15)
16041 mute = AMP_IN_UNMUTE(i);
16042 else
16043 mute = AMP_IN_MUTE(i);
16044 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16045 mute);
16046 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016047}
16048
16049static void alc861_auto_init_multi_out(struct hda_codec *codec)
16050{
16051 struct alc_spec *spec = codec->spec;
16052 int i;
16053
16054 for (i = 0; i < spec->autocfg.line_outs; i++) {
16055 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016056 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016057 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016058 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016059 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016060 }
16061}
16062
16063static void alc861_auto_init_hp_out(struct hda_codec *codec)
16064{
16065 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016066
Takashi Iwai15870f02009-10-05 08:25:13 +020016067 if (spec->autocfg.hp_outs)
16068 alc861_auto_set_output_and_unmute(codec,
16069 spec->autocfg.hp_pins[0],
16070 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020016071 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020016072 if (spec->autocfg.speaker_outs)
16073 alc861_auto_set_output_and_unmute(codec,
16074 spec->autocfg.speaker_pins[0],
16075 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020016076 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016077}
16078
16079static void alc861_auto_init_analog_input(struct hda_codec *codec)
16080{
16081 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016082 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010016083 int i;
16084
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016085 for (i = 0; i < cfg->num_inputs; i++) {
16086 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010016087 if (nid >= 0x0c && nid <= 0x11)
Takashi Iwai30ea0982010-09-16 18:47:56 +020016088 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016089 }
16090}
16091
16092/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016093/* return 1 if successful, 0 if the proper config is not found,
16094 * or a negative error code
16095 */
Kailang Yangdf694da2005-12-05 19:42:22 +010016096static int alc861_parse_auto_config(struct hda_codec *codec)
16097{
16098 struct alc_spec *spec = codec->spec;
16099 int err;
16100 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
16101
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016102 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16103 alc861_ignore);
16104 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016105 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016106 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010016107 return 0; /* can't find valid BIOS pin config */
16108
Takashi Iwai1c209302009-07-22 15:17:45 +020016109 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016110 if (err < 0)
16111 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016112 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016113 if (err < 0)
16114 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016115 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016116 if (err < 0)
16117 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016118 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016119 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016120 return err;
16121
16122 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16123
Takashi Iwai757899a2010-07-30 10:48:14 +020016124 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016125
Takashi Iwai603c4012008-07-30 15:01:44 +020016126 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016127 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010016128
Takashi Iwaid88897e2008-10-31 15:01:37 +010016129 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010016130
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020016131 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016132 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010016133
16134 spec->adc_nids = alc861_adc_nids;
16135 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016136 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016137
Kailang Yang6227cdc2010-02-25 08:36:52 +010016138 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016139
Kailang Yangdf694da2005-12-05 19:42:22 +010016140 return 1;
16141}
16142
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016143/* additional initialization for auto-configuration model */
16144static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010016145{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016146 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016147 alc861_auto_init_multi_out(codec);
16148 alc861_auto_init_hp_out(codec);
16149 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020016150 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016151 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016152 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016153}
16154
Takashi Iwaicb53c622007-08-10 17:21:45 +020016155#ifdef CONFIG_SND_HDA_POWER_SAVE
16156static struct hda_amp_list alc861_loopbacks[] = {
16157 { 0x15, HDA_INPUT, 0 },
16158 { 0x15, HDA_INPUT, 1 },
16159 { 0x15, HDA_INPUT, 2 },
16160 { 0x15, HDA_INPUT, 3 },
16161 { } /* end */
16162};
16163#endif
16164
Kailang Yangdf694da2005-12-05 19:42:22 +010016165
16166/*
16167 * configuration and preset
16168 */
Takashi Iwaiea734962011-01-17 11:29:34 +010016169static const char * const alc861_models[ALC861_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016170 [ALC861_3ST] = "3stack",
16171 [ALC660_3ST] = "3stack-660",
16172 [ALC861_3ST_DIG] = "3stack-dig",
16173 [ALC861_6ST_DIG] = "6stack-dig",
16174 [ALC861_UNIWILL_M31] = "uniwill-m31",
16175 [ALC861_TOSHIBA] = "toshiba",
16176 [ALC861_ASUS] = "asus",
16177 [ALC861_ASUS_LAPTOP] = "asus-laptop",
16178 [ALC861_AUTO] = "auto",
16179};
16180
16181static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010016182 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016183 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16184 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16185 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016186 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020016187 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010016188 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020016189 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
16190 * Any other models that need this preset?
16191 */
16192 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020016193 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
16194 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016195 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
16196 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
16197 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
16198 /* FIXME: the below seems conflict */
16199 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
16200 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
16201 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010016202 {}
16203};
16204
16205static struct alc_config_preset alc861_presets[] = {
16206 [ALC861_3ST] = {
16207 .mixers = { alc861_3ST_mixer },
16208 .init_verbs = { alc861_threestack_init_verbs },
16209 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16210 .dac_nids = alc861_dac_nids,
16211 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16212 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016213 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016214 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16215 .adc_nids = alc861_adc_nids,
16216 .input_mux = &alc861_capture_source,
16217 },
16218 [ALC861_3ST_DIG] = {
16219 .mixers = { alc861_base_mixer },
16220 .init_verbs = { alc861_threestack_init_verbs },
16221 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16222 .dac_nids = alc861_dac_nids,
16223 .dig_out_nid = ALC861_DIGOUT_NID,
16224 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16225 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016226 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016227 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16228 .adc_nids = alc861_adc_nids,
16229 .input_mux = &alc861_capture_source,
16230 },
16231 [ALC861_6ST_DIG] = {
16232 .mixers = { alc861_base_mixer },
16233 .init_verbs = { alc861_base_init_verbs },
16234 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16235 .dac_nids = alc861_dac_nids,
16236 .dig_out_nid = ALC861_DIGOUT_NID,
16237 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
16238 .channel_mode = alc861_8ch_modes,
16239 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16240 .adc_nids = alc861_adc_nids,
16241 .input_mux = &alc861_capture_source,
16242 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016243 [ALC660_3ST] = {
16244 .mixers = { alc861_3ST_mixer },
16245 .init_verbs = { alc861_threestack_init_verbs },
16246 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
16247 .dac_nids = alc660_dac_nids,
16248 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16249 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016250 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016251 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16252 .adc_nids = alc861_adc_nids,
16253 .input_mux = &alc861_capture_source,
16254 },
Takashi Iwai22309c32006-08-09 16:57:28 +020016255 [ALC861_UNIWILL_M31] = {
16256 .mixers = { alc861_uniwill_m31_mixer },
16257 .init_verbs = { alc861_uniwill_m31_init_verbs },
16258 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16259 .dac_nids = alc861_dac_nids,
16260 .dig_out_nid = ALC861_DIGOUT_NID,
16261 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
16262 .channel_mode = alc861_uniwill_m31_modes,
16263 .need_dac_fix = 1,
16264 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16265 .adc_nids = alc861_adc_nids,
16266 .input_mux = &alc861_capture_source,
16267 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016268 [ALC861_TOSHIBA] = {
16269 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016270 .init_verbs = { alc861_base_init_verbs,
16271 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016272 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16273 .dac_nids = alc861_dac_nids,
16274 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16275 .channel_mode = alc883_3ST_2ch_modes,
16276 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16277 .adc_nids = alc861_adc_nids,
16278 .input_mux = &alc861_capture_source,
16279 .unsol_event = alc861_toshiba_unsol_event,
16280 .init_hook = alc861_toshiba_automute,
16281 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020016282 [ALC861_ASUS] = {
16283 .mixers = { alc861_asus_mixer },
16284 .init_verbs = { alc861_asus_init_verbs },
16285 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16286 .dac_nids = alc861_dac_nids,
16287 .dig_out_nid = ALC861_DIGOUT_NID,
16288 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
16289 .channel_mode = alc861_asus_modes,
16290 .need_dac_fix = 1,
16291 .hp_nid = 0x06,
16292 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16293 .adc_nids = alc861_adc_nids,
16294 .input_mux = &alc861_capture_source,
16295 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010016296 [ALC861_ASUS_LAPTOP] = {
16297 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
16298 .init_verbs = { alc861_asus_init_verbs,
16299 alc861_asus_laptop_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(alc883_3ST_2ch_modes),
16304 .channel_mode = alc883_3ST_2ch_modes,
16305 .need_dac_fix = 1,
16306 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16307 .adc_nids = alc861_adc_nids,
16308 .input_mux = &alc861_capture_source,
16309 },
16310};
Kailang Yangdf694da2005-12-05 19:42:22 +010016311
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016312/* Pin config fixes */
16313enum {
16314 PINFIX_FSC_AMILO_PI1505,
16315};
16316
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016317static const struct alc_fixup alc861_fixups[] = {
16318 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016319 .type = ALC_FIXUP_PINS,
16320 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020016321 { 0x0b, 0x0221101f }, /* HP */
16322 { 0x0f, 0x90170310 }, /* speaker */
16323 { }
16324 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016325 },
16326};
16327
16328static struct snd_pci_quirk alc861_fixup_tbl[] = {
16329 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
16330 {}
16331};
Kailang Yangdf694da2005-12-05 19:42:22 +010016332
16333static int patch_alc861(struct hda_codec *codec)
16334{
16335 struct alc_spec *spec;
16336 int board_config;
16337 int err;
16338
Robert P. J. Daydc041e02006-12-19 14:44:15 +010016339 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010016340 if (spec == NULL)
16341 return -ENOMEM;
16342
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016343 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016344
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016345 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
16346 alc861_models,
16347 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016348
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016349 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016350 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16351 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010016352 board_config = ALC861_AUTO;
16353 }
16354
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016355 if (board_config == ALC861_AUTO) {
16356 alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
16357 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
16358 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016359
Kailang Yangdf694da2005-12-05 19:42:22 +010016360 if (board_config == ALC861_AUTO) {
16361 /* automatic parse from the BIOS config */
16362 err = alc861_parse_auto_config(codec);
16363 if (err < 0) {
16364 alc_free(codec);
16365 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016366 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016367 printk(KERN_INFO
16368 "hda_codec: Cannot set up configuration "
16369 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010016370 board_config = ALC861_3ST_DIG;
16371 }
16372 }
16373
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016374 err = snd_hda_attach_beep_device(codec, 0x23);
16375 if (err < 0) {
16376 alc_free(codec);
16377 return err;
16378 }
16379
Kailang Yangdf694da2005-12-05 19:42:22 +010016380 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016381 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016382
Kailang Yangdf694da2005-12-05 19:42:22 +010016383 spec->stream_analog_playback = &alc861_pcm_analog_playback;
16384 spec->stream_analog_capture = &alc861_pcm_analog_capture;
16385
Kailang Yangdf694da2005-12-05 19:42:22 +010016386 spec->stream_digital_playback = &alc861_pcm_digital_playback;
16387 spec->stream_digital_capture = &alc861_pcm_digital_capture;
16388
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010016389 if (!spec->cap_mixer)
16390 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016391 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
16392
Takashi Iwai2134ea42008-01-10 16:53:55 +010016393 spec->vmaster_nid = 0x03;
16394
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016395 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016396
Kailang Yangdf694da2005-12-05 19:42:22 +010016397 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050016398 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016399 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016400#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050016401 spec->power_hook = alc_power_eapd;
16402#endif
16403 }
16404#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020016405 if (!spec->loopback.amplist)
16406 spec->loopback.amplist = alc861_loopbacks;
16407#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020016408
Kailang Yangdf694da2005-12-05 19:42:22 +010016409 return 0;
16410}
16411
16412/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016413 * ALC861-VD support
16414 *
16415 * Based on ALC882
16416 *
16417 * In addition, an independent DAC
16418 */
16419#define ALC861VD_DIGOUT_NID 0x06
16420
16421static hda_nid_t alc861vd_dac_nids[4] = {
16422 /* front, surr, clfe, side surr */
16423 0x02, 0x03, 0x04, 0x05
16424};
16425
16426/* dac_nids for ALC660vd are in a different order - according to
16427 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016428 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016429 * of ALC660vd codecs, but for now there is only 3stack mixer
16430 * - and it is the same as in 861vd.
16431 * adc_nids in ALC660vd are (is) the same as in 861vd
16432 */
16433static hda_nid_t alc660vd_dac_nids[3] = {
16434 /* front, rear, clfe, rear_surr */
16435 0x02, 0x04, 0x03
16436};
16437
16438static hda_nid_t alc861vd_adc_nids[1] = {
16439 /* ADC0 */
16440 0x09,
16441};
16442
Takashi Iwaie1406342008-02-11 18:32:32 +010016443static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
16444
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016445/* input MUX */
16446/* FIXME: should be a matrix-type input source selection */
16447static struct hda_input_mux alc861vd_capture_source = {
16448 .num_items = 4,
16449 .items = {
16450 { "Mic", 0x0 },
16451 { "Front Mic", 0x1 },
16452 { "Line", 0x2 },
16453 { "CD", 0x4 },
16454 },
16455};
16456
Kailang Yang272a5272007-05-14 11:00:38 +020016457static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016458 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016459 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +010016460 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010016461 { "Internal Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016462 },
16463};
16464
Kailang Yangd1a991a2007-08-15 16:21:59 +020016465static struct hda_input_mux alc861vd_hp_capture_source = {
16466 .num_items = 2,
16467 .items = {
16468 { "Front Mic", 0x0 },
16469 { "ATAPI Mic", 0x1 },
16470 },
16471};
16472
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016473/*
16474 * 2ch mode
16475 */
16476static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16477 { 2, NULL }
16478};
16479
16480/*
16481 * 6ch mode
16482 */
16483static struct hda_verb alc861vd_6stack_ch6_init[] = {
16484 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16485 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16486 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16487 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16488 { } /* end */
16489};
16490
16491/*
16492 * 8ch mode
16493 */
16494static struct hda_verb alc861vd_6stack_ch8_init[] = {
16495 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16496 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16497 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16498 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16499 { } /* end */
16500};
16501
16502static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16503 { 6, alc861vd_6stack_ch6_init },
16504 { 8, alc861vd_6stack_ch8_init },
16505};
16506
16507static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16508 {
16509 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16510 .name = "Channel Mode",
16511 .info = alc_ch_mode_info,
16512 .get = alc_ch_mode_get,
16513 .put = alc_ch_mode_put,
16514 },
16515 { } /* end */
16516};
16517
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016518/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16519 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16520 */
16521static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16522 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16523 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16524
16525 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16526 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16527
16528 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16529 HDA_OUTPUT),
16530 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16531 HDA_OUTPUT),
16532 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16533 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16534
16535 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16536 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16537
16538 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16539
David Henningsson5f99f862011-01-04 15:24:24 +010016540 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016541 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16542 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16543
David Henningsson5f99f862011-01-04 15:24:24 +010016544 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016545 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16546 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16547
16548 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16549 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16550
16551 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16552 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16553
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016554 { } /* end */
16555};
16556
16557static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16558 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16559 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16560
16561 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16562
David Henningsson5f99f862011-01-04 15:24:24 +010016563 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016564 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16565 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16566
David Henningsson5f99f862011-01-04 15:24:24 +010016567 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016568 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16569 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16570
16571 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16572 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16573
16574 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16575 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16576
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016577 { } /* end */
16578};
16579
Kailang Yangbdd148a2007-05-08 15:19:08 +020016580static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16581 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16582 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16583 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16584
16585 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16586
David Henningsson5f99f862011-01-04 15:24:24 +010016587 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016588 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16589 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16590
David Henningsson5f99f862011-01-04 15:24:24 +010016591 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016592 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16593 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16594
16595 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16596 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16597
16598 { } /* end */
16599};
16600
Tobin Davisb419f342008-03-07 11:57:51 +010016601/* Pin assignment: Speaker=0x14, HP = 0x15,
David Henningsson8607f7c2010-12-20 14:43:54 +010016602 * Mic=0x18, Internal Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016603 */
16604static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016605 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16606 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016607 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16608 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016609 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +010016610 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16611 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016612 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010016613 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16614 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016615 { } /* end */
16616};
16617
Kailang Yangd1a991a2007-08-15 16:21:59 +020016618/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16619 * Front Mic=0x18, ATAPI Mic = 0x19,
16620 */
16621static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16622 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16623 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16624 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16625 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16626 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16627 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16628 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16629 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016630
Kailang Yangd1a991a2007-08-15 16:21:59 +020016631 { } /* end */
16632};
16633
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016634/*
16635 * generic initialization of ADC, input mixers and output mixers
16636 */
16637static struct hda_verb alc861vd_volume_init_verbs[] = {
16638 /*
16639 * Unmute ADC0 and set the default input to mic-in
16640 */
16641 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16642 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16643
16644 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16645 * the analog-loopback mixer widget
16646 */
16647 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016648 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16649 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16650 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16651 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16652 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016653
16654 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016655 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16656 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16657 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016658 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016659
16660 /*
16661 * Set up output mixers (0x02 - 0x05)
16662 */
16663 /* set vol=0 to output mixers */
16664 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16665 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16666 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16667 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16668
16669 /* set up input amps for analog loopback */
16670 /* Amp Indices: DAC = 0, mixer = 1 */
16671 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16672 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16673 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16674 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16675 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16676 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16677 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16678 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16679
16680 { }
16681};
16682
16683/*
16684 * 3-stack pin configuration:
16685 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16686 */
16687static struct hda_verb alc861vd_3stack_init_verbs[] = {
16688 /*
16689 * Set pin mode and muting
16690 */
16691 /* set front pin widgets 0x14 for output */
16692 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16693 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16694 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16695
16696 /* Mic (rear) pin: input vref at 80% */
16697 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16698 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16699 /* Front Mic pin: input vref at 80% */
16700 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16701 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16702 /* Line In pin: input */
16703 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16704 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16705 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16706 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16707 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16708 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16709 /* CD pin widget for input */
16710 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16711
16712 { }
16713};
16714
16715/*
16716 * 6-stack pin configuration:
16717 */
16718static struct hda_verb alc861vd_6stack_init_verbs[] = {
16719 /*
16720 * Set pin mode and muting
16721 */
16722 /* set front pin widgets 0x14 for output */
16723 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16724 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16725 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16726
16727 /* Rear Pin: output 1 (0x0d) */
16728 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16729 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16730 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16731 /* CLFE Pin: output 2 (0x0e) */
16732 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16733 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16734 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16735 /* Side Pin: output 3 (0x0f) */
16736 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16737 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16738 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16739
16740 /* Mic (rear) pin: input vref at 80% */
16741 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16742 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16743 /* Front Mic pin: input vref at 80% */
16744 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16745 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16746 /* Line In pin: input */
16747 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16748 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16749 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16750 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16751 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16752 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16753 /* CD pin widget for input */
16754 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16755
16756 { }
16757};
16758
Kailang Yangbdd148a2007-05-08 15:19:08 +020016759static struct hda_verb alc861vd_eapd_verbs[] = {
16760 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16761 { }
16762};
16763
Kailang Yangf9423e72008-05-27 12:32:25 +020016764static struct hda_verb alc660vd_eapd_verbs[] = {
16765 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16766 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16767 { }
16768};
16769
Kailang Yangbdd148a2007-05-08 15:19:08 +020016770static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16771 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16772 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16773 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16774 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016775 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016776 {}
16777};
16778
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016779static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016780{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016781 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016782 spec->autocfg.hp_pins[0] = 0x1b;
16783 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016784}
16785
16786static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16787{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016788 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +010016789 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016790}
16791
16792static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16793 unsigned int res)
16794{
16795 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016796 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +010016797 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016798 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016799 default:
16800 alc_automute_amp_unsol_event(codec, res);
16801 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016802 }
16803}
16804
Kailang Yang272a5272007-05-14 11:00:38 +020016805static struct hda_verb alc861vd_dallas_verbs[] = {
16806 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16807 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16808 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16809 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16810
16811 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16812 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16813 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16814 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16815 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16816 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16817 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16818 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016819
Kailang Yang272a5272007-05-14 11:00:38 +020016820 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16821 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16822 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16823 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16824 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16825 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16826 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16827 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16828
16829 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16830 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16831 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16832 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16833 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16834 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16835 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16836 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16837
16838 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16839 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16840 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16841 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16842
16843 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016844 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016845 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16846
16847 { } /* end */
16848};
16849
16850/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016851static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016852{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016853 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016854
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016855 spec->autocfg.hp_pins[0] = 0x15;
16856 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016857}
16858
Takashi Iwaicb53c622007-08-10 17:21:45 +020016859#ifdef CONFIG_SND_HDA_POWER_SAVE
16860#define alc861vd_loopbacks alc880_loopbacks
16861#endif
16862
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016863/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016864#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16865#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16866#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16867#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16868
16869/*
16870 * configuration and preset
16871 */
Takashi Iwaiea734962011-01-17 11:29:34 +010016872static const char * const alc861vd_models[ALC861VD_MODEL_LAST] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016873 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016874 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016875 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016876 [ALC861VD_3ST] = "3stack",
16877 [ALC861VD_3ST_DIG] = "3stack-digout",
16878 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016879 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016880 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016881 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016882 [ALC861VD_AUTO] = "auto",
16883};
16884
16885static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016886 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16887 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016888 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016889 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016890 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016891 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016892 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016893 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016894 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016895 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016896 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016897 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016898 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016899 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016900 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016901 {}
16902};
16903
16904static struct alc_config_preset alc861vd_presets[] = {
16905 [ALC660VD_3ST] = {
16906 .mixers = { alc861vd_3st_mixer },
16907 .init_verbs = { alc861vd_volume_init_verbs,
16908 alc861vd_3stack_init_verbs },
16909 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16910 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016911 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16912 .channel_mode = alc861vd_3stack_2ch_modes,
16913 .input_mux = &alc861vd_capture_source,
16914 },
Mike Crash6963f842007-06-25 12:12:51 +020016915 [ALC660VD_3ST_DIG] = {
16916 .mixers = { alc861vd_3st_mixer },
16917 .init_verbs = { alc861vd_volume_init_verbs,
16918 alc861vd_3stack_init_verbs },
16919 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16920 .dac_nids = alc660vd_dac_nids,
16921 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016922 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16923 .channel_mode = alc861vd_3stack_2ch_modes,
16924 .input_mux = &alc861vd_capture_source,
16925 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016926 [ALC861VD_3ST] = {
16927 .mixers = { alc861vd_3st_mixer },
16928 .init_verbs = { alc861vd_volume_init_verbs,
16929 alc861vd_3stack_init_verbs },
16930 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16931 .dac_nids = alc861vd_dac_nids,
16932 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16933 .channel_mode = alc861vd_3stack_2ch_modes,
16934 .input_mux = &alc861vd_capture_source,
16935 },
16936 [ALC861VD_3ST_DIG] = {
16937 .mixers = { alc861vd_3st_mixer },
16938 .init_verbs = { alc861vd_volume_init_verbs,
16939 alc861vd_3stack_init_verbs },
16940 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16941 .dac_nids = alc861vd_dac_nids,
16942 .dig_out_nid = ALC861VD_DIGOUT_NID,
16943 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16944 .channel_mode = alc861vd_3stack_2ch_modes,
16945 .input_mux = &alc861vd_capture_source,
16946 },
16947 [ALC861VD_6ST_DIG] = {
16948 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16949 .init_verbs = { alc861vd_volume_init_verbs,
16950 alc861vd_6stack_init_verbs },
16951 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16952 .dac_nids = alc861vd_dac_nids,
16953 .dig_out_nid = ALC861VD_DIGOUT_NID,
16954 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16955 .channel_mode = alc861vd_6stack_modes,
16956 .input_mux = &alc861vd_capture_source,
16957 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016958 [ALC861VD_LENOVO] = {
16959 .mixers = { alc861vd_lenovo_mixer },
16960 .init_verbs = { alc861vd_volume_init_verbs,
16961 alc861vd_3stack_init_verbs,
16962 alc861vd_eapd_verbs,
16963 alc861vd_lenovo_unsol_verbs },
16964 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16965 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016966 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16967 .channel_mode = alc861vd_3stack_2ch_modes,
16968 .input_mux = &alc861vd_capture_source,
16969 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016970 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016971 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016972 },
Kailang Yang272a5272007-05-14 11:00:38 +020016973 [ALC861VD_DALLAS] = {
16974 .mixers = { alc861vd_dallas_mixer },
16975 .init_verbs = { alc861vd_dallas_verbs },
16976 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16977 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016978 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16979 .channel_mode = alc861vd_3stack_2ch_modes,
16980 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016981 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016982 .setup = alc861vd_dallas_setup,
16983 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016984 },
16985 [ALC861VD_HP] = {
16986 .mixers = { alc861vd_hp_mixer },
16987 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16988 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16989 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016990 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016991 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16992 .channel_mode = alc861vd_3stack_2ch_modes,
16993 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016994 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016995 .setup = alc861vd_dallas_setup,
16996 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020016997 },
Takashi Iwai13c94742008-11-05 08:06:08 +010016998 [ALC660VD_ASUS_V1S] = {
16999 .mixers = { alc861vd_lenovo_mixer },
17000 .init_verbs = { alc861vd_volume_init_verbs,
17001 alc861vd_3stack_init_verbs,
17002 alc861vd_eapd_verbs,
17003 alc861vd_lenovo_unsol_verbs },
17004 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
17005 .dac_nids = alc660vd_dac_nids,
17006 .dig_out_nid = ALC861VD_DIGOUT_NID,
17007 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17008 .channel_mode = alc861vd_3stack_2ch_modes,
17009 .input_mux = &alc861vd_capture_source,
17010 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017011 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017012 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010017013 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017014};
17015
17016/*
17017 * BIOS auto configuration
17018 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017019static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
17020 const struct auto_pin_cfg *cfg)
17021{
Herton Ronaldo Krzesinski71675942010-11-25 00:08:01 -020017022 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x22, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020017023}
17024
17025
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017026static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
17027 hda_nid_t nid, int pin_type, int dac_idx)
17028{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017029 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017030}
17031
17032static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
17033{
17034 struct alc_spec *spec = codec->spec;
17035 int i;
17036
17037 for (i = 0; i <= HDA_SIDE; i++) {
17038 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017039 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017040 if (nid)
17041 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017042 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017043 }
17044}
17045
17046
17047static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
17048{
17049 struct alc_spec *spec = codec->spec;
17050 hda_nid_t pin;
17051
17052 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017053 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017054 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017055 pin = spec->autocfg.speaker_pins[0];
17056 if (pin)
17057 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017058}
17059
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017060#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
17061
17062static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
17063{
17064 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017065 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017066 int i;
17067
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017068 for (i = 0; i < cfg->num_inputs; i++) {
17069 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017070 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020017071 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +010017072 if (nid != ALC861VD_PIN_CD_NID &&
17073 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017074 snd_hda_codec_write(codec, nid, 0,
17075 AC_VERB_SET_AMP_GAIN_MUTE,
17076 AMP_OUT_MUTE);
17077 }
17078 }
17079}
17080
Takashi Iwaif511b012008-08-15 16:46:42 +020017081#define alc861vd_auto_init_input_src alc882_auto_init_input_src
17082
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017083#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
17084#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
17085
17086/* add playback controls from the parsed DAC table */
Takashi Iwai569ed342011-01-19 10:14:46 +010017087/* Based on ALC880 version. But ALC861VD has separate,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017088 * different NIDs for mute/unmute switch and volume control */
17089static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
17090 const struct auto_pin_cfg *cfg)
17091{
Takashi Iwaiea734962011-01-17 11:29:34 +010017092 static const char * const chname[4] = {
17093 "Front", "Surround", "CLFE", "Side"
17094 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017095 const char *pfx = alc_get_line_out_pfx(cfg, true);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017096 hda_nid_t nid_v, nid_s;
17097 int i, err;
17098
17099 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017100 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017101 continue;
17102 nid_v = alc861vd_idx_to_mixer_vol(
17103 alc880_dac_to_idx(
17104 spec->multiout.dac_nids[i]));
17105 nid_s = alc861vd_idx_to_mixer_switch(
17106 alc880_dac_to_idx(
17107 spec->multiout.dac_nids[i]));
17108
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017109 if (!pfx && i == 2) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017110 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017111 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17112 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017113 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
17114 HDA_OUTPUT));
17115 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017116 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017117 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17118 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017119 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
17120 HDA_OUTPUT));
17121 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017122 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017123 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17124 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017125 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
17126 HDA_INPUT));
17127 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017128 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017129 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17130 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017131 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
17132 HDA_INPUT));
17133 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017134 return err;
17135 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017136 const char *name = pfx;
17137 if (!name)
17138 name = chname[i];
17139 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17140 name, i,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017141 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
17142 HDA_OUTPUT));
17143 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017144 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017145 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17146 name, i,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017147 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017148 HDA_INPUT));
17149 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017150 return err;
17151 }
17152 }
17153 return 0;
17154}
17155
17156/* add playback controls for speaker and HP outputs */
17157/* Based on ALC880 version. But ALC861VD has separate,
17158 * different NIDs for mute/unmute switch and volume control */
17159static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
17160 hda_nid_t pin, const char *pfx)
17161{
17162 hda_nid_t nid_v, nid_s;
17163 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017164
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017165 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017166 return 0;
17167
17168 if (alc880_is_fixed_pin(pin)) {
17169 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17170 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017171 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017172 spec->multiout.hp_nid = nid_v;
17173 else
17174 spec->multiout.extra_out_nid[0] = nid_v;
17175 /* control HP volume/switch on the output mixer amp */
17176 nid_v = alc861vd_idx_to_mixer_vol(
17177 alc880_fixed_pin_idx(pin));
17178 nid_s = alc861vd_idx_to_mixer_switch(
17179 alc880_fixed_pin_idx(pin));
17180
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017181 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017182 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
17183 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017184 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017185 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017186 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
17187 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017188 return err;
17189 } else if (alc880_is_multi_pin(pin)) {
17190 /* set manual connection */
17191 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017192 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017193 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17194 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017195 return err;
17196 }
17197 return 0;
17198}
17199
17200/* parse the BIOS configuration and set up the alc_spec
17201 * return 1 if successful, 0 if the proper config is not found,
17202 * or a negative error code
17203 * Based on ALC880 version - had to change it to override
17204 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
17205static int alc861vd_parse_auto_config(struct hda_codec *codec)
17206{
17207 struct alc_spec *spec = codec->spec;
17208 int err;
17209 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
17210
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017211 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17212 alc861vd_ignore);
17213 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017214 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017215 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017216 return 0; /* can't find valid BIOS pin config */
17217
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017218 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17219 if (err < 0)
17220 return err;
17221 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
17222 if (err < 0)
17223 return err;
17224 err = alc861vd_auto_create_extra_out(spec,
17225 spec->autocfg.speaker_pins[0],
17226 "Speaker");
17227 if (err < 0)
17228 return err;
17229 err = alc861vd_auto_create_extra_out(spec,
17230 spec->autocfg.hp_pins[0],
17231 "Headphone");
17232 if (err < 0)
17233 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017234 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017235 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017236 return err;
17237
17238 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17239
Takashi Iwai757899a2010-07-30 10:48:14 +020017240 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017241
Takashi Iwai603c4012008-07-30 15:01:44 +020017242 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017243 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017244
Takashi Iwaid88897e2008-10-31 15:01:37 +010017245 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017246
17247 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017248 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017249
Takashi Iwai776e1842007-08-29 15:07:11 +020017250 err = alc_auto_add_mic_boost(codec);
17251 if (err < 0)
17252 return err;
17253
Kailang Yang6227cdc2010-02-25 08:36:52 +010017254 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017255
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017256 return 1;
17257}
17258
17259/* additional initialization for auto-configuration model */
17260static void alc861vd_auto_init(struct hda_codec *codec)
17261{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017262 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017263 alc861vd_auto_init_multi_out(codec);
17264 alc861vd_auto_init_hp_out(codec);
17265 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017266 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020017267 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017268 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017269 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017270}
17271
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017272enum {
17273 ALC660VD_FIX_ASUS_GPIO1
17274};
17275
17276/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017277static const struct alc_fixup alc861vd_fixups[] = {
17278 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017279 .type = ALC_FIXUP_VERBS,
17280 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020017281 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
17282 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
17283 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
17284 { }
17285 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017286 },
17287};
17288
17289static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
17290 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
17291 {}
17292};
17293
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017294static int patch_alc861vd(struct hda_codec *codec)
17295{
17296 struct alc_spec *spec;
17297 int err, board_config;
17298
17299 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17300 if (spec == NULL)
17301 return -ENOMEM;
17302
17303 codec->spec = spec;
17304
17305 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
17306 alc861vd_models,
17307 alc861vd_cfg_tbl);
17308
17309 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017310 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17311 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017312 board_config = ALC861VD_AUTO;
17313 }
17314
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017315 if (board_config == ALC861VD_AUTO) {
17316 alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
17317 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
17318 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017319
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017320 if (board_config == ALC861VD_AUTO) {
17321 /* automatic parse from the BIOS config */
17322 err = alc861vd_parse_auto_config(codec);
17323 if (err < 0) {
17324 alc_free(codec);
17325 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017326 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017327 printk(KERN_INFO
17328 "hda_codec: Cannot set up configuration "
17329 "from BIOS. Using base mode...\n");
17330 board_config = ALC861VD_3ST;
17331 }
17332 }
17333
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017334 err = snd_hda_attach_beep_device(codec, 0x23);
17335 if (err < 0) {
17336 alc_free(codec);
17337 return err;
17338 }
17339
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017340 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017341 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017342
Kailang Yang2f893282008-05-27 12:14:47 +020017343 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020017344 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010017345 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020017346 }
17347
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017348 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
17349 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
17350
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017351 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
17352 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
17353
Takashi Iwaidd704692009-08-11 08:45:11 +020017354 if (!spec->adc_nids) {
17355 spec->adc_nids = alc861vd_adc_nids;
17356 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
17357 }
17358 if (!spec->capsrc_nids)
17359 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017360
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017361 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010017362 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017363
Takashi Iwai2134ea42008-01-10 16:53:55 +010017364 spec->vmaster_nid = 0x02;
17365
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017366 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017367
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017368 codec->patch_ops = alc_patch_ops;
17369
17370 if (board_config == ALC861VD_AUTO)
17371 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017372#ifdef CONFIG_SND_HDA_POWER_SAVE
17373 if (!spec->loopback.amplist)
17374 spec->loopback.amplist = alc861vd_loopbacks;
17375#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017376
17377 return 0;
17378}
17379
17380/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017381 * ALC662 support
17382 *
17383 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
17384 * configuration. Each pin widget can choose any input DACs and a mixer.
17385 * Each ADC is connected from a mixer of all inputs. This makes possible
17386 * 6-channel independent captures.
17387 *
17388 * In addition, an independent DAC for the multi-playback (not used in this
17389 * driver yet).
17390 */
17391#define ALC662_DIGOUT_NID 0x06
17392#define ALC662_DIGIN_NID 0x0a
17393
17394static hda_nid_t alc662_dac_nids[4] = {
17395 /* front, rear, clfe, rear_surr */
17396 0x02, 0x03, 0x04
17397};
17398
Kailang Yang622e84c2009-04-21 07:39:04 +020017399static hda_nid_t alc272_dac_nids[2] = {
17400 0x02, 0x03
17401};
17402
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017403static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017404 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017405 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017406};
Takashi Iwaie1406342008-02-11 18:32:32 +010017407
Kailang Yang622e84c2009-04-21 07:39:04 +020017408static hda_nid_t alc272_adc_nids[1] = {
17409 /* ADC1-2 */
17410 0x08,
17411};
17412
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017413static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020017414static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
17415
Takashi Iwaie1406342008-02-11 18:32:32 +010017416
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017417/* input MUX */
17418/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017419static struct hda_input_mux alc662_capture_source = {
17420 .num_items = 4,
17421 .items = {
17422 { "Mic", 0x0 },
17423 { "Front Mic", 0x1 },
17424 { "Line", 0x2 },
17425 { "CD", 0x4 },
17426 },
17427};
17428
17429static struct hda_input_mux alc662_lenovo_101e_capture_source = {
17430 .num_items = 2,
17431 .items = {
17432 { "Mic", 0x1 },
17433 { "Line", 0x2 },
17434 },
17435};
Kailang Yang291702f2007-10-16 14:28:03 +020017436
Kailang Yang6dda9f42008-05-27 12:05:31 +020017437static struct hda_input_mux alc663_capture_source = {
17438 .num_items = 3,
17439 .items = {
17440 { "Mic", 0x0 },
17441 { "Front Mic", 0x1 },
17442 { "Line", 0x2 },
17443 },
17444};
17445
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017446#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020017447static struct hda_input_mux alc272_nc10_capture_source = {
17448 .num_items = 16,
17449 .items = {
17450 { "Autoselect Mic", 0x0 },
17451 { "Internal Mic", 0x1 },
17452 { "In-0x02", 0x2 },
17453 { "In-0x03", 0x3 },
17454 { "In-0x04", 0x4 },
17455 { "In-0x05", 0x5 },
17456 { "In-0x06", 0x6 },
17457 { "In-0x07", 0x7 },
17458 { "In-0x08", 0x8 },
17459 { "In-0x09", 0x9 },
17460 { "In-0x0a", 0x0a },
17461 { "In-0x0b", 0x0b },
17462 { "In-0x0c", 0x0c },
17463 { "In-0x0d", 0x0d },
17464 { "In-0x0e", 0x0e },
17465 { "In-0x0f", 0x0f },
17466 },
17467};
17468#endif
17469
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017470/*
17471 * 2ch mode
17472 */
17473static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17474 { 2, NULL }
17475};
17476
17477/*
17478 * 2ch mode
17479 */
17480static struct hda_verb alc662_3ST_ch2_init[] = {
17481 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17482 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17483 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17484 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17485 { } /* end */
17486};
17487
17488/*
17489 * 6ch mode
17490 */
17491static struct hda_verb alc662_3ST_ch6_init[] = {
17492 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17493 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17494 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17495 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17496 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17497 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17498 { } /* end */
17499};
17500
17501static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17502 { 2, alc662_3ST_ch2_init },
17503 { 6, alc662_3ST_ch6_init },
17504};
17505
17506/*
17507 * 2ch mode
17508 */
17509static struct hda_verb alc662_sixstack_ch6_init[] = {
17510 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17511 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17512 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17513 { } /* end */
17514};
17515
17516/*
17517 * 6ch mode
17518 */
17519static struct hda_verb alc662_sixstack_ch8_init[] = {
17520 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17521 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17522 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17523 { } /* end */
17524};
17525
17526static struct hda_channel_mode alc662_5stack_modes[2] = {
17527 { 2, alc662_sixstack_ch6_init },
17528 { 6, alc662_sixstack_ch8_init },
17529};
17530
17531/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17532 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17533 */
17534
17535static struct snd_kcontrol_new alc662_base_mixer[] = {
17536 /* output mixer control */
17537 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017538 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017539 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017540 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017541 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17542 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017543 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17544 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017545 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17546
17547 /*Input mixer control */
17548 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17549 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17550 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17551 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17552 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17553 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17554 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17555 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017556 { } /* end */
17557};
17558
17559static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17560 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017561 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017562 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17563 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17564 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17565 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17566 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17567 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17568 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17569 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17570 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017571 { } /* end */
17572};
17573
17574static struct snd_kcontrol_new alc662_3ST_6ch_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_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017578 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017579 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17580 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017581 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17582 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017583 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17584 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17585 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17586 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17587 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17588 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17589 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17590 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17591 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017592 { } /* end */
17593};
17594
17595static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17596 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17597 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017598 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17599 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017600 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
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, 0x1, HDA_INPUT),
17604 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017605 { } /* end */
17606};
17607
Kailang Yang291702f2007-10-16 14:28:03 +020017608static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017609 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17610 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017611
David Henningsson5f99f862011-01-04 15:24:24 +010017612 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017613 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17614 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017615
David Henningsson5f99f862011-01-04 15:24:24 +010017616 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017617 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17618 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017619 { } /* end */
17620};
17621
Kailang Yang8c427222008-01-10 13:03:59 +010017622static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017623 ALC262_HIPPO_MASTER_SWITCH,
17624 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017625 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017626 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17627 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017628 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17629 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17630 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17631 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17632 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17633 { } /* end */
17634};
17635
Kailang Yangf1d4e282008-08-26 14:03:29 +020017636static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17637 .ops = &snd_hda_bind_vol,
17638 .values = {
17639 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17640 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17641 0
17642 },
17643};
17644
17645static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17646 .ops = &snd_hda_bind_sw,
17647 .values = {
17648 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17649 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17650 0
17651 },
17652};
17653
Kailang Yang6dda9f42008-05-27 12:05:31 +020017654static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017655 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17656 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17657 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17658 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17659 { } /* end */
17660};
17661
17662static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17663 .ops = &snd_hda_bind_sw,
17664 .values = {
17665 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17666 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17667 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17668 0
17669 },
17670};
17671
17672static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17673 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17674 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17675 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17676 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17677 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17678 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17679
17680 { } /* end */
17681};
17682
17683static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17684 .ops = &snd_hda_bind_sw,
17685 .values = {
17686 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17687 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17688 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17689 0
17690 },
17691};
17692
17693static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17694 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17695 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17696 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17697 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17698 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17699 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17700 { } /* end */
17701};
17702
17703static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017704 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17705 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017706 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17709 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17710 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17711 { } /* end */
17712};
17713
17714static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17715 .ops = &snd_hda_bind_vol,
17716 .values = {
17717 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17718 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17719 0
17720 },
17721};
17722
17723static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17724 .ops = &snd_hda_bind_sw,
17725 .values = {
17726 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17727 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17728 0
17729 },
17730};
17731
17732static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17733 HDA_BIND_VOL("Master Playback Volume",
17734 &alc663_asus_two_bind_master_vol),
17735 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17736 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017737 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17738 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17739 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017740 { } /* end */
17741};
17742
17743static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17744 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17745 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17746 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17747 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17748 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17749 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017750 { } /* end */
17751};
17752
17753static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17754 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17755 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17756 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17757 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17758 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17759
17760 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17761 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017762 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17763 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017764 { } /* end */
17765};
17766
17767static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17768 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17769 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17770 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17771
17772 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17773 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017774 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17775 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017776 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17777 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17778 { } /* end */
17779};
17780
Kailang Yangebb83ee2009-12-17 12:23:00 +010017781static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17782 .ops = &snd_hda_bind_sw,
17783 .values = {
17784 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17785 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17786 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17787 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17788 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17789 0
17790 },
17791};
17792
17793static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17794 .ops = &snd_hda_bind_sw,
17795 .values = {
17796 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17797 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17798 0
17799 },
17800};
17801
17802static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17803 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17804 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17805 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17806 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17807 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17808 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17809 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17810 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17811 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17812 { } /* end */
17813};
17814
17815static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17816 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17817 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17818 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17819 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17820 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17821 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17822 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17823 { } /* end */
17824};
17825
17826
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017827static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17828 {
17829 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17830 .name = "Channel Mode",
17831 .info = alc_ch_mode_info,
17832 .get = alc_ch_mode_get,
17833 .put = alc_ch_mode_put,
17834 },
17835 { } /* end */
17836};
17837
17838static struct hda_verb alc662_init_verbs[] = {
17839 /* ADC: mute amp left and right */
17840 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17841 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017842
Kailang Yangb60dd392007-09-20 12:50:29 +020017843 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17844 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17845 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17846 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17847 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17848 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017849
17850 /* Front Pin: output 0 (0x0c) */
17851 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17852 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17853
17854 /* Rear Pin: output 1 (0x0d) */
17855 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17856 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17857
17858 /* CLFE Pin: output 2 (0x0e) */
17859 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17860 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17861
17862 /* Mic (rear) pin: input vref at 80% */
17863 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17864 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17865 /* Front Mic pin: input vref at 80% */
17866 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17867 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17868 /* Line In pin: input */
17869 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17870 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17871 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17872 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17873 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17874 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17875 /* CD pin widget for input */
17876 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17877
17878 /* FIXME: use matrix-type input source selection */
17879 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17880 /* Input mixer */
17881 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017882 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017883
17884 /* always trun on EAPD */
17885 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17886 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17887
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017888 { }
17889};
17890
Kailang Yangcec27c82010-02-04 14:18:18 +010017891static struct hda_verb alc663_init_verbs[] = {
17892 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17893 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17894 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17895 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17896 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17897 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17898 { }
17899};
17900
17901static struct hda_verb alc272_init_verbs[] = {
17902 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17903 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17904 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17905 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17906 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17907 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17908 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17909 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17910 { }
17911};
17912
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017913static struct hda_verb alc662_sue_init_verbs[] = {
17914 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17915 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017916 {}
17917};
17918
17919static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17920 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17921 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17922 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017923};
17924
Kailang Yang8c427222008-01-10 13:03:59 +010017925/* Set Unsolicited Event*/
17926static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17927 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17928 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17929 {}
17930};
17931
Kailang Yang6dda9f42008-05-27 12:05:31 +020017932static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017933 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17934 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017935 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17936 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017937 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17938 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17939 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017940 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17941 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17942 {}
17943};
17944
Kailang Yangf1d4e282008-08-26 14:03:29 +020017945static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17946 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17947 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17948 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17949 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17950 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17951 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17952 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17953 {}
17954};
17955
17956static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17957 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17958 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17959 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17960 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17961 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17962 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17963 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17964 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17965 {}
17966};
17967
17968static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17969 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17970 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17971 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17972 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17973 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17974 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17975 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17976 {}
17977};
17978
17979static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17980 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17981 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17982 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17983 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
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, 0x0}, /* 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 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17991 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17992 {}
17993};
17994
17995static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
17996 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17997 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17998 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17999 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18000 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18001 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18002 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18003 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18004 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18005 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18006 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18007 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18008 {}
18009};
18010
Kailang Yang6dda9f42008-05-27 12:05:31 +020018011static struct hda_verb alc663_g71v_init_verbs[] = {
18012 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18013 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
18014 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
18015
18016 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18017 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18018 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18019
18020 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
18021 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
18022 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
18023 {}
18024};
18025
18026static struct hda_verb alc663_g50v_init_verbs[] = {
18027 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18028 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18029 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18030
18031 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18032 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18033 {}
18034};
18035
Kailang Yangf1d4e282008-08-26 14:03:29 +020018036static struct hda_verb alc662_ecs_init_verbs[] = {
18037 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
18038 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18039 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18040 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18041 {}
18042};
18043
Kailang Yang622e84c2009-04-21 07:39:04 +020018044static struct hda_verb alc272_dell_zm1_init_verbs[] = {
18045 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18046 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18047 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18048 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18049 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18050 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18051 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18052 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18053 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18054 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18055 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18056 {}
18057};
18058
18059static struct hda_verb alc272_dell_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 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18068 {0x23, 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
Kailang Yangebb83ee2009-12-17 12:23:00 +010018074static struct hda_verb alc663_mode7_init_verbs[] = {
18075 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18076 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18077 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18078 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18079 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18080 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18081 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
18082 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18083 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18084 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18085 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18086 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18087 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18088 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18089 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18090 {}
18091};
18092
18093static struct hda_verb alc663_mode8_init_verbs[] = {
18094 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18095 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18096 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18097 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
18098 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18099 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18100 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18101 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18102 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18103 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18104 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18105 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18106 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18107 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18108 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18109 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18110 {}
18111};
18112
Kailang Yangf1d4e282008-08-26 14:03:29 +020018113static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
18114 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
18115 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
18116 { } /* end */
18117};
18118
Kailang Yang622e84c2009-04-21 07:39:04 +020018119static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
18120 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
18121 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
18122 { } /* end */
18123};
18124
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018125static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
18126{
18127 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018128 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018129
Wu Fengguang864f92b2009-11-18 12:38:02 +080018130 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018131 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018132
Takashi Iwai47fd8302007-08-10 17:11:07 +020018133 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18134 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018135}
18136
18137static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
18138{
18139 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018140 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018141
Wu Fengguang864f92b2009-11-18 12:38:02 +080018142 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018143 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018144
Takashi Iwai47fd8302007-08-10 17:11:07 +020018145 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18146 HDA_AMP_MUTE, bits);
18147 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18148 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018149}
18150
18151static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
18152 unsigned int res)
18153{
18154 if ((res >> 26) == ALC880_HP_EVENT)
18155 alc662_lenovo_101e_all_automute(codec);
18156 if ((res >> 26) == ALC880_FRONT_EVENT)
18157 alc662_lenovo_101e_ispeaker_automute(codec);
18158}
18159
Kailang Yang291702f2007-10-16 14:28:03 +020018160/* unsolicited event for HP jack sensing */
18161static void alc662_eeepc_unsol_event(struct hda_codec *codec,
18162 unsigned int res)
18163{
Kailang Yang291702f2007-10-16 14:28:03 +020018164 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018165 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020018166 else
18167 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020018168}
18169
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018170static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020018171{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018172 struct alc_spec *spec = codec->spec;
18173
18174 alc262_hippo1_setup(codec);
18175 spec->ext_mic.pin = 0x18;
18176 spec->ext_mic.mux_idx = 0;
18177 spec->int_mic.pin = 0x19;
18178 spec->int_mic.mux_idx = 1;
18179 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020018180}
18181
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018182static void alc662_eeepc_inithook(struct hda_codec *codec)
18183{
18184 alc262_hippo_automute(codec);
18185 alc_mic_automute(codec);
18186}
18187
18188static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010018189{
Takashi Iwai42171c12009-05-08 14:11:43 +020018190 struct alc_spec *spec = codec->spec;
18191
18192 spec->autocfg.hp_pins[0] = 0x14;
18193 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010018194}
18195
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018196#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
18197
Kailang Yang6dda9f42008-05-27 12:05:31 +020018198static void alc663_m51va_speaker_automute(struct hda_codec *codec)
18199{
18200 unsigned int present;
18201 unsigned char bits;
18202
Wu Fengguang864f92b2009-11-18 12:38:02 +080018203 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018204 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018205 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018206 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018207 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018208 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018209}
18210
18211static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
18212{
18213 unsigned int present;
18214 unsigned char bits;
18215
Wu Fengguang864f92b2009-11-18 12:38:02 +080018216 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018217 bits = present ? HDA_AMP_MUTE : 0;
18218 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018219 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018220 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
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, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018223 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018224 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018225 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018226}
18227
18228static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
18229{
18230 unsigned int present;
18231 unsigned char bits;
18232
Wu Fengguang864f92b2009-11-18 12:38:02 +080018233 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018234 bits = present ? HDA_AMP_MUTE : 0;
18235 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
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, 0x0c, HDA_INPUT, 1,
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, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018240 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018241 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018242 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018243}
18244
18245static void alc662_f5z_speaker_automute(struct hda_codec *codec)
18246{
18247 unsigned int present;
18248 unsigned char bits;
18249
Wu Fengguang864f92b2009-11-18 12:38:02 +080018250 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018251 bits = present ? 0 : PIN_OUT;
18252 snd_hda_codec_write(codec, 0x14, 0,
18253 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
18254}
18255
18256static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
18257{
18258 unsigned int present1, present2;
18259
Wu Fengguang864f92b2009-11-18 12:38:02 +080018260 present1 = snd_hda_jack_detect(codec, 0x21);
18261 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018262
18263 if (present1 || present2) {
18264 snd_hda_codec_write_cache(codec, 0x14, 0,
18265 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18266 } else {
18267 snd_hda_codec_write_cache(codec, 0x14, 0,
18268 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18269 }
18270}
18271
18272static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
18273{
18274 unsigned int present1, present2;
18275
Wu Fengguang864f92b2009-11-18 12:38:02 +080018276 present1 = snd_hda_jack_detect(codec, 0x1b);
18277 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018278
18279 if (present1 || present2) {
18280 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018281 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018282 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018283 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018284 } else {
18285 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018286 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018287 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018288 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018289 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020018290}
18291
Kailang Yangebb83ee2009-12-17 12:23:00 +010018292static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
18293{
18294 unsigned int present1, present2;
18295
18296 present1 = snd_hda_codec_read(codec, 0x1b, 0,
18297 AC_VERB_GET_PIN_SENSE, 0)
18298 & AC_PINSENSE_PRESENCE;
18299 present2 = snd_hda_codec_read(codec, 0x21, 0,
18300 AC_VERB_GET_PIN_SENSE, 0)
18301 & AC_PINSENSE_PRESENCE;
18302
18303 if (present1 || present2) {
18304 snd_hda_codec_write_cache(codec, 0x14, 0,
18305 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18306 snd_hda_codec_write_cache(codec, 0x17, 0,
18307 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18308 } else {
18309 snd_hda_codec_write_cache(codec, 0x14, 0,
18310 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18311 snd_hda_codec_write_cache(codec, 0x17, 0,
18312 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18313 }
18314}
18315
18316static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
18317{
18318 unsigned int present1, present2;
18319
18320 present1 = snd_hda_codec_read(codec, 0x21, 0,
18321 AC_VERB_GET_PIN_SENSE, 0)
18322 & AC_PINSENSE_PRESENCE;
18323 present2 = snd_hda_codec_read(codec, 0x15, 0,
18324 AC_VERB_GET_PIN_SENSE, 0)
18325 & AC_PINSENSE_PRESENCE;
18326
18327 if (present1 || present2) {
18328 snd_hda_codec_write_cache(codec, 0x14, 0,
18329 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18330 snd_hda_codec_write_cache(codec, 0x17, 0,
18331 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18332 } else {
18333 snd_hda_codec_write_cache(codec, 0x14, 0,
18334 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18335 snd_hda_codec_write_cache(codec, 0x17, 0,
18336 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18337 }
18338}
18339
Kailang Yang6dda9f42008-05-27 12:05:31 +020018340static void alc663_m51va_unsol_event(struct hda_codec *codec,
18341 unsigned int res)
18342{
18343 switch (res >> 26) {
18344 case ALC880_HP_EVENT:
18345 alc663_m51va_speaker_automute(codec);
18346 break;
18347 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018348 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018349 break;
18350 }
18351}
18352
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018353static void alc663_m51va_setup(struct hda_codec *codec)
18354{
18355 struct alc_spec *spec = codec->spec;
18356 spec->ext_mic.pin = 0x18;
18357 spec->ext_mic.mux_idx = 0;
18358 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018359 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018360 spec->auto_mic = 1;
18361}
18362
Kailang Yang6dda9f42008-05-27 12:05:31 +020018363static void alc663_m51va_inithook(struct hda_codec *codec)
18364{
18365 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018366 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018367}
18368
Kailang Yangf1d4e282008-08-26 14:03:29 +020018369/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018370#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010018371
18372static void alc663_mode1_setup(struct hda_codec *codec)
18373{
18374 struct alc_spec *spec = codec->spec;
18375 spec->ext_mic.pin = 0x18;
18376 spec->ext_mic.mux_idx = 0;
18377 spec->int_mic.pin = 0x19;
18378 spec->int_mic.mux_idx = 1;
18379 spec->auto_mic = 1;
18380}
18381
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018382#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020018383
Kailang Yangf1d4e282008-08-26 14:03:29 +020018384/* ***************** Mode2 ******************************/
18385static void alc662_mode2_unsol_event(struct hda_codec *codec,
18386 unsigned int res)
18387{
18388 switch (res >> 26) {
18389 case ALC880_HP_EVENT:
18390 alc662_f5z_speaker_automute(codec);
18391 break;
18392 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018393 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018394 break;
18395 }
18396}
18397
Kailang Yangebb83ee2009-12-17 12:23:00 +010018398#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018399
Kailang Yangf1d4e282008-08-26 14:03:29 +020018400static void alc662_mode2_inithook(struct hda_codec *codec)
18401{
18402 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018403 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018404}
18405/* ***************** Mode3 ******************************/
18406static void alc663_mode3_unsol_event(struct hda_codec *codec,
18407 unsigned int res)
18408{
18409 switch (res >> 26) {
18410 case ALC880_HP_EVENT:
18411 alc663_two_hp_m1_speaker_automute(codec);
18412 break;
18413 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018414 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018415 break;
18416 }
18417}
18418
Kailang Yangebb83ee2009-12-17 12:23:00 +010018419#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018420
Kailang Yangf1d4e282008-08-26 14:03:29 +020018421static void alc663_mode3_inithook(struct hda_codec *codec)
18422{
18423 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018424 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018425}
18426/* ***************** Mode4 ******************************/
18427static void alc663_mode4_unsol_event(struct hda_codec *codec,
18428 unsigned int res)
18429{
18430 switch (res >> 26) {
18431 case ALC880_HP_EVENT:
18432 alc663_21jd_two_speaker_automute(codec);
18433 break;
18434 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018435 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018436 break;
18437 }
18438}
18439
Kailang Yangebb83ee2009-12-17 12:23:00 +010018440#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018441
Kailang Yangf1d4e282008-08-26 14:03:29 +020018442static void alc663_mode4_inithook(struct hda_codec *codec)
18443{
18444 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018445 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018446}
18447/* ***************** Mode5 ******************************/
18448static void alc663_mode5_unsol_event(struct hda_codec *codec,
18449 unsigned int res)
18450{
18451 switch (res >> 26) {
18452 case ALC880_HP_EVENT:
18453 alc663_15jd_two_speaker_automute(codec);
18454 break;
18455 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018456 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018457 break;
18458 }
18459}
18460
Kailang Yangebb83ee2009-12-17 12:23:00 +010018461#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018462
Kailang Yangf1d4e282008-08-26 14:03:29 +020018463static void alc663_mode5_inithook(struct hda_codec *codec)
18464{
18465 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018466 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018467}
18468/* ***************** Mode6 ******************************/
18469static void alc663_mode6_unsol_event(struct hda_codec *codec,
18470 unsigned int res)
18471{
18472 switch (res >> 26) {
18473 case ALC880_HP_EVENT:
18474 alc663_two_hp_m2_speaker_automute(codec);
18475 break;
18476 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018477 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018478 break;
18479 }
18480}
18481
Kailang Yangebb83ee2009-12-17 12:23:00 +010018482#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018483
Kailang Yangf1d4e282008-08-26 14:03:29 +020018484static void alc663_mode6_inithook(struct hda_codec *codec)
18485{
18486 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018487 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018488}
18489
Kailang Yangebb83ee2009-12-17 12:23:00 +010018490/* ***************** Mode7 ******************************/
18491static void alc663_mode7_unsol_event(struct hda_codec *codec,
18492 unsigned int res)
18493{
18494 switch (res >> 26) {
18495 case ALC880_HP_EVENT:
18496 alc663_two_hp_m7_speaker_automute(codec);
18497 break;
18498 case ALC880_MIC_EVENT:
18499 alc_mic_automute(codec);
18500 break;
18501 }
18502}
18503
18504#define alc663_mode7_setup alc663_mode1_setup
18505
18506static void alc663_mode7_inithook(struct hda_codec *codec)
18507{
18508 alc663_two_hp_m7_speaker_automute(codec);
18509 alc_mic_automute(codec);
18510}
18511
18512/* ***************** Mode8 ******************************/
18513static void alc663_mode8_unsol_event(struct hda_codec *codec,
18514 unsigned int res)
18515{
18516 switch (res >> 26) {
18517 case ALC880_HP_EVENT:
18518 alc663_two_hp_m8_speaker_automute(codec);
18519 break;
18520 case ALC880_MIC_EVENT:
18521 alc_mic_automute(codec);
18522 break;
18523 }
18524}
18525
18526#define alc663_mode8_setup alc663_m51va_setup
18527
18528static void alc663_mode8_inithook(struct hda_codec *codec)
18529{
18530 alc663_two_hp_m8_speaker_automute(codec);
18531 alc_mic_automute(codec);
18532}
18533
Kailang Yang6dda9f42008-05-27 12:05:31 +020018534static void alc663_g71v_hp_automute(struct hda_codec *codec)
18535{
18536 unsigned int present;
18537 unsigned char bits;
18538
Wu Fengguang864f92b2009-11-18 12:38:02 +080018539 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018540 bits = present ? HDA_AMP_MUTE : 0;
18541 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18542 HDA_AMP_MUTE, bits);
18543 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18544 HDA_AMP_MUTE, bits);
18545}
18546
18547static void alc663_g71v_front_automute(struct hda_codec *codec)
18548{
18549 unsigned int present;
18550 unsigned char bits;
18551
Wu Fengguang864f92b2009-11-18 12:38:02 +080018552 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018553 bits = present ? HDA_AMP_MUTE : 0;
18554 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18555 HDA_AMP_MUTE, bits);
18556}
18557
18558static void alc663_g71v_unsol_event(struct hda_codec *codec,
18559 unsigned int res)
18560{
18561 switch (res >> 26) {
18562 case ALC880_HP_EVENT:
18563 alc663_g71v_hp_automute(codec);
18564 break;
18565 case ALC880_FRONT_EVENT:
18566 alc663_g71v_front_automute(codec);
18567 break;
18568 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018569 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018570 break;
18571 }
18572}
18573
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018574#define alc663_g71v_setup alc663_m51va_setup
18575
Kailang Yang6dda9f42008-05-27 12:05:31 +020018576static void alc663_g71v_inithook(struct hda_codec *codec)
18577{
18578 alc663_g71v_front_automute(codec);
18579 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018580 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018581}
18582
18583static void alc663_g50v_unsol_event(struct hda_codec *codec,
18584 unsigned int res)
18585{
18586 switch (res >> 26) {
18587 case ALC880_HP_EVENT:
18588 alc663_m51va_speaker_automute(codec);
18589 break;
18590 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018591 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018592 break;
18593 }
18594}
18595
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018596#define alc663_g50v_setup alc663_m51va_setup
18597
Kailang Yang6dda9f42008-05-27 12:05:31 +020018598static void alc663_g50v_inithook(struct hda_codec *codec)
18599{
18600 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018601 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018602}
18603
Kailang Yangf1d4e282008-08-26 14:03:29 +020018604static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18605 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018606 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018607
David Henningsson5f99f862011-01-04 15:24:24 +010018608 HDA_CODEC_VOLUME("Mic/LineIn Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018609 HDA_CODEC_VOLUME("Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18610 HDA_CODEC_MUTE("Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018611
David Henningsson5f99f862011-01-04 15:24:24 +010018612 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018613 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18614 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018615 { } /* end */
18616};
18617
Chris Pockelé9541ba12009-05-12 08:08:53 +020018618static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18619 /* Master Playback automatically created from Speaker and Headphone */
18620 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18621 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18622 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18623 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18624
David Henningsson8607f7c2010-12-20 14:43:54 +010018625 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18626 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018627 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018628
David Henningsson28c4edb2010-12-20 14:24:29 +010018629 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18630 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018631 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018632 { } /* end */
18633};
18634
Takashi Iwaicb53c622007-08-10 17:21:45 +020018635#ifdef CONFIG_SND_HDA_POWER_SAVE
18636#define alc662_loopbacks alc880_loopbacks
18637#endif
18638
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018639
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018640/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018641#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18642#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18643#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18644#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18645
18646/*
18647 * configuration and preset
18648 */
Takashi Iwaiea734962011-01-17 11:29:34 +010018649static const char * const alc662_models[ALC662_MODEL_LAST] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018650 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18651 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18652 [ALC662_3ST_6ch] = "3stack-6ch",
18653 [ALC662_5ST_DIG] = "6stack-dig",
18654 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018655 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018656 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018657 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018658 [ALC663_ASUS_M51VA] = "m51va",
18659 [ALC663_ASUS_G71V] = "g71v",
18660 [ALC663_ASUS_H13] = "h13",
18661 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018662 [ALC663_ASUS_MODE1] = "asus-mode1",
18663 [ALC662_ASUS_MODE2] = "asus-mode2",
18664 [ALC663_ASUS_MODE3] = "asus-mode3",
18665 [ALC663_ASUS_MODE4] = "asus-mode4",
18666 [ALC663_ASUS_MODE5] = "asus-mode5",
18667 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018668 [ALC663_ASUS_MODE7] = "asus-mode7",
18669 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018670 [ALC272_DELL] = "dell",
18671 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018672 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018673 [ALC662_AUTO] = "auto",
18674};
18675
18676static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018677 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018678 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18679 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018680 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18681 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018682 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018683 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18684 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18685 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18686 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018687 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18688 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018689 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018690 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18691 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18692 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18693 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18694 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018695 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018696 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18697 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018698 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18699 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18700 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18701 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018702 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018703 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18704 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18705 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018706 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18707 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18708 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18709 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018710 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018711 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18712 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018713 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018714 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18715 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18716 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018717 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018718 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018719 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18720 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018721 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18722 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18723 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018724 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018725 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18726 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018727 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018728 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018729 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018730 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18731 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18732 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018733 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018734 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18735 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018736 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018737 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018738 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018739 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018740 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18741 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018742 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018743 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018744 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18745 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018746 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018747 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018748 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018749 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018750 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018751 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018752 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18753 ALC663_ASUS_H13),
Anisse Astier965b76d2011-02-10 13:14:44 +010018754 SND_PCI_QUIRK(0x1991, 0x5628, "Ordissimo EVE", ALC662_LENOVO_101E),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018755 {}
18756};
18757
18758static struct alc_config_preset alc662_presets[] = {
18759 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018760 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018761 .init_verbs = { alc662_init_verbs },
18762 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18763 .dac_nids = alc662_dac_nids,
18764 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018765 .dig_in_nid = ALC662_DIGIN_NID,
18766 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18767 .channel_mode = alc662_3ST_2ch_modes,
18768 .input_mux = &alc662_capture_source,
18769 },
18770 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018771 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018772 .init_verbs = { alc662_init_verbs },
18773 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18774 .dac_nids = alc662_dac_nids,
18775 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018776 .dig_in_nid = ALC662_DIGIN_NID,
18777 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18778 .channel_mode = alc662_3ST_6ch_modes,
18779 .need_dac_fix = 1,
18780 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018781 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018782 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018783 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018784 .init_verbs = { alc662_init_verbs },
18785 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18786 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018787 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18788 .channel_mode = alc662_3ST_6ch_modes,
18789 .need_dac_fix = 1,
18790 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018791 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018792 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018793 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018794 .init_verbs = { alc662_init_verbs },
18795 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18796 .dac_nids = alc662_dac_nids,
18797 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018798 .dig_in_nid = ALC662_DIGIN_NID,
18799 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18800 .channel_mode = alc662_5stack_modes,
18801 .input_mux = &alc662_capture_source,
18802 },
18803 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018804 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018805 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18806 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18807 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018808 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18809 .channel_mode = alc662_3ST_2ch_modes,
18810 .input_mux = &alc662_lenovo_101e_capture_source,
18811 .unsol_event = alc662_lenovo_101e_unsol_event,
18812 .init_hook = alc662_lenovo_101e_all_automute,
18813 },
Kailang Yang291702f2007-10-16 14:28:03 +020018814 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018815 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018816 .init_verbs = { alc662_init_verbs,
18817 alc662_eeepc_sue_init_verbs },
18818 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18819 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018820 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18821 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018822 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018823 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018824 .init_hook = alc662_eeepc_inithook,
18825 },
Kailang Yang8c427222008-01-10 13:03:59 +010018826 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018827 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018828 alc662_chmode_mixer },
18829 .init_verbs = { alc662_init_verbs,
18830 alc662_eeepc_ep20_sue_init_verbs },
18831 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18832 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018833 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18834 .channel_mode = alc662_3ST_6ch_modes,
18835 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018836 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018837 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018838 .init_hook = alc662_eeepc_ep20_inithook,
18839 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018840 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018841 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018842 .init_verbs = { alc662_init_verbs,
18843 alc662_ecs_init_verbs },
18844 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18845 .dac_nids = alc662_dac_nids,
18846 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18847 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018848 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018849 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018850 .init_hook = alc662_eeepc_inithook,
18851 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018852 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018853 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018854 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18855 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18856 .dac_nids = alc662_dac_nids,
18857 .dig_out_nid = ALC662_DIGOUT_NID,
18858 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18859 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018860 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018861 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018862 .init_hook = alc663_m51va_inithook,
18863 },
18864 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018865 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018866 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18867 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18868 .dac_nids = alc662_dac_nids,
18869 .dig_out_nid = ALC662_DIGOUT_NID,
18870 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18871 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018872 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018873 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018874 .init_hook = alc663_g71v_inithook,
18875 },
18876 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018877 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018878 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18879 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18880 .dac_nids = alc662_dac_nids,
18881 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18882 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018883 .unsol_event = alc663_m51va_unsol_event,
18884 .init_hook = alc663_m51va_inithook,
18885 },
18886 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018887 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018888 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18889 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18890 .dac_nids = alc662_dac_nids,
18891 .dig_out_nid = ALC662_DIGOUT_NID,
18892 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18893 .channel_mode = alc662_3ST_6ch_modes,
18894 .input_mux = &alc663_capture_source,
18895 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018896 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018897 .init_hook = alc663_g50v_inithook,
18898 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018899 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018900 .mixers = { alc663_m51va_mixer },
18901 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018902 .init_verbs = { alc662_init_verbs,
18903 alc663_21jd_amic_init_verbs },
18904 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18905 .hp_nid = 0x03,
18906 .dac_nids = alc662_dac_nids,
18907 .dig_out_nid = ALC662_DIGOUT_NID,
18908 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18909 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018910 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018911 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018912 .init_hook = alc663_mode1_inithook,
18913 },
18914 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018915 .mixers = { alc662_1bjd_mixer },
18916 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018917 .init_verbs = { alc662_init_verbs,
18918 alc662_1bjd_amic_init_verbs },
18919 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18920 .dac_nids = alc662_dac_nids,
18921 .dig_out_nid = ALC662_DIGOUT_NID,
18922 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18923 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018924 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018925 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018926 .init_hook = alc662_mode2_inithook,
18927 },
18928 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018929 .mixers = { alc663_two_hp_m1_mixer },
18930 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018931 .init_verbs = { alc662_init_verbs,
18932 alc663_two_hp_amic_m1_init_verbs },
18933 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18934 .hp_nid = 0x03,
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 = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018940 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018941 .init_hook = alc663_mode3_inithook,
18942 },
18943 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018944 .mixers = { alc663_asus_21jd_clfe_mixer },
18945 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018946 .init_verbs = { alc662_init_verbs,
18947 alc663_21jd_amic_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_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018955 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018956 .init_hook = alc663_mode4_inithook,
18957 },
18958 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018959 .mixers = { alc663_asus_15jd_clfe_mixer },
18960 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018961 .init_verbs = { alc662_init_verbs,
18962 alc663_15jd_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_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018970 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018971 .init_hook = alc663_mode5_inithook,
18972 },
18973 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018974 .mixers = { alc663_two_hp_m2_mixer },
18975 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018976 .init_verbs = { alc662_init_verbs,
18977 alc663_two_hp_amic_m2_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_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018985 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018986 .init_hook = alc663_mode6_inithook,
18987 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018988 [ALC663_ASUS_MODE7] = {
18989 .mixers = { alc663_mode7_mixer },
18990 .cap_mixer = alc662_auto_capture_mixer,
18991 .init_verbs = { alc662_init_verbs,
18992 alc663_mode7_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,
18999 .unsol_event = alc663_mode7_unsol_event,
19000 .setup = alc663_mode7_setup,
19001 .init_hook = alc663_mode7_inithook,
19002 },
19003 [ALC663_ASUS_MODE8] = {
19004 .mixers = { alc663_mode8_mixer },
19005 .cap_mixer = alc662_auto_capture_mixer,
19006 .init_verbs = { alc662_init_verbs,
19007 alc663_mode8_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_mode8_unsol_event,
19015 .setup = alc663_mode8_setup,
19016 .init_hook = alc663_mode8_inithook,
19017 },
Kailang Yang622e84c2009-04-21 07:39:04 +020019018 [ALC272_DELL] = {
19019 .mixers = { alc663_m51va_mixer },
19020 .cap_mixer = alc272_auto_capture_mixer,
19021 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
19022 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19023 .dac_nids = alc662_dac_nids,
19024 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19025 .adc_nids = alc272_adc_nids,
19026 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
19027 .capsrc_nids = alc272_capsrc_nids,
19028 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020019029 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019030 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020019031 .init_hook = alc663_m51va_inithook,
19032 },
19033 [ALC272_DELL_ZM1] = {
19034 .mixers = { alc663_m51va_mixer },
19035 .cap_mixer = alc662_auto_capture_mixer,
19036 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_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 = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019041 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020019042 .capsrc_nids = alc662_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 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020019048 [ALC272_SAMSUNG_NC10] = {
19049 .mixers = { alc272_nc10_mixer },
19050 .init_verbs = { alc662_init_verbs,
19051 alc663_21jd_amic_init_verbs },
19052 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19053 .dac_nids = alc272_dac_nids,
19054 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19055 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019056 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020019057 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019058 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020019059 .init_hook = alc663_mode4_inithook,
19060 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019061};
19062
19063
19064/*
19065 * BIOS auto configuration
19066 */
19067
Takashi Iwai7085ec12009-10-02 09:03:58 +020019068/* convert from MIX nid to DAC */
19069static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
19070{
19071 if (nid == 0x0f)
19072 return 0x02;
19073 else if (nid >= 0x0c && nid <= 0x0e)
19074 return nid - 0x0c + 0x02;
David Henningssoncc1c4522010-11-24 14:17:47 +010019075 else if (nid == 0x26) /* ALC887-VD has this DAC too */
19076 return 0x25;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019077 else
19078 return 0;
19079}
19080
19081/* get MIX nid connected to the given pin targeted to DAC */
19082static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
19083 hda_nid_t dac)
19084{
David Henningssoncc1c4522010-11-24 14:17:47 +010019085 hda_nid_t mix[5];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019086 int i, num;
19087
19088 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
19089 for (i = 0; i < num; i++) {
19090 if (alc662_mix_to_dac(mix[i]) == dac)
19091 return mix[i];
19092 }
19093 return 0;
19094}
19095
19096/* look for an empty DAC slot */
19097static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
19098{
19099 struct alc_spec *spec = codec->spec;
19100 hda_nid_t srcs[5];
19101 int i, j, num;
19102
19103 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
19104 if (num < 0)
19105 return 0;
19106 for (i = 0; i < num; i++) {
19107 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
19108 if (!nid)
19109 continue;
19110 for (j = 0; j < spec->multiout.num_dacs; j++)
19111 if (spec->multiout.dac_nids[j] == nid)
19112 break;
19113 if (j >= spec->multiout.num_dacs)
19114 return nid;
19115 }
19116 return 0;
19117}
19118
19119/* fill in the dac_nids table from the parsed pin configuration */
19120static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
19121 const struct auto_pin_cfg *cfg)
19122{
19123 struct alc_spec *spec = codec->spec;
19124 int i;
19125 hda_nid_t dac;
19126
19127 spec->multiout.dac_nids = spec->private_dac_nids;
19128 for (i = 0; i < cfg->line_outs; i++) {
19129 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
19130 if (!dac)
19131 continue;
19132 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19133 }
19134 return 0;
19135}
19136
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019137static inline int __alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
19138 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019139{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019140 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019141 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
19142}
19143
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019144static inline int __alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
19145 hda_nid_t nid, int idx, unsigned int chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019146{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019147 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019148 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
19149}
19150
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019151#define alc662_add_vol_ctl(spec, pfx, nid, chs) \
19152 __alc662_add_vol_ctl(spec, pfx, nid, 0, chs)
19153#define alc662_add_sw_ctl(spec, pfx, nid, chs) \
19154 __alc662_add_sw_ctl(spec, pfx, nid, 0, chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019155#define alc662_add_stereo_vol(spec, pfx, nid) \
19156 alc662_add_vol_ctl(spec, pfx, nid, 3)
19157#define alc662_add_stereo_sw(spec, pfx, nid) \
19158 alc662_add_sw_ctl(spec, pfx, nid, 3)
19159
19160/* add playback controls from the parsed DAC table */
19161static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
19162 const struct auto_pin_cfg *cfg)
19163{
19164 struct alc_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +010019165 static const char * const chname[4] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019166 "Front", "Surround", NULL /*CLFE*/, "Side"
19167 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019168 const char *pfx = alc_get_line_out_pfx(cfg, true);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019169 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019170 int i, err;
19171
19172 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019173 nid = spec->multiout.dac_nids[i];
19174 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019175 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019176 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
19177 if (!mix)
19178 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019179 if (!pfx && i == 2) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019180 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019181 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019182 if (err < 0)
19183 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019184 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019185 if (err < 0)
19186 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019187 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019188 if (err < 0)
19189 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019190 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019191 if (err < 0)
19192 return err;
19193 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019194 const char *name = pfx;
19195 if (!name)
19196 name = chname[i];
19197 err = __alc662_add_vol_ctl(spec, name, nid, i, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019198 if (err < 0)
19199 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019200 err = __alc662_add_sw_ctl(spec, name, mix, i, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019201 if (err < 0)
19202 return err;
19203 }
19204 }
19205 return 0;
19206}
19207
19208/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019209/* return DAC nid if any new DAC is assigned */
19210static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019211 const char *pfx)
19212{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019213 struct alc_spec *spec = codec->spec;
19214 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019215 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019216
19217 if (!pin)
19218 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019219 nid = alc662_look_for_dac(codec, pin);
19220 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019221 /* the corresponding DAC is already occupied */
19222 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
19223 return 0; /* no way */
19224 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019225 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019226 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19227 }
19228
19229 mix = alc662_dac_to_mix(codec, pin, nid);
19230 if (!mix)
19231 return 0;
19232 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
19233 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020019234 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019235 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
19236 if (err < 0)
19237 return err;
19238 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019239}
19240
19241/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020019242#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020019243 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019244
19245static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
19246 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019247 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019248{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019249 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020019250 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019251
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019252 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019253 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019254 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
19255 if (num <= 1)
19256 return;
19257 for (i = 0; i < num; i++) {
19258 if (alc662_mix_to_dac(srcs[i]) != dac)
19259 continue;
19260 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
19261 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019262 }
19263}
19264
19265static void alc662_auto_init_multi_out(struct hda_codec *codec)
19266{
19267 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019268 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019269 int i;
19270
19271 for (i = 0; i <= HDA_SIDE; i++) {
19272 hda_nid_t nid = spec->autocfg.line_out_pins[i];
19273 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020019274 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019275 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019276 }
19277}
19278
19279static void alc662_auto_init_hp_out(struct hda_codec *codec)
19280{
19281 struct alc_spec *spec = codec->spec;
19282 hda_nid_t pin;
19283
19284 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019285 if (pin)
19286 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
19287 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019288 pin = spec->autocfg.speaker_pins[0];
19289 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019290 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
19291 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019292}
19293
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019294#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
19295
19296static void alc662_auto_init_analog_input(struct hda_codec *codec)
19297{
19298 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019299 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019300 int i;
19301
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019302 for (i = 0; i < cfg->num_inputs; i++) {
19303 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019304 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020019305 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010019306 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010019307 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019308 snd_hda_codec_write(codec, nid, 0,
19309 AC_VERB_SET_AMP_GAIN_MUTE,
19310 AMP_OUT_MUTE);
19311 }
19312 }
19313}
19314
Takashi Iwaif511b012008-08-15 16:46:42 +020019315#define alc662_auto_init_input_src alc882_auto_init_input_src
19316
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019317static int alc662_parse_auto_config(struct hda_codec *codec)
19318{
19319 struct alc_spec *spec = codec->spec;
19320 int err;
19321 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
19322
19323 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19324 alc662_ignore);
19325 if (err < 0)
19326 return err;
19327 if (!spec->autocfg.line_outs)
19328 return 0; /* can't find valid BIOS pin config */
19329
Takashi Iwai7085ec12009-10-02 09:03:58 +020019330 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019331 if (err < 0)
19332 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019333 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019334 if (err < 0)
19335 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019336 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019337 spec->autocfg.speaker_pins[0],
19338 "Speaker");
19339 if (err < 0)
19340 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019341 if (err)
19342 spec->multiout.extra_out_nid[0] = err;
19343 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019344 "Headphone");
19345 if (err < 0)
19346 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019347 if (err)
19348 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019349 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019350 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019351 return err;
19352
19353 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
19354
Takashi Iwai757899a2010-07-30 10:48:14 +020019355 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019356
Takashi Iwai603c4012008-07-30 15:01:44 +020019357 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010019358 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019359
19360 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020019361 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020019362
Kailang Yangcec27c82010-02-04 14:18:18 +010019363 add_verb(spec, alc662_init_verbs);
19364 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019365 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Kailang Yangcec27c82010-02-04 14:18:18 +010019366 add_verb(spec, alc663_init_verbs);
19367
19368 if (codec->vendor_id == 0x10ec0272)
19369 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020019370
19371 err = alc_auto_add_mic_boost(codec);
19372 if (err < 0)
19373 return err;
19374
Kailang Yang6227cdc2010-02-25 08:36:52 +010019375 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
19376 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
19377 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
19378 else
19379 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020019380
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019381 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019382}
19383
19384/* additional initialization for auto-configuration model */
19385static void alc662_auto_init(struct hda_codec *codec)
19386{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019387 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019388 alc662_auto_init_multi_out(codec);
19389 alc662_auto_init_hp_out(codec);
19390 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020019391 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019392 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019393 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020019394 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019395}
19396
Todd Broch6be79482010-12-07 16:51:05 -080019397static void alc272_fixup_mario(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019398 const struct alc_fixup *fix, int action)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010019399{
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019400 if (action != ALC_FIXUP_ACT_PROBE)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010019401 return;
Todd Broch6be79482010-12-07 16:51:05 -080019402 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
19403 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
19404 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
19405 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
19406 (0 << AC_AMPCAP_MUTE_SHIFT)))
19407 printk(KERN_WARNING
19408 "hda_codec: failed to override amp caps for NID 0x2\n");
19409}
19410
David Henningsson6cb3b702010-09-09 08:51:44 +020019411enum {
Daniel T Chen2df03512010-10-10 22:39:28 -040019412 ALC662_FIXUP_ASPIRE,
David Henningsson6cb3b702010-09-09 08:51:44 +020019413 ALC662_FIXUP_IDEAPAD,
Todd Broch6be79482010-12-07 16:51:05 -080019414 ALC272_FIXUP_MARIO,
Anisse Astierd2ebd472011-01-20 12:36:21 +010019415 ALC662_FIXUP_CZC_P10T,
David Henningsson6cb3b702010-09-09 08:51:44 +020019416};
19417
19418static const struct alc_fixup alc662_fixups[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019419 [ALC662_FIXUP_ASPIRE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019420 .type = ALC_FIXUP_PINS,
19421 .v.pins = (const struct alc_pincfg[]) {
Daniel T Chen2df03512010-10-10 22:39:28 -040019422 { 0x15, 0x99130112 }, /* subwoofer */
19423 { }
19424 }
19425 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019426 [ALC662_FIXUP_IDEAPAD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019427 .type = ALC_FIXUP_PINS,
19428 .v.pins = (const struct alc_pincfg[]) {
David Henningsson6cb3b702010-09-09 08:51:44 +020019429 { 0x17, 0x99130112 }, /* subwoofer */
19430 { }
19431 }
19432 },
Todd Broch6be79482010-12-07 16:51:05 -080019433 [ALC272_FIXUP_MARIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019434 .type = ALC_FIXUP_FUNC,
19435 .v.func = alc272_fixup_mario,
Anisse Astierd2ebd472011-01-20 12:36:21 +010019436 },
19437 [ALC662_FIXUP_CZC_P10T] = {
19438 .type = ALC_FIXUP_VERBS,
19439 .v.verbs = (const struct hda_verb[]) {
19440 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
19441 {}
19442 }
19443 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019444};
19445
19446static struct snd_pci_quirk alc662_fixup_tbl[] = {
David Henningssona6c47a82011-02-10 15:39:19 +010019447 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
Daniel T Chen2df03512010-10-10 22:39:28 -040019448 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
Daniel T Chena0e90ac2010-11-20 10:20:35 -050019449 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
Valentine Sinitsynd4118582010-10-01 22:24:08 +060019450 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
David Henningsson6cb3b702010-09-09 08:51:44 +020019451 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
Anisse Astierd2ebd472011-01-20 12:36:21 +010019452 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
David Henningsson6cb3b702010-09-09 08:51:44 +020019453 {}
19454};
19455
Todd Broch6be79482010-12-07 16:51:05 -080019456static const struct alc_model_fixup alc662_fixup_models[] = {
19457 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
19458 {}
19459};
David Henningsson6cb3b702010-09-09 08:51:44 +020019460
19461
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019462static int patch_alc662(struct hda_codec *codec)
19463{
19464 struct alc_spec *spec;
19465 int err, board_config;
Kailang Yang693194f2010-10-21 08:51:48 +020019466 int coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019467
19468 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19469 if (!spec)
19470 return -ENOMEM;
19471
19472 codec->spec = spec;
19473
Kailang Yangda00c242010-03-19 11:23:45 +010019474 alc_auto_parse_customize_define(codec);
19475
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020019476 alc_fix_pll_init(codec, 0x20, 0x04, 15);
19477
Kailang Yang693194f2010-10-21 08:51:48 +020019478 coef = alc_read_coef_idx(codec, 0);
19479 if (coef == 0x8020 || coef == 0x8011)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019480 alc_codec_rename(codec, "ALC661");
Kailang Yang693194f2010-10-21 08:51:48 +020019481 else if (coef & (1 << 14) &&
19482 codec->bus->pci->subsystem_vendor == 0x1025 &&
19483 spec->cdefine.platform_type == 1)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019484 alc_codec_rename(codec, "ALC272X");
Kailang Yang693194f2010-10-21 08:51:48 +020019485 else if (coef == 0x4011)
19486 alc_codec_rename(codec, "ALC656");
Kailang Yang274693f2009-12-03 10:07:50 +010019487
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019488 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19489 alc662_models,
19490 alc662_cfg_tbl);
19491 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019492 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19493 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019494 board_config = ALC662_AUTO;
19495 }
19496
19497 if (board_config == ALC662_AUTO) {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019498 alc_pick_fixup(codec, alc662_fixup_models,
19499 alc662_fixup_tbl, alc662_fixups);
19500 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019501 /* automatic parse from the BIOS config */
19502 err = alc662_parse_auto_config(codec);
19503 if (err < 0) {
19504 alc_free(codec);
19505 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019506 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019507 printk(KERN_INFO
19508 "hda_codec: Cannot set up configuration "
19509 "from BIOS. Using base mode...\n");
19510 board_config = ALC662_3ST_2ch_DIG;
19511 }
19512 }
19513
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019514 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019515 err = snd_hda_attach_beep_device(codec, 0x1);
19516 if (err < 0) {
19517 alc_free(codec);
19518 return err;
19519 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019520 }
19521
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019522 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019523 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019524
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019525 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19526 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19527
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019528 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19529 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19530
Takashi Iwaidd704692009-08-11 08:45:11 +020019531 if (!spec->adc_nids) {
19532 spec->adc_nids = alc662_adc_nids;
19533 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19534 }
19535 if (!spec->capsrc_nids)
19536 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019537
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019538 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019539 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019540
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019541 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019542 switch (codec->vendor_id) {
19543 case 0x10ec0662:
19544 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19545 break;
19546 case 0x10ec0272:
19547 case 0x10ec0663:
19548 case 0x10ec0665:
19549 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19550 break;
19551 case 0x10ec0273:
19552 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19553 break;
19554 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019555 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019556 spec->vmaster_nid = 0x02;
19557
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019558 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
19559
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019560 codec->patch_ops = alc_patch_ops;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019561 if (board_config == ALC662_AUTO)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019562 spec->init_hook = alc662_auto_init;
David Henningsson6cb3b702010-09-09 08:51:44 +020019563
Kailang Yangbf1b0222010-10-21 08:49:56 +020019564 alc_init_jacks(codec);
19565
Takashi Iwaicb53c622007-08-10 17:21:45 +020019566#ifdef CONFIG_SND_HDA_POWER_SAVE
19567 if (!spec->loopback.amplist)
19568 spec->loopback.amplist = alc662_loopbacks;
19569#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019570
19571 return 0;
19572}
19573
Kailang Yang274693f2009-12-03 10:07:50 +010019574static int patch_alc888(struct hda_codec *codec)
19575{
19576 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19577 kfree(codec->chip_name);
Kailang Yang01e0f132010-11-22 10:59:36 +010019578 if (codec->vendor_id == 0x10ec0887)
19579 codec->chip_name = kstrdup("ALC887-VD", GFP_KERNEL);
19580 else
19581 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019582 if (!codec->chip_name) {
19583 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019584 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019585 }
19586 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019587 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019588 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019589}
19590
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019591/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019592 * ALC680 support
19593 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019594#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019595#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19596#define alc680_modes alc260_modes
19597
19598static hda_nid_t alc680_dac_nids[3] = {
19599 /* Lout1, Lout2, hp */
19600 0x02, 0x03, 0x04
19601};
19602
19603static hda_nid_t alc680_adc_nids[3] = {
19604 /* ADC0-2 */
19605 /* DMIC, MIC, Line-in*/
19606 0x07, 0x08, 0x09
19607};
19608
Kailang Yangc69aefa2010-08-17 10:39:22 +020019609/*
19610 * Analog capture ADC cgange
19611 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019612static void alc680_rec_autoswitch(struct hda_codec *codec)
19613{
19614 struct alc_spec *spec = codec->spec;
19615 struct auto_pin_cfg *cfg = &spec->autocfg;
19616 int pin_found = 0;
19617 int type_found = AUTO_PIN_LAST;
19618 hda_nid_t nid;
19619 int i;
19620
19621 for (i = 0; i < cfg->num_inputs; i++) {
19622 nid = cfg->inputs[i].pin;
19623 if (!(snd_hda_query_pin_caps(codec, nid) &
19624 AC_PINCAP_PRES_DETECT))
19625 continue;
19626 if (snd_hda_jack_detect(codec, nid)) {
19627 if (cfg->inputs[i].type < type_found) {
19628 type_found = cfg->inputs[i].type;
19629 pin_found = nid;
19630 }
19631 }
19632 }
19633
19634 nid = 0x07;
19635 if (pin_found)
19636 snd_hda_get_connections(codec, pin_found, &nid, 1);
19637
19638 if (nid != spec->cur_adc)
19639 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19640 spec->cur_adc = nid;
19641 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19642 spec->cur_adc_format);
19643}
19644
Kailang Yangc69aefa2010-08-17 10:39:22 +020019645static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19646 struct hda_codec *codec,
19647 unsigned int stream_tag,
19648 unsigned int format,
19649 struct snd_pcm_substream *substream)
19650{
19651 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019652
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019653 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019654 spec->cur_adc_stream_tag = stream_tag;
19655 spec->cur_adc_format = format;
19656
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019657 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019658 return 0;
19659}
19660
19661static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19662 struct hda_codec *codec,
19663 struct snd_pcm_substream *substream)
19664{
19665 snd_hda_codec_cleanup_stream(codec, 0x07);
19666 snd_hda_codec_cleanup_stream(codec, 0x08);
19667 snd_hda_codec_cleanup_stream(codec, 0x09);
19668 return 0;
19669}
19670
19671static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19672 .substreams = 1, /* can be overridden */
19673 .channels_min = 2,
19674 .channels_max = 2,
19675 /* NID is set in alc_build_pcms */
19676 .ops = {
19677 .prepare = alc680_capture_pcm_prepare,
19678 .cleanup = alc680_capture_pcm_cleanup
19679 },
19680};
19681
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019682static struct snd_kcontrol_new alc680_base_mixer[] = {
19683 /* output mixer control */
19684 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19685 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19686 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19687 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010019688 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x12, 0, HDA_INPUT),
19689 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
19690 HDA_CODEC_VOLUME("Line In Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019691 { }
19692};
19693
Kailang Yangc69aefa2010-08-17 10:39:22 +020019694static struct hda_bind_ctls alc680_bind_cap_vol = {
19695 .ops = &snd_hda_bind_vol,
19696 .values = {
19697 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19698 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19699 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19700 0
19701 },
19702};
19703
19704static struct hda_bind_ctls alc680_bind_cap_switch = {
19705 .ops = &snd_hda_bind_sw,
19706 .values = {
19707 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19708 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19709 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19710 0
19711 },
19712};
19713
19714static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19715 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19716 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019717 { } /* end */
19718};
19719
19720/*
19721 * generic initialization of ADC, input mixers and output mixers
19722 */
19723static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019724 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19725 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19726 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019727
Kailang Yangc69aefa2010-08-17 10:39:22 +020019728 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19729 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19730 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19731 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19732 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19733 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019734
19735 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19736 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19737 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19738 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19739 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019740
19741 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19742 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019743 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019744
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019745 { }
19746};
19747
Kailang Yangc69aefa2010-08-17 10:39:22 +020019748/* toggle speaker-output according to the hp-jack state */
19749static void alc680_base_setup(struct hda_codec *codec)
19750{
19751 struct alc_spec *spec = codec->spec;
19752
19753 spec->autocfg.hp_pins[0] = 0x16;
19754 spec->autocfg.speaker_pins[0] = 0x14;
19755 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019756 spec->autocfg.num_inputs = 2;
19757 spec->autocfg.inputs[0].pin = 0x18;
19758 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19759 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019760 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019761}
19762
19763static void alc680_unsol_event(struct hda_codec *codec,
19764 unsigned int res)
19765{
19766 if ((res >> 26) == ALC880_HP_EVENT)
19767 alc_automute_amp(codec);
19768 if ((res >> 26) == ALC880_MIC_EVENT)
19769 alc680_rec_autoswitch(codec);
19770}
19771
19772static void alc680_inithook(struct hda_codec *codec)
19773{
19774 alc_automute_amp(codec);
19775 alc680_rec_autoswitch(codec);
19776}
19777
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019778/* create input playback/capture controls for the given pin */
19779static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19780 const char *ctlname, int idx)
19781{
19782 hda_nid_t dac;
19783 int err;
19784
19785 switch (nid) {
19786 case 0x14:
19787 dac = 0x02;
19788 break;
19789 case 0x15:
19790 dac = 0x03;
19791 break;
19792 case 0x16:
19793 dac = 0x04;
19794 break;
19795 default:
19796 return 0;
19797 }
19798 if (spec->multiout.dac_nids[0] != dac &&
19799 spec->multiout.dac_nids[1] != dac) {
19800 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19801 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19802 HDA_OUTPUT));
19803 if (err < 0)
19804 return err;
19805
19806 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19807 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19808
19809 if (err < 0)
19810 return err;
19811 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19812 }
19813
19814 return 0;
19815}
19816
19817/* add playback controls from the parsed DAC table */
19818static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19819 const struct auto_pin_cfg *cfg)
19820{
19821 hda_nid_t nid;
19822 int err;
19823
19824 spec->multiout.dac_nids = spec->private_dac_nids;
19825
19826 nid = cfg->line_out_pins[0];
19827 if (nid) {
19828 const char *name;
19829 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19830 name = "Speaker";
19831 else
19832 name = "Front";
19833 err = alc680_new_analog_output(spec, nid, name, 0);
19834 if (err < 0)
19835 return err;
19836 }
19837
19838 nid = cfg->speaker_pins[0];
19839 if (nid) {
19840 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19841 if (err < 0)
19842 return err;
19843 }
19844 nid = cfg->hp_pins[0];
19845 if (nid) {
19846 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19847 if (err < 0)
19848 return err;
19849 }
19850
19851 return 0;
19852}
19853
19854static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19855 hda_nid_t nid, int pin_type)
19856{
19857 alc_set_pin_output(codec, nid, pin_type);
19858}
19859
19860static void alc680_auto_init_multi_out(struct hda_codec *codec)
19861{
19862 struct alc_spec *spec = codec->spec;
19863 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19864 if (nid) {
19865 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19866 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19867 }
19868}
19869
19870static void alc680_auto_init_hp_out(struct hda_codec *codec)
19871{
19872 struct alc_spec *spec = codec->spec;
19873 hda_nid_t pin;
19874
19875 pin = spec->autocfg.hp_pins[0];
19876 if (pin)
19877 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19878 pin = spec->autocfg.speaker_pins[0];
19879 if (pin)
19880 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19881}
19882
19883/* pcm configuration: identical with ALC880 */
19884#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19885#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19886#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19887#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019888#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019889
19890/*
19891 * BIOS auto configuration
19892 */
19893static int alc680_parse_auto_config(struct hda_codec *codec)
19894{
19895 struct alc_spec *spec = codec->spec;
19896 int err;
19897 static hda_nid_t alc680_ignore[] = { 0 };
19898
19899 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19900 alc680_ignore);
19901 if (err < 0)
19902 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019903
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019904 if (!spec->autocfg.line_outs) {
19905 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19906 spec->multiout.max_channels = 2;
19907 spec->no_analog = 1;
19908 goto dig_only;
19909 }
19910 return 0; /* can't find valid BIOS pin config */
19911 }
19912 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19913 if (err < 0)
19914 return err;
19915
19916 spec->multiout.max_channels = 2;
19917
19918 dig_only:
19919 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019920 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019921 if (spec->kctls.list)
19922 add_mixer(spec, spec->kctls.list);
19923
19924 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019925
19926 err = alc_auto_add_mic_boost(codec);
19927 if (err < 0)
19928 return err;
19929
19930 return 1;
19931}
19932
19933#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19934
19935/* init callback for auto-configuration model -- overriding the default init */
19936static void alc680_auto_init(struct hda_codec *codec)
19937{
19938 struct alc_spec *spec = codec->spec;
19939 alc680_auto_init_multi_out(codec);
19940 alc680_auto_init_hp_out(codec);
19941 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019942 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019943 if (spec->unsol_event)
19944 alc_inithook(codec);
19945}
19946
19947/*
19948 * configuration and preset
19949 */
Takashi Iwaiea734962011-01-17 11:29:34 +010019950static const char * const alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019951 [ALC680_BASE] = "base",
19952 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019953};
19954
19955static struct snd_pci_quirk alc680_cfg_tbl[] = {
19956 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19957 {}
19958};
19959
19960static struct alc_config_preset alc680_presets[] = {
19961 [ALC680_BASE] = {
19962 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019963 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019964 .init_verbs = { alc680_init_verbs },
19965 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19966 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019967 .dig_out_nid = ALC680_DIGOUT_NID,
19968 .num_channel_mode = ARRAY_SIZE(alc680_modes),
19969 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020019970 .unsol_event = alc680_unsol_event,
19971 .setup = alc680_base_setup,
19972 .init_hook = alc680_inithook,
19973
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019974 },
19975};
19976
19977static int patch_alc680(struct hda_codec *codec)
19978{
19979 struct alc_spec *spec;
19980 int board_config;
19981 int err;
19982
19983 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19984 if (spec == NULL)
19985 return -ENOMEM;
19986
19987 codec->spec = spec;
19988
19989 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
19990 alc680_models,
19991 alc680_cfg_tbl);
19992
19993 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
19994 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19995 codec->chip_name);
19996 board_config = ALC680_AUTO;
19997 }
19998
19999 if (board_config == ALC680_AUTO) {
20000 /* automatic parse from the BIOS config */
20001 err = alc680_parse_auto_config(codec);
20002 if (err < 0) {
20003 alc_free(codec);
20004 return err;
20005 } else if (!err) {
20006 printk(KERN_INFO
20007 "hda_codec: Cannot set up configuration "
20008 "from BIOS. Using base mode...\n");
20009 board_config = ALC680_BASE;
20010 }
20011 }
20012
20013 if (board_config != ALC680_AUTO)
20014 setup_preset(codec, &alc680_presets[board_config]);
20015
20016 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020020017 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020018 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020020019 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020020
20021 if (!spec->adc_nids) {
20022 spec->adc_nids = alc680_adc_nids;
20023 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
20024 }
20025
20026 if (!spec->cap_mixer)
20027 set_capture_mixer(codec);
20028
20029 spec->vmaster_nid = 0x02;
20030
20031 codec->patch_ops = alc_patch_ops;
20032 if (board_config == ALC680_AUTO)
20033 spec->init_hook = alc680_auto_init;
20034
20035 return 0;
20036}
20037
20038/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070020039 * patch entries
20040 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010020041static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070020042 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020043 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020044 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020020045 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020046 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020047 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020020048 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020049 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020050 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020051 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020052 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
20053 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
20054 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020055 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020056 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020057 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
20058 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020020059 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010020060 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010020061 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020062 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020063 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020064 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020065 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020020066 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020067 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020020068 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020069 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020070 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yang01e0f132010-11-22 10:59:36 +010020071 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc888 },
Kailang Yang44426082008-10-15 11:18:05 +020020072 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020073 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020074 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020075 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020076 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020077 {} /* terminator */
20078};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010020079
20080MODULE_ALIAS("snd-hda-codec-id:10ec*");
20081
20082MODULE_LICENSE("GPL");
20083MODULE_DESCRIPTION("Realtek HD-audio codec");
20084
20085static struct hda_codec_preset_list realtek_list = {
20086 .preset = snd_hda_preset_realtek,
20087 .owner = THIS_MODULE,
20088};
20089
20090static int __init patch_realtek_init(void)
20091{
20092 return snd_hda_add_codec_preset(&realtek_list);
20093}
20094
20095static void __exit patch_realtek_exit(void)
20096{
20097 snd_hda_delete_codec_preset(&realtek_list);
20098}
20099
20100module_init(patch_realtek_init)
20101module_exit(patch_realtek_exit)