blob: 11a1380b8821dec69e2ac6e6ed6233fef4f5c2ed [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ünther3e1647c52009-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 Iwai584c0c42011-03-10 12:51:11 +0100388 unsigned int single_input_src:1;
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200389 int init_amp;
Takashi Iwaid433a672010-09-20 15:11:54 +0200390 int codec_variant; /* flag for other variants */
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100391
Takashi Iwai2134ea42008-01-10 16:53:55 +0100392 /* for virtual master */
393 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200394#ifdef CONFIG_SND_HDA_POWER_SAVE
395 struct hda_loopback_check loopback;
396#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200397
398 /* for PLL fix */
399 hda_nid_t pll_nid;
400 unsigned int pll_coef_idx, pll_coef_bit;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +0100401
402 /* fix-up list */
403 int fixup_id;
404 const struct alc_fixup *fixup_list;
405 const char *fixup_name;
Kailang Yangdf694da2005-12-05 19:42:22 +0100406};
407
408/*
409 * configuration template - to be copied to the spec instance
410 */
411struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200412 struct snd_kcontrol_new *mixers[5]; /* should be identical size
413 * with spec
414 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100415 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100416 const struct hda_verb *init_verbs[5];
417 unsigned int num_dacs;
418 hda_nid_t *dac_nids;
419 hda_nid_t dig_out_nid; /* optional */
420 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800421 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100422 unsigned int num_adc_nids;
423 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100424 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100425 hda_nid_t dig_in_nid;
426 unsigned int num_channel_mode;
427 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200428 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200429 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200430 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100431 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100432 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200433 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100434 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200435#ifdef CONFIG_SND_HDA_POWER_SAVE
436 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500437 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200438#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439};
440
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441
442/*
443 * input MUX handling
444 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200445static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
446 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447{
448 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
449 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200450 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
451 if (mux_idx >= spec->num_mux_defs)
452 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100453 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
454 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200455 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456}
457
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200458static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
459 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460{
461 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
462 struct alc_spec *spec = codec->spec;
463 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
464
465 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
466 return 0;
467}
468
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200469static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
470 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471{
472 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
473 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100474 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100476 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100477 hda_nid_t nid = spec->capsrc_nids ?
478 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200479 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480
Takashi Iwaicd896c32008-11-18 12:36:33 +0100481 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
482 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100483 if (!imux->num_items && mux_idx > 0)
484 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100485
Takashi Iwaia22d5432009-07-27 12:54:26 +0200486 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200487 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100488 /* Matrix-mixer style (e.g. ALC882) */
489 unsigned int *cur_val = &spec->cur_mux[adc_idx];
490 unsigned int i, idx;
491
492 idx = ucontrol->value.enumerated.item[0];
493 if (idx >= imux->num_items)
494 idx = imux->num_items - 1;
495 if (*cur_val == idx)
496 return 0;
497 for (i = 0; i < imux->num_items; i++) {
498 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
499 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
500 imux->items[i].index,
501 HDA_AMP_MUTE, v);
502 }
503 *cur_val = idx;
504 return 1;
505 } else {
506 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100507 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100508 &spec->cur_mux[adc_idx]);
509 }
510}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200511
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512/*
513 * channel mode setting
514 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200515static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
516 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517{
518 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
519 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100520 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
521 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522}
523
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200524static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
525 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526{
527 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
528 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100529 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200530 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200531 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532}
533
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200534static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
535 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536{
537 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
538 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200539 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
540 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200541 &spec->ext_channel_count);
542 if (err >= 0 && !spec->const_channel_count) {
543 spec->multiout.max_channels = spec->ext_channel_count;
544 if (spec->need_dac_fix)
545 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
546 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200547 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548}
549
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100551 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200552 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100553 * being part of a format specifier. Maximum allowed length of a value is
554 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100555 *
556 * Note: some retasking pin complexes seem to ignore requests for input
557 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
558 * are requested. Therefore order this list so that this behaviour will not
559 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200560 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
561 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200562 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100563static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100564 "Mic 50pc bias", "Mic 80pc bias",
565 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100566};
567static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100568 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100569};
570/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200571 * in the pin being assumed to be exclusively an input or an output pin. In
572 * addition, "input" pins may or may not process the mic bias option
573 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
574 * accept requests for bias as of chip versions up to March 2006) and/or
575 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100576 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200577#define ALC_PIN_DIR_IN 0x00
578#define ALC_PIN_DIR_OUT 0x01
579#define ALC_PIN_DIR_INOUT 0x02
580#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
581#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100582
Kailang Yangea1fb292008-08-26 12:58:38 +0200583/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100584 * For each direction the minimum and maximum values are given.
585 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200586static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100587 { 0, 2 }, /* ALC_PIN_DIR_IN */
588 { 3, 4 }, /* ALC_PIN_DIR_OUT */
589 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200590 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
591 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100592};
593#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
594#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
595#define alc_pin_mode_n_items(_dir) \
596 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
597
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200598static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
599 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200600{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100601 unsigned int item_num = uinfo->value.enumerated.item;
602 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
603
604 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200605 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100606 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
607
608 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
609 item_num = alc_pin_mode_min(dir);
610 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200611 return 0;
612}
613
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200614static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
615 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200616{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100617 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200618 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
619 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100620 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200621 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200622 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
623 AC_VERB_GET_PIN_WIDGET_CONTROL,
624 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200625
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100626 /* Find enumerated value for current pinctl setting */
627 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200628 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100629 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200630 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100631 return 0;
632}
633
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200634static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
635 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100636{
637 signed int change;
638 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
639 hda_nid_t nid = kcontrol->private_value & 0xffff;
640 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
641 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200642 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
643 AC_VERB_GET_PIN_WIDGET_CONTROL,
644 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100645
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200646 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100647 val = alc_pin_mode_min(dir);
648
649 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100650 if (change) {
651 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200652 snd_hda_codec_write_cache(codec, nid, 0,
653 AC_VERB_SET_PIN_WIDGET_CONTROL,
654 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100655
Kailang Yangea1fb292008-08-26 12:58:38 +0200656 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100657 * for the requested pin mode. Enum values of 2 or less are
658 * input modes.
659 *
660 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200661 * reduces noise slightly (particularly on input) so we'll
662 * do it. However, having both input and output buffers
663 * enabled simultaneously doesn't seem to be problematic if
664 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100665 */
666 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200667 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
668 HDA_AMP_MUTE, HDA_AMP_MUTE);
669 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
670 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100671 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200672 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
673 HDA_AMP_MUTE, HDA_AMP_MUTE);
674 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
675 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100676 }
677 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200678 return change;
679}
680
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100681#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200682 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100683 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100684 .info = alc_pin_mode_info, \
685 .get = alc_pin_mode_get, \
686 .put = alc_pin_mode_put, \
687 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100688
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100689/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
690 * together using a mask with more than one bit set. This control is
691 * currently used only by the ALC260 test model. At this stage they are not
692 * needed for any "production" models.
693 */
694#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200695#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200696
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200697static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
698 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100699{
700 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
701 hda_nid_t nid = kcontrol->private_value & 0xffff;
702 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
703 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200704 unsigned int val = snd_hda_codec_read(codec, nid, 0,
705 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100706
707 *valp = (val & mask) != 0;
708 return 0;
709}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200710static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
711 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100712{
713 signed int change;
714 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
715 hda_nid_t nid = kcontrol->private_value & 0xffff;
716 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
717 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200718 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
719 AC_VERB_GET_GPIO_DATA,
720 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100721
722 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200723 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
724 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100725 gpio_data &= ~mask;
726 else
727 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200728 snd_hda_codec_write_cache(codec, nid, 0,
729 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100730
731 return change;
732}
733#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
734 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100735 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100736 .info = alc_gpio_data_info, \
737 .get = alc_gpio_data_get, \
738 .put = alc_gpio_data_put, \
739 .private_value = nid | (mask<<16) }
740#endif /* CONFIG_SND_DEBUG */
741
Jonathan Woithe92621f12006-02-28 11:47:47 +0100742/* A switch control to allow the enabling of the digital IO pins on the
743 * ALC260. This is incredibly simplistic; the intention of this control is
744 * to provide something in the test model allowing digital outputs to be
745 * identified if present. If models are found which can utilise these
746 * outputs a more complete mixer control can be devised for those models if
747 * necessary.
748 */
749#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200750#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200751
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200752static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
753 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100754{
755 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
756 hda_nid_t nid = kcontrol->private_value & 0xffff;
757 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
758 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200759 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100760 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100761
762 *valp = (val & mask) != 0;
763 return 0;
764}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200765static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
766 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100767{
768 signed int change;
769 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
770 hda_nid_t nid = kcontrol->private_value & 0xffff;
771 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
772 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200773 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100774 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200775 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100776
777 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200778 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100779 if (val==0)
780 ctrl_data &= ~mask;
781 else
782 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200783 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
784 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100785
786 return change;
787}
788#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
789 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100790 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100791 .info = alc_spdif_ctrl_info, \
792 .get = alc_spdif_ctrl_get, \
793 .put = alc_spdif_ctrl_put, \
794 .private_value = nid | (mask<<16) }
795#endif /* CONFIG_SND_DEBUG */
796
Jonathan Woithef8225f62008-01-08 12:16:54 +0100797/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
798 * Again, this is only used in the ALC26x test models to help identify when
799 * the EAPD line must be asserted for features to work.
800 */
801#ifdef CONFIG_SND_DEBUG
802#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
803
804static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
805 struct snd_ctl_elem_value *ucontrol)
806{
807 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
808 hda_nid_t nid = kcontrol->private_value & 0xffff;
809 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
810 long *valp = ucontrol->value.integer.value;
811 unsigned int val = snd_hda_codec_read(codec, nid, 0,
812 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
813
814 *valp = (val & mask) != 0;
815 return 0;
816}
817
818static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
819 struct snd_ctl_elem_value *ucontrol)
820{
821 int change;
822 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
823 hda_nid_t nid = kcontrol->private_value & 0xffff;
824 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
825 long val = *ucontrol->value.integer.value;
826 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
827 AC_VERB_GET_EAPD_BTLENABLE,
828 0x00);
829
830 /* Set/unset the masked control bit(s) as needed */
831 change = (!val ? 0 : mask) != (ctrl_data & mask);
832 if (!val)
833 ctrl_data &= ~mask;
834 else
835 ctrl_data |= mask;
836 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
837 ctrl_data);
838
839 return change;
840}
841
842#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
843 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100844 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100845 .info = alc_eapd_ctrl_info, \
846 .get = alc_eapd_ctrl_get, \
847 .put = alc_eapd_ctrl_put, \
848 .private_value = nid | (mask<<16) }
849#endif /* CONFIG_SND_DEBUG */
850
Kailang Yangdf694da2005-12-05 19:42:22 +0100851/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100852 * set up the input pin config (depending on the given auto-pin type)
853 */
854static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
855 int auto_pin_type)
856{
857 unsigned int val = PIN_IN;
858
Takashi Iwai86e29592010-09-09 14:50:17 +0200859 if (auto_pin_type == AUTO_PIN_MIC) {
Takashi Iwai23f0c042009-02-26 13:03:58 +0100860 unsigned int pincap;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200861 unsigned int oldval;
862 oldval = snd_hda_codec_read(codec, nid, 0,
863 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Takashi Iwai1327a322009-03-23 13:07:47 +0100864 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100865 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200866 /* if the default pin setup is vref50, we give it priority */
867 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
Takashi Iwai23f0c042009-02-26 13:03:58 +0100868 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200869 else if (pincap & AC_PINCAP_VREF_50)
870 val = PIN_VREF50;
871 else if (pincap & AC_PINCAP_VREF_100)
872 val = PIN_VREF100;
873 else if (pincap & AC_PINCAP_VREF_GRD)
874 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100875 }
876 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
877}
878
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200879static void alc_fixup_autocfg_pin_nums(struct hda_codec *codec)
880{
881 struct alc_spec *spec = codec->spec;
882 struct auto_pin_cfg *cfg = &spec->autocfg;
883
884 if (!cfg->line_outs) {
885 while (cfg->line_outs < AUTO_CFG_MAX_OUTS &&
886 cfg->line_out_pins[cfg->line_outs])
887 cfg->line_outs++;
888 }
889 if (!cfg->speaker_outs) {
890 while (cfg->speaker_outs < AUTO_CFG_MAX_OUTS &&
891 cfg->speaker_pins[cfg->speaker_outs])
892 cfg->speaker_outs++;
893 }
894 if (!cfg->hp_outs) {
895 while (cfg->hp_outs < AUTO_CFG_MAX_OUTS &&
896 cfg->hp_pins[cfg->hp_outs])
897 cfg->hp_outs++;
898 }
899}
900
Takashi Iwai23f0c042009-02-26 13:03:58 +0100901/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100902 */
903static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
904{
905 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
906 return;
907 spec->mixers[spec->num_mixers++] = mix;
908}
909
910static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
911{
912 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
913 return;
914 spec->init_verbs[spec->num_init_verbs++] = verb;
915}
916
917/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100918 * set up from the preset table
919 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200920static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200921 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100922{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200923 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100924 int i;
925
926 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100927 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100928 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200929 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
930 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100931 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200932
Kailang Yangdf694da2005-12-05 19:42:22 +0100933 spec->channel_mode = preset->channel_mode;
934 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200935 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200936 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100937
Hector Martin3b315d72009-06-02 10:54:19 +0200938 if (preset->const_channel_count)
939 spec->multiout.max_channels = preset->const_channel_count;
940 else
941 spec->multiout.max_channels = spec->channel_mode[0].channels;
942 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100943
944 spec->multiout.num_dacs = preset->num_dacs;
945 spec->multiout.dac_nids = preset->dac_nids;
946 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800947 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100948 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200949
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200950 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200951 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200952 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100953 spec->input_mux = preset->input_mux;
954
955 spec->num_adc_nids = preset->num_adc_nids;
956 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100957 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100958 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100959
960 spec->unsol_event = preset->unsol_event;
961 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200962#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100963 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200964 spec->loopback.amplist = preset->loopbacks;
965#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200966
967 if (preset->setup)
968 preset->setup(codec);
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200969
970 alc_fixup_autocfg_pin_nums(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100971}
972
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200973/* Enable GPIO mask and set output */
974static struct hda_verb alc_gpio1_init_verbs[] = {
975 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
976 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
977 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
978 { }
979};
980
981static struct hda_verb alc_gpio2_init_verbs[] = {
982 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
983 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
984 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
985 { }
986};
987
Kailang Yangbdd148a2007-05-08 15:19:08 +0200988static struct hda_verb alc_gpio3_init_verbs[] = {
989 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
990 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
991 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
992 { }
993};
994
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200995/*
996 * Fix hardware PLL issue
997 * On some codecs, the analog PLL gating control must be off while
998 * the default value is 1.
999 */
1000static void alc_fix_pll(struct hda_codec *codec)
1001{
1002 struct alc_spec *spec = codec->spec;
1003 unsigned int val;
1004
1005 if (!spec->pll_nid)
1006 return;
1007 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1008 spec->pll_coef_idx);
1009 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
1010 AC_VERB_GET_PROC_COEF, 0);
1011 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1012 spec->pll_coef_idx);
1013 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
1014 val & ~(1 << spec->pll_coef_bit));
1015}
1016
1017static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
1018 unsigned int coef_idx, unsigned int coef_bit)
1019{
1020 struct alc_spec *spec = codec->spec;
1021 spec->pll_nid = nid;
1022 spec->pll_coef_idx = coef_idx;
1023 spec->pll_coef_bit = coef_bit;
1024 alc_fix_pll(codec);
1025}
1026
Kailang Yang9ad0e492010-09-14 23:22:00 +02001027static int alc_init_jacks(struct hda_codec *codec)
1028{
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001029#ifdef CONFIG_SND_HDA_INPUT_JACK
Kailang Yang9ad0e492010-09-14 23:22:00 +02001030 struct alc_spec *spec = codec->spec;
1031 int err;
1032 unsigned int hp_nid = spec->autocfg.hp_pins[0];
1033 unsigned int mic_nid = spec->ext_mic.pin;
1034
Takashi Iwai265a0242010-09-21 11:26:21 +02001035 if (hp_nid) {
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001036 err = snd_hda_input_jack_add(codec, hp_nid,
1037 SND_JACK_HEADPHONE, NULL);
Takashi Iwai265a0242010-09-21 11:26:21 +02001038 if (err < 0)
1039 return err;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001040 snd_hda_input_jack_report(codec, hp_nid);
Takashi Iwai265a0242010-09-21 11:26:21 +02001041 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001042
Takashi Iwai265a0242010-09-21 11:26:21 +02001043 if (mic_nid) {
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001044 err = snd_hda_input_jack_add(codec, mic_nid,
1045 SND_JACK_MICROPHONE, NULL);
Takashi Iwai265a0242010-09-21 11:26:21 +02001046 if (err < 0)
1047 return err;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001048 snd_hda_input_jack_report(codec, mic_nid);
Takashi Iwai265a0242010-09-21 11:26:21 +02001049 }
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001050#endif /* CONFIG_SND_HDA_INPUT_JACK */
Kailang Yang9ad0e492010-09-14 23:22:00 +02001051 return 0;
1052}
Kailang Yang9ad0e492010-09-14 23:22:00 +02001053
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001054static void alc_automute_speaker(struct hda_codec *codec, int pinctl)
Kailang Yangc9b58002007-10-16 14:30:01 +02001055{
1056 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001057 unsigned int mute;
1058 hda_nid_t nid;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001059 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +02001060
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001061 spec->jack_present = 0;
1062 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1063 nid = spec->autocfg.hp_pins[i];
1064 if (!nid)
1065 break;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001066 snd_hda_input_jack_report(codec, nid);
David Henningssonf0ce2792011-02-28 15:58:07 +01001067 spec->jack_present |= snd_hda_jack_detect(codec, nid);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001068 }
1069
1070 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1071 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001072 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1073 nid = spec->autocfg.speaker_pins[i];
1074 if (!nid)
1075 break;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001076 if (pinctl) {
1077 snd_hda_codec_write(codec, nid, 0,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001078 AC_VERB_SET_PIN_WIDGET_CONTROL,
1079 spec->jack_present ? 0 : PIN_OUT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001080 } else {
1081 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1082 HDA_AMP_MUTE, mute);
1083 }
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001084 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001085}
1086
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001087static void alc_automute_pin(struct hda_codec *codec)
1088{
1089 alc_automute_speaker(codec, 1);
1090}
1091
Takashi Iwai6c819492009-08-10 18:47:44 +02001092static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1093 hda_nid_t nid)
1094{
1095 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1096 int i, nums;
1097
1098 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1099 for (i = 0; i < nums; i++)
1100 if (conn[i] == nid)
1101 return i;
1102 return -1;
1103}
1104
Takashi Iwai840b64c2010-07-13 22:49:01 +02001105/* switch the current ADC according to the jack state */
1106static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1107{
1108 struct alc_spec *spec = codec->spec;
1109 unsigned int present;
1110 hda_nid_t new_adc;
1111
1112 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1113 if (present)
1114 spec->cur_adc_idx = 1;
1115 else
1116 spec->cur_adc_idx = 0;
1117 new_adc = spec->adc_nids[spec->cur_adc_idx];
1118 if (spec->cur_adc && spec->cur_adc != new_adc) {
1119 /* stream is running, let's swap the current ADC */
Takashi Iwaif0cea792010-08-13 11:56:53 +02001120 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
Takashi Iwai840b64c2010-07-13 22:49:01 +02001121 spec->cur_adc = new_adc;
1122 snd_hda_codec_setup_stream(codec, new_adc,
1123 spec->cur_adc_stream_tag, 0,
1124 spec->cur_adc_format);
1125 }
1126}
1127
Kailang Yang7fb0d782008-10-15 11:12:35 +02001128static void alc_mic_automute(struct hda_codec *codec)
1129{
1130 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001131 struct alc_mic_route *dead, *alive;
1132 unsigned int present, type;
1133 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001134
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001135 if (!spec->auto_mic)
1136 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001137 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1138 return;
1139 if (snd_BUG_ON(!spec->adc_nids))
1140 return;
1141
Takashi Iwai840b64c2010-07-13 22:49:01 +02001142 if (spec->dual_adc_switch) {
1143 alc_dual_mic_adc_auto_switch(codec);
1144 return;
1145 }
1146
Takashi Iwai6c819492009-08-10 18:47:44 +02001147 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1148
Wu Fengguang864f92b2009-11-18 12:38:02 +08001149 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001150 if (present) {
1151 alive = &spec->ext_mic;
1152 dead = &spec->int_mic;
1153 } else {
1154 alive = &spec->int_mic;
1155 dead = &spec->ext_mic;
1156 }
1157
Takashi Iwai6c819492009-08-10 18:47:44 +02001158 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1159 if (type == AC_WID_AUD_MIX) {
1160 /* Matrix-mixer style (e.g. ALC882) */
1161 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1162 alive->mux_idx,
1163 HDA_AMP_MUTE, 0);
1164 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1165 dead->mux_idx,
1166 HDA_AMP_MUTE, HDA_AMP_MUTE);
1167 } else {
1168 /* MUX style (e.g. ALC880) */
1169 snd_hda_codec_write_cache(codec, cap_nid, 0,
1170 AC_VERB_SET_CONNECT_SEL,
1171 alive->mux_idx);
1172 }
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001173 snd_hda_input_jack_report(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001174
1175 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001176}
1177
Kailang Yangc9b58002007-10-16 14:30:01 +02001178/* unsolicited event for HP jack sensing */
1179static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1180{
1181 if (codec->vendor_id == 0x10ec0880)
1182 res >>= 28;
1183 else
1184 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001185 switch (res) {
1186 case ALC880_HP_EVENT:
1187 alc_automute_pin(codec);
1188 break;
1189 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001190 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001191 break;
1192 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001193}
1194
1195static void alc_inithook(struct hda_codec *codec)
1196{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001197 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001198 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001199}
1200
Kailang Yangf9423e72008-05-27 12:32:25 +02001201/* additional initialization for ALC888 variants */
1202static void alc888_coef_init(struct hda_codec *codec)
1203{
1204 unsigned int tmp;
1205
1206 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1207 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1208 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001209 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001210 /* alc888S-VC */
1211 snd_hda_codec_read(codec, 0x20, 0,
1212 AC_VERB_SET_PROC_COEF, 0x830);
1213 else
1214 /* alc888-VB */
1215 snd_hda_codec_read(codec, 0x20, 0,
1216 AC_VERB_SET_PROC_COEF, 0x3030);
1217}
1218
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001219static void alc889_coef_init(struct hda_codec *codec)
1220{
1221 unsigned int tmp;
1222
1223 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1224 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1225 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1226 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1227}
1228
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001229/* turn on/off EAPD control (only if available) */
1230static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1231{
1232 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1233 return;
1234 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1235 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1236 on ? 2 : 0);
1237}
1238
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001239static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001240{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001241 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001242
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001243 switch (type) {
1244 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001245 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1246 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001247 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001248 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1249 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001250 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001251 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1252 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001253 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001254 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001255 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001256 set_eapd(codec, 0x0f, 1);
1257 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001258 break;
1259 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001260 case 0x10ec0267:
1261 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001262 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001263 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001264 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001265 case 0x10ec0660:
1266 case 0x10ec0662:
1267 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001268 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001269 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001270 set_eapd(codec, 0x14, 1);
1271 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001272 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001273 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001274 switch (codec->vendor_id) {
1275 case 0x10ec0260:
1276 snd_hda_codec_write(codec, 0x1a, 0,
1277 AC_VERB_SET_COEF_INDEX, 7);
1278 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1279 AC_VERB_GET_PROC_COEF, 0);
1280 snd_hda_codec_write(codec, 0x1a, 0,
1281 AC_VERB_SET_COEF_INDEX, 7);
1282 snd_hda_codec_write(codec, 0x1a, 0,
1283 AC_VERB_SET_PROC_COEF,
1284 tmp | 0x2010);
1285 break;
1286 case 0x10ec0262:
1287 case 0x10ec0880:
1288 case 0x10ec0882:
1289 case 0x10ec0883:
1290 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001291 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001292 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001293 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001294 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001295 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001296 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001297 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001298#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001299 case 0x10ec0267:
1300 case 0x10ec0268:
1301 snd_hda_codec_write(codec, 0x20, 0,
1302 AC_VERB_SET_COEF_INDEX, 7);
1303 tmp = snd_hda_codec_read(codec, 0x20, 0,
1304 AC_VERB_GET_PROC_COEF, 0);
1305 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001306 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001307 snd_hda_codec_write(codec, 0x20, 0,
1308 AC_VERB_SET_PROC_COEF,
1309 tmp | 0x3000);
1310 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001311#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001312 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001313 break;
1314 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001315}
Kailang Yangea1fb292008-08-26 12:58:38 +02001316
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001317static void alc_init_auto_hp(struct hda_codec *codec)
1318{
1319 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001320 struct auto_pin_cfg *cfg = &spec->autocfg;
1321 int i;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001322
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001323 if (!cfg->hp_pins[0]) {
1324 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001325 return;
1326 }
1327
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001328 if (!cfg->speaker_pins[0]) {
1329 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
1330 return;
1331 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1332 sizeof(cfg->speaker_pins));
1333 cfg->speaker_outs = cfg->line_outs;
1334 }
1335
1336 if (!cfg->hp_pins[0]) {
1337 memcpy(cfg->hp_pins, cfg->line_out_pins,
1338 sizeof(cfg->hp_pins));
1339 cfg->hp_outs = cfg->line_outs;
1340 }
1341
1342 for (i = 0; i < cfg->hp_outs; i++) {
1343 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1344 cfg->hp_pins[i]);
1345 snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0,
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001346 AC_VERB_SET_UNSOLICITED_ENABLE,
1347 AC_USRSP_EN | ALC880_HP_EVENT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001348 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001349 spec->unsol_event = alc_sku_unsol_event;
1350}
1351
Takashi Iwai6c819492009-08-10 18:47:44 +02001352static void alc_init_auto_mic(struct hda_codec *codec)
1353{
1354 struct alc_spec *spec = codec->spec;
1355 struct auto_pin_cfg *cfg = &spec->autocfg;
1356 hda_nid_t fixed, ext;
1357 int i;
1358
1359 /* there must be only two mic inputs exclusively */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001360 for (i = 0; i < cfg->num_inputs; i++)
Takashi Iwai86e29592010-09-09 14:50:17 +02001361 if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
Takashi Iwai6c819492009-08-10 18:47:44 +02001362 return;
1363
1364 fixed = ext = 0;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001365 for (i = 0; i < cfg->num_inputs; i++) {
1366 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai6c819492009-08-10 18:47:44 +02001367 unsigned int defcfg;
Takashi Iwai6c819492009-08-10 18:47:44 +02001368 defcfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001369 switch (snd_hda_get_input_pin_attr(defcfg)) {
1370 case INPUT_PIN_ATTR_INT:
Takashi Iwai6c819492009-08-10 18:47:44 +02001371 if (fixed)
1372 return; /* already occupied */
1373 fixed = nid;
1374 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001375 case INPUT_PIN_ATTR_UNUSED:
1376 return; /* invalid entry */
1377 default:
Takashi Iwai6c819492009-08-10 18:47:44 +02001378 if (ext)
1379 return; /* already occupied */
1380 ext = nid;
1381 break;
Takashi Iwai6c819492009-08-10 18:47:44 +02001382 }
1383 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001384 if (!ext || !fixed)
1385 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001386 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1387 return; /* no unsol support */
1388 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1389 ext, fixed);
1390 spec->ext_mic.pin = ext;
1391 spec->int_mic.pin = fixed;
1392 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1393 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1394 spec->auto_mic = 1;
1395 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1396 AC_VERB_SET_UNSOLICITED_ENABLE,
1397 AC_USRSP_EN | ALC880_MIC_EVENT);
1398 spec->unsol_event = alc_sku_unsol_event;
1399}
1400
David Henningsson90622912010-10-14 14:50:18 +02001401/* Could be any non-zero and even value. When used as fixup, tells
1402 * the driver to ignore any present sku defines.
1403 */
1404#define ALC_FIXUP_SKU_IGNORE (2)
1405
Kailang Yangda00c242010-03-19 11:23:45 +01001406static int alc_auto_parse_customize_define(struct hda_codec *codec)
1407{
1408 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001409 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001410 struct alc_spec *spec = codec->spec;
1411
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001412 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1413
David Henningsson90622912010-10-14 14:50:18 +02001414 if (spec->cdefine.fixup) {
1415 ass = spec->cdefine.sku_cfg;
1416 if (ass == ALC_FIXUP_SKU_IGNORE)
1417 return -1;
1418 goto do_sku;
1419 }
1420
Kailang Yangda00c242010-03-19 11:23:45 +01001421 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001422 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +01001423 goto do_sku;
1424
1425 nid = 0x1d;
1426 if (codec->vendor_id == 0x10ec0260)
1427 nid = 0x17;
1428 ass = snd_hda_codec_get_pincfg(codec, nid);
1429
1430 if (!(ass & 1)) {
1431 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1432 codec->chip_name, ass);
1433 return -1;
1434 }
1435
1436 /* check sum */
1437 tmp = 0;
1438 for (i = 1; i < 16; i++) {
1439 if ((ass >> i) & 1)
1440 tmp++;
1441 }
1442 if (((ass >> 16) & 0xf) != tmp)
1443 return -1;
1444
1445 spec->cdefine.port_connectivity = ass >> 30;
1446 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1447 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1448 spec->cdefine.customization = ass >> 8;
1449do_sku:
1450 spec->cdefine.sku_cfg = ass;
1451 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1452 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1453 spec->cdefine.swap = (ass & 0x2) >> 1;
1454 spec->cdefine.override = ass & 0x1;
1455
1456 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1457 nid, spec->cdefine.sku_cfg);
1458 snd_printd("SKU: port_connectivity=0x%x\n",
1459 spec->cdefine.port_connectivity);
1460 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1461 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1462 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1463 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1464 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1465 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1466 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1467
1468 return 0;
1469}
1470
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001471/* check subsystem ID and set up device-specific initialization;
1472 * return 1 if initialized, 0 if invalid SSID
1473 */
1474/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1475 * 31 ~ 16 : Manufacture ID
1476 * 15 ~ 8 : SKU ID
1477 * 7 ~ 0 : Assembly ID
1478 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1479 */
1480static int alc_subsystem_id(struct hda_codec *codec,
1481 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001482 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001483{
1484 unsigned int ass, tmp, i;
1485 unsigned nid;
1486 struct alc_spec *spec = codec->spec;
1487
David Henningsson90622912010-10-14 14:50:18 +02001488 if (spec->cdefine.fixup) {
1489 ass = spec->cdefine.sku_cfg;
1490 if (ass == ALC_FIXUP_SKU_IGNORE)
1491 return 0;
1492 goto do_sku;
1493 }
1494
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001495 ass = codec->subsystem_id & 0xffff;
1496 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1497 goto do_sku;
1498
1499 /* invalid SSID, check the special NID pin defcfg instead */
1500 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001501 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001502 * 29~21 : reserve
1503 * 20 : PCBEEP input
1504 * 19~16 : Check sum (15:1)
1505 * 15~1 : Custom
1506 * 0 : override
1507 */
1508 nid = 0x1d;
1509 if (codec->vendor_id == 0x10ec0260)
1510 nid = 0x17;
1511 ass = snd_hda_codec_get_pincfg(codec, nid);
1512 snd_printd("realtek: No valid SSID, "
1513 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001514 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001515 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001516 return 0;
1517 if ((ass >> 30) != 1) /* no physical connection */
1518 return 0;
1519
1520 /* check sum */
1521 tmp = 0;
1522 for (i = 1; i < 16; i++) {
1523 if ((ass >> i) & 1)
1524 tmp++;
1525 }
1526 if (((ass >> 16) & 0xf) != tmp)
1527 return 0;
1528do_sku:
1529 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1530 ass & 0xffff, codec->vendor_id);
1531 /*
1532 * 0 : override
1533 * 1 : Swap Jack
1534 * 2 : 0 --> Desktop, 1 --> Laptop
1535 * 3~5 : External Amplifier control
1536 * 7~6 : Reserved
1537 */
1538 tmp = (ass & 0x38) >> 3; /* external Amp control */
1539 switch (tmp) {
1540 case 1:
1541 spec->init_amp = ALC_INIT_GPIO1;
1542 break;
1543 case 3:
1544 spec->init_amp = ALC_INIT_GPIO2;
1545 break;
1546 case 7:
1547 spec->init_amp = ALC_INIT_GPIO3;
1548 break;
1549 case 5:
Takashi Iwai5a8cfb42010-11-26 17:11:18 +01001550 default:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001551 spec->init_amp = ALC_INIT_DEFAULT;
1552 break;
1553 }
1554
1555 /* is laptop or Desktop and enable the function "Mute internal speaker
1556 * when the external headphone out jack is plugged"
1557 */
1558 if (!(ass & 0x8000))
1559 return 1;
1560 /*
1561 * 10~8 : Jack location
1562 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1563 * 14~13: Resvered
1564 * 15 : 1 --> enable the function "Mute internal speaker
1565 * when the external headphone out jack is plugged"
1566 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001567 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001568 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001569 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1570 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001571 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001572 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001573 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001574 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001575 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001576 else if (tmp == 3)
1577 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001578 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001579 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001580 for (i = 0; i < spec->autocfg.line_outs; i++)
1581 if (spec->autocfg.line_out_pins[i] == nid)
1582 return 1;
1583 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001584 }
1585
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001586 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001587 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001588 return 1;
1589}
Kailang Yangea1fb292008-08-26 12:58:38 +02001590
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001591static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001592 hda_nid_t porta, hda_nid_t porte,
1593 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001594{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001595 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001596 struct alc_spec *spec = codec->spec;
1597 snd_printd("realtek: "
1598 "Enable default setup for auto mode as fallback\n");
1599 spec->init_amp = ALC_INIT_DEFAULT;
1600 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001601 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001602 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001603}
1604
Takashi Iwai41e41f12005-06-08 14:48:49 +02001605/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001606 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001607 */
1608
1609struct alc_pincfg {
1610 hda_nid_t nid;
1611 u32 val;
1612};
1613
Todd Broche1eb5f12010-12-06 11:19:51 -08001614struct alc_model_fixup {
1615 const int id;
1616 const char *name;
1617};
1618
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001619struct alc_fixup {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001620 int type;
Takashi Iwai361fe6e2011-01-14 09:55:32 +01001621 bool chained;
1622 int chain_id;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001623 union {
1624 unsigned int sku;
1625 const struct alc_pincfg *pins;
1626 const struct hda_verb *verbs;
1627 void (*func)(struct hda_codec *codec,
1628 const struct alc_fixup *fix,
1629 int action);
1630 } v;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001631};
1632
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001633enum {
1634 ALC_FIXUP_INVALID,
1635 ALC_FIXUP_SKU,
1636 ALC_FIXUP_PINS,
1637 ALC_FIXUP_VERBS,
1638 ALC_FIXUP_FUNC,
1639};
Takashi Iwaif95474e2007-07-10 00:47:43 +02001640
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001641enum {
1642 ALC_FIXUP_ACT_PRE_PROBE,
1643 ALC_FIXUP_ACT_PROBE,
Takashi Iwai58701122011-01-13 15:41:45 +01001644 ALC_FIXUP_ACT_INIT,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001645};
1646
1647static void alc_apply_fixup(struct hda_codec *codec, int action)
1648{
1649 struct alc_spec *spec = codec->spec;
1650 int id = spec->fixup_id;
Takashi Iwaiaa1d0c52011-01-19 17:27:58 +01001651#ifdef CONFIG_SND_DEBUG_VERBOSE
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001652 const char *modelname = spec->fixup_name;
Takashi Iwaiaa1d0c52011-01-19 17:27:58 +01001653#endif
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001654 int depth = 0;
1655
1656 if (!spec->fixup_list)
1657 return;
1658
1659 while (id >= 0) {
1660 const struct alc_fixup *fix = spec->fixup_list + id;
1661 const struct alc_pincfg *cfg;
1662
1663 switch (fix->type) {
1664 case ALC_FIXUP_SKU:
1665 if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku)
1666 break;;
1667 snd_printdd(KERN_INFO "hda_codec: %s: "
1668 "Apply sku override for %s\n",
1669 codec->chip_name, modelname);
1670 spec->cdefine.sku_cfg = fix->v.sku;
1671 spec->cdefine.fixup = 1;
1672 break;
1673 case ALC_FIXUP_PINS:
1674 cfg = fix->v.pins;
1675 if (action != ALC_FIXUP_ACT_PRE_PROBE || !cfg)
1676 break;
1677 snd_printdd(KERN_INFO "hda_codec: %s: "
1678 "Apply pincfg for %s\n",
1679 codec->chip_name, modelname);
1680 for (; cfg->nid; cfg++)
1681 snd_hda_codec_set_pincfg(codec, cfg->nid,
1682 cfg->val);
1683 break;
1684 case ALC_FIXUP_VERBS:
1685 if (action != ALC_FIXUP_ACT_PROBE || !fix->v.verbs)
1686 break;
1687 snd_printdd(KERN_INFO "hda_codec: %s: "
1688 "Apply fix-verbs for %s\n",
1689 codec->chip_name, modelname);
1690 add_verb(codec->spec, fix->v.verbs);
1691 break;
1692 case ALC_FIXUP_FUNC:
1693 if (!fix->v.func)
1694 break;
1695 snd_printdd(KERN_INFO "hda_codec: %s: "
1696 "Apply fix-func for %s\n",
1697 codec->chip_name, modelname);
1698 fix->v.func(codec, fix, action);
1699 break;
1700 default:
1701 snd_printk(KERN_ERR "hda_codec: %s: "
1702 "Invalid fixup type %d\n",
1703 codec->chip_name, fix->type);
1704 break;
1705 }
1706 if (!fix[id].chained)
1707 break;
1708 if (++depth > 10)
1709 break;
1710 id = fix[id].chain_id;
Takashi Iwai9d578832010-11-22 13:29:19 +01001711 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001712}
1713
Todd Broche1eb5f12010-12-06 11:19:51 -08001714static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001715 const struct alc_model_fixup *models,
1716 const struct snd_pci_quirk *quirk,
1717 const struct alc_fixup *fixlist)
Todd Broche1eb5f12010-12-06 11:19:51 -08001718{
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001719 struct alc_spec *spec = codec->spec;
1720 int id = -1;
1721 const char *name = NULL;
Todd Broche1eb5f12010-12-06 11:19:51 -08001722
Todd Broche1eb5f12010-12-06 11:19:51 -08001723 if (codec->modelname && models) {
1724 while (models->name) {
1725 if (!strcmp(codec->modelname, models->name)) {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001726 id = models->id;
1727 name = models->name;
Todd Broche1eb5f12010-12-06 11:19:51 -08001728 break;
1729 }
1730 models++;
1731 }
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001732 }
1733 if (id < 0) {
1734 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1735 if (quirk) {
1736 id = quirk->value;
1737#ifdef CONFIG_SND_DEBUG_VERBOSE
1738 name = quirk->name;
1739#endif
1740 }
1741 }
1742
1743 spec->fixup_id = id;
1744 if (id >= 0) {
1745 spec->fixup_list = fixlist;
1746 spec->fixup_name = name;
Todd Broche1eb5f12010-12-06 11:19:51 -08001747 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001748}
1749
Kailang Yang274693f2009-12-03 10:07:50 +01001750static int alc_read_coef_idx(struct hda_codec *codec,
1751 unsigned int coef_idx)
1752{
1753 unsigned int val;
1754 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1755 coef_idx);
1756 val = snd_hda_codec_read(codec, 0x20, 0,
1757 AC_VERB_GET_PROC_COEF, 0);
1758 return val;
1759}
1760
Kailang Yang977ddd62010-09-15 10:02:29 +02001761static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1762 unsigned int coef_val)
1763{
1764 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1765 coef_idx);
1766 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1767 coef_val);
1768}
1769
Takashi Iwai757899a2010-07-30 10:48:14 +02001770/* set right pin controls for digital I/O */
1771static void alc_auto_init_digital(struct hda_codec *codec)
1772{
1773 struct alc_spec *spec = codec->spec;
1774 int i;
1775 hda_nid_t pin;
1776
1777 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1778 pin = spec->autocfg.dig_out_pins[i];
1779 if (pin) {
1780 snd_hda_codec_write(codec, pin, 0,
1781 AC_VERB_SET_PIN_WIDGET_CONTROL,
1782 PIN_OUT);
1783 }
1784 }
1785 pin = spec->autocfg.dig_in_pin;
1786 if (pin)
1787 snd_hda_codec_write(codec, pin, 0,
1788 AC_VERB_SET_PIN_WIDGET_CONTROL,
1789 PIN_IN);
1790}
1791
1792/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1793static void alc_auto_parse_digital(struct hda_codec *codec)
1794{
1795 struct alc_spec *spec = codec->spec;
1796 int i, err;
1797 hda_nid_t dig_nid;
1798
1799 /* support multiple SPDIFs; the secondary is set up as a slave */
1800 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1801 err = snd_hda_get_connections(codec,
1802 spec->autocfg.dig_out_pins[i],
1803 &dig_nid, 1);
1804 if (err < 0)
1805 continue;
1806 if (!i) {
1807 spec->multiout.dig_out_nid = dig_nid;
1808 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1809 } else {
1810 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1811 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1812 break;
1813 spec->slave_dig_outs[i - 1] = dig_nid;
1814 }
1815 }
1816
1817 if (spec->autocfg.dig_in_pin) {
Takashi Iwai01fdf182010-09-24 09:09:42 +02001818 dig_nid = codec->start_nid;
1819 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
1820 unsigned int wcaps = get_wcaps(codec, dig_nid);
1821 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
1822 continue;
1823 if (!(wcaps & AC_WCAP_DIGITAL))
1824 continue;
1825 if (!(wcaps & AC_WCAP_CONN_LIST))
1826 continue;
1827 err = get_connection_index(codec, dig_nid,
1828 spec->autocfg.dig_in_pin);
1829 if (err >= 0) {
1830 spec->dig_in_nid = dig_nid;
1831 break;
1832 }
1833 }
Takashi Iwai757899a2010-07-30 10:48:14 +02001834 }
1835}
1836
Takashi Iwaif95474e2007-07-10 00:47:43 +02001837/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001838 * ALC888
1839 */
1840
1841/*
1842 * 2ch mode
1843 */
1844static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1845/* Mic-in jack as mic in */
1846 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1847 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1848/* Line-in jack as Line in */
1849 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1850 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1851/* Line-Out as Front */
1852 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1853 { } /* end */
1854};
1855
1856/*
1857 * 4ch mode
1858 */
1859static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1860/* Mic-in jack as mic in */
1861 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1862 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1863/* Line-in jack as Surround */
1864 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1865 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1866/* Line-Out as Front */
1867 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1868 { } /* end */
1869};
1870
1871/*
1872 * 6ch mode
1873 */
1874static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1875/* Mic-in jack as CLFE */
1876 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1877 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1878/* Line-in jack as Surround */
1879 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1880 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1881/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1882 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1883 { } /* end */
1884};
1885
1886/*
1887 * 8ch mode
1888 */
1889static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1890/* Mic-in jack as CLFE */
1891 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1892 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1893/* Line-in jack as Surround */
1894 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1895 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1896/* Line-Out as Side */
1897 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1898 { } /* end */
1899};
1900
1901static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1902 { 2, alc888_4ST_ch2_intel_init },
1903 { 4, alc888_4ST_ch4_intel_init },
1904 { 6, alc888_4ST_ch6_intel_init },
1905 { 8, alc888_4ST_ch8_intel_init },
1906};
1907
1908/*
1909 * ALC888 Fujitsu Siemens Amillo xa3530
1910 */
1911
1912static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1913/* Front Mic: set to PIN_IN (empty by default) */
1914 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1915/* Connect Internal HP to Front */
1916 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1917 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1918 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1919/* Connect Bass HP to Front */
1920 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1921 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1922 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1923/* Connect Line-Out side jack (SPDIF) to Side */
1924 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1925 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1926 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1927/* Connect Mic jack to CLFE */
1928 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1929 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1930 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1931/* Connect Line-in jack to Surround */
1932 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1933 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1934 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1935/* Connect HP out jack to Front */
1936 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1937 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1938 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1939/* Enable unsolicited event for HP jack and Line-out jack */
1940 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1941 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1942 {}
1943};
1944
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001945static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001946{
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001947 alc_automute_speaker(codec, 0);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001948}
1949
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001950static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1951 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001952{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001953 if (codec->vendor_id == 0x10ec0880)
1954 res >>= 28;
1955 else
1956 res >>= 26;
1957 if (res == ALC880_HP_EVENT)
1958 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001959}
1960
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001961static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001962{
1963 struct alc_spec *spec = codec->spec;
1964
1965 spec->autocfg.hp_pins[0] = 0x15;
1966 spec->autocfg.speaker_pins[0] = 0x14;
1967 spec->autocfg.speaker_pins[1] = 0x16;
1968 spec->autocfg.speaker_pins[2] = 0x17;
1969 spec->autocfg.speaker_pins[3] = 0x19;
1970 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001971}
1972
1973static void alc889_intel_init_hook(struct hda_codec *codec)
1974{
1975 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001976 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001977}
1978
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001979static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001980{
1981 struct alc_spec *spec = codec->spec;
1982
1983 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1984 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1985 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1986 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001987}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001988
1989/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001990 * ALC888 Acer Aspire 4930G model
1991 */
1992
1993static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1994/* Front Mic: set to PIN_IN (empty by default) */
1995 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1996/* Unselect Front Mic by default in input mixer 3 */
1997 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001998/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001999 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2000/* Connect Internal HP to front */
2001 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2002 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2003 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2004/* Connect HP out to front */
2005 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2006 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2007 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie2e93292011-01-12 08:03:39 +01002008 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002009 { }
2010};
2011
Hector Martin3b315d72009-06-02 10:54:19 +02002012/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01002013 * ALC888 Acer Aspire 6530G model
2014 */
2015
2016static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01002017/* Route to built-in subwoofer as well as speakers */
2018 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2019 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2020 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2021 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002022/* Bias voltage on for external mic port */
2023 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02002024/* Front Mic: set to PIN_IN (empty by default) */
2025 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2026/* Unselect Front Mic by default in input mixer 3 */
2027 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002028/* Enable unsolicited event for HP jack */
2029 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2030/* Enable speaker output */
2031 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2032 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01002033 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002034/* Enable headphone output */
2035 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2036 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2037 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01002038 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002039 { }
2040};
2041
2042/*
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002043 *ALC888 Acer Aspire 7730G model
2044 */
2045
2046static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
2047/* Bias voltage on for external mic port */
2048 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
2049/* Front Mic: set to PIN_IN (empty by default) */
2050 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2051/* Unselect Front Mic by default in input mixer 3 */
2052 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2053/* Enable unsolicited event for HP jack */
2054 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2055/* Enable speaker output */
2056 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2057 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2058 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
2059/* Enable headphone output */
2060 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2061 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2062 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2063 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
2064/*Enable internal subwoofer */
2065 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2066 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2067 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
2068 {0x17, AC_VERB_SET_EAPD_BTLENABLE, 2},
2069 { }
2070};
2071
2072/*
Hector Martin018df412009-06-04 00:13:40 +02002073 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02002074 */
2075
Hector Martin018df412009-06-04 00:13:40 +02002076static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02002077/* Front Mic: set to PIN_IN (empty by default) */
2078 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2079/* Unselect Front Mic by default in input mixer 3 */
2080 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2081/* Enable unsolicited event for HP jack */
2082 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2083/* Connect Internal Front to Front */
2084 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2085 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2086 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2087/* Connect Internal Rear to Rear */
2088 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2089 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2090 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
2091/* Connect Internal CLFE to CLFE */
2092 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2093 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2094 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
2095/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02002096 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02002097 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2098 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2099/* Enable all DACs */
2100/* DAC DISABLE/MUTE 1? */
2101/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
2102 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
2103 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2104/* DAC DISABLE/MUTE 2? */
2105/* some bit here disables the other DACs. Init=0x4900 */
2106 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
2107 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02002108/* DMIC fix
2109 * This laptop has a stereo digital microphone. The mics are only 1cm apart
2110 * which makes the stereo useless. However, either the mic or the ALC889
2111 * makes the signal become a difference/sum signal instead of standard
2112 * stereo, which is annoying. So instead we flip this bit which makes the
2113 * codec replicate the sum signal to both channels, turning it into a
2114 * normal mono mic.
2115 */
2116/* DMIC_CONTROL? Init value = 0x0001 */
2117 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
2118 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02002119 { }
2120};
2121
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002122static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002123 /* Front mic only available on one ADC */
2124 {
2125 .num_items = 4,
2126 .items = {
2127 { "Mic", 0x0 },
2128 { "Line", 0x2 },
2129 { "CD", 0x4 },
2130 { "Front Mic", 0xb },
2131 },
2132 },
2133 {
2134 .num_items = 3,
2135 .items = {
2136 { "Mic", 0x0 },
2137 { "Line", 0x2 },
2138 { "CD", 0x4 },
2139 },
2140 }
2141};
2142
Tony Vroond2fd4b02009-06-21 00:40:10 +01002143static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2144 /* Interal mic only available on one ADC */
2145 {
Tony Vroon684a8842009-06-26 09:27:50 +01002146 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002147 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +01002148 { "Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002149 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002150 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002151 { "Input Mix", 0xa },
David Henningsson28c4edb2010-12-20 14:24:29 +01002152 { "Internal Mic", 0xb },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002153 },
2154 },
2155 {
Tony Vroon684a8842009-06-26 09:27:50 +01002156 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002157 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +01002158 { "Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002159 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002160 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002161 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002162 },
2163 }
2164};
2165
Hector Martin018df412009-06-04 00:13:40 +02002166static struct hda_input_mux alc889_capture_sources[3] = {
2167 /* Digital mic only available on first "ADC" */
2168 {
2169 .num_items = 5,
2170 .items = {
2171 { "Mic", 0x0 },
2172 { "Line", 0x2 },
2173 { "CD", 0x4 },
2174 { "Front Mic", 0xb },
2175 { "Input Mix", 0xa },
2176 },
2177 },
2178 {
2179 .num_items = 4,
2180 .items = {
2181 { "Mic", 0x0 },
2182 { "Line", 0x2 },
2183 { "CD", 0x4 },
2184 { "Input Mix", 0xa },
2185 },
2186 },
2187 {
2188 .num_items = 4,
2189 .items = {
2190 { "Mic", 0x0 },
2191 { "Line", 0x2 },
2192 { "CD", 0x4 },
2193 { "Input Mix", 0xa },
2194 },
2195 }
2196};
2197
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002198static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002199 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2200 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2201 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2202 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2203 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2204 HDA_OUTPUT),
2205 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2206 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2207 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2208 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2209 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2210 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2211 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2212 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2213 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2214 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01002215 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002216 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002217 { } /* end */
2218};
2219
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002220static struct snd_kcontrol_new alc888_acer_aspire_4930g_mixer[] = {
2221 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2222 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2223 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2224 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Łukasz Wojniłowicz786c51f2011-02-24 10:03:31 +01002225 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002226 HDA_OUTPUT),
Łukasz Wojniłowicz786c51f2011-02-24 10:03:31 +01002227 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2228 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2229 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2230 HDA_CODEC_VOLUME_MONO("Internal LFE Playback Volume", 0x0f, 1, 0x0, HDA_OUTPUT),
2231 HDA_BIND_MUTE_MONO("Internal LFE Playback Switch", 0x0f, 1, 2, HDA_INPUT),
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002232 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2233 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2234 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2235 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2236 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2237 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
2238 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2239 { } /* end */
2240};
2241
Hector Martin556eea92009-12-20 22:51:23 +01002242static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2243 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2244 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2245 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2246 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2247 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2248 HDA_OUTPUT),
2249 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2250 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2251 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2252 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2253 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2254 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01002255 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hector Martin556eea92009-12-20 22:51:23 +01002256 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2257 { } /* end */
2258};
2259
2260
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002261static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002262{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002263 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002264
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002265 spec->autocfg.hp_pins[0] = 0x15;
2266 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01002267 spec->autocfg.speaker_pins[1] = 0x16;
2268 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002269}
2270
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002271static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02002272{
2273 struct alc_spec *spec = codec->spec;
2274
2275 spec->autocfg.hp_pins[0] = 0x15;
2276 spec->autocfg.speaker_pins[0] = 0x14;
2277 spec->autocfg.speaker_pins[1] = 0x16;
2278 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02002279}
2280
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002281static void alc888_acer_aspire_7730g_setup(struct hda_codec *codec)
2282{
2283 struct alc_spec *spec = codec->spec;
2284
2285 spec->autocfg.hp_pins[0] = 0x15;
2286 spec->autocfg.speaker_pins[0] = 0x14;
2287 spec->autocfg.speaker_pins[1] = 0x16;
2288 spec->autocfg.speaker_pins[2] = 0x17;
2289}
2290
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002291static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02002292{
2293 struct alc_spec *spec = codec->spec;
2294
2295 spec->autocfg.hp_pins[0] = 0x15;
2296 spec->autocfg.speaker_pins[0] = 0x14;
2297 spec->autocfg.speaker_pins[1] = 0x16;
2298 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02002299}
2300
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002301/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002302 * ALC880 3-stack model
2303 *
2304 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002305 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2306 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07002307 */
2308
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002309static hda_nid_t alc880_dac_nids[4] = {
2310 /* front, rear, clfe, rear_surr */
2311 0x02, 0x05, 0x04, 0x03
2312};
2313
2314static hda_nid_t alc880_adc_nids[3] = {
2315 /* ADC0-2 */
2316 0x07, 0x08, 0x09,
2317};
2318
2319/* The datasheet says the node 0x07 is connected from inputs,
2320 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01002321 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07002322 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002323static hda_nid_t alc880_adc_nids_alt[2] = {
2324 /* ADC1-2 */
2325 0x08, 0x09,
2326};
2327
2328#define ALC880_DIGOUT_NID 0x06
2329#define ALC880_DIGIN_NID 0x0a
2330
2331static struct hda_input_mux alc880_capture_source = {
2332 .num_items = 4,
2333 .items = {
2334 { "Mic", 0x0 },
2335 { "Front Mic", 0x3 },
2336 { "Line", 0x2 },
2337 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002338 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002339};
2340
2341/* channel source setting (2/6 channel selection for 3-stack) */
2342/* 2ch mode */
2343static struct hda_verb alc880_threestack_ch2_init[] = {
2344 /* set line-in to input, mute it */
2345 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2346 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2347 /* set mic-in to input vref 80%, mute it */
2348 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2349 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002350 { } /* end */
2351};
2352
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002353/* 6ch mode */
2354static struct hda_verb alc880_threestack_ch6_init[] = {
2355 /* set line-in to output, unmute it */
2356 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2357 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2358 /* set mic-in to output, unmute it */
2359 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2360 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2361 { } /* end */
2362};
2363
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002364static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002365 { 2, alc880_threestack_ch2_init },
2366 { 6, alc880_threestack_ch6_init },
2367};
2368
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002369static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002370 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002371 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002372 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002373 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002374 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2375 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002376 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2377 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002378 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2379 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2380 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2381 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2382 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2383 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2384 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2385 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002386 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002387 {
2388 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2389 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002390 .info = alc_ch_mode_info,
2391 .get = alc_ch_mode_get,
2392 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002393 },
2394 { } /* end */
2395};
2396
2397/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002398static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2399 struct snd_ctl_elem_info *uinfo)
2400{
2401 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2402 struct alc_spec *spec = codec->spec;
2403 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002404
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002405 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002406 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2407 HDA_INPUT);
2408 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002409 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002410 return err;
2411}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002412
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002413static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2414 unsigned int size, unsigned int __user *tlv)
2415{
2416 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2417 struct alc_spec *spec = codec->spec;
2418 int err;
2419
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002420 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002421 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2422 HDA_INPUT);
2423 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002424 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002425 return err;
2426}
2427
2428typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2429 struct snd_ctl_elem_value *ucontrol);
2430
2431static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2432 struct snd_ctl_elem_value *ucontrol,
2433 getput_call_t func)
2434{
2435 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2436 struct alc_spec *spec = codec->spec;
2437 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2438 int err;
2439
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002440 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002441 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2442 3, 0, HDA_INPUT);
2443 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002444 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002445 return err;
2446}
2447
2448static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2449 struct snd_ctl_elem_value *ucontrol)
2450{
2451 return alc_cap_getput_caller(kcontrol, ucontrol,
2452 snd_hda_mixer_amp_volume_get);
2453}
2454
2455static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2456 struct snd_ctl_elem_value *ucontrol)
2457{
2458 return alc_cap_getput_caller(kcontrol, ucontrol,
2459 snd_hda_mixer_amp_volume_put);
2460}
2461
2462/* capture mixer elements */
2463#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2464
2465static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2466 struct snd_ctl_elem_value *ucontrol)
2467{
2468 return alc_cap_getput_caller(kcontrol, ucontrol,
2469 snd_hda_mixer_amp_switch_get);
2470}
2471
2472static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2473 struct snd_ctl_elem_value *ucontrol)
2474{
2475 return alc_cap_getput_caller(kcontrol, ucontrol,
2476 snd_hda_mixer_amp_switch_put);
2477}
2478
Takashi Iwaia23b6882009-03-23 15:21:36 +01002479#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002480 { \
2481 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2482 .name = "Capture Switch", \
2483 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2484 .count = num, \
2485 .info = alc_cap_sw_info, \
2486 .get = alc_cap_sw_get, \
2487 .put = alc_cap_sw_put, \
2488 }, \
2489 { \
2490 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2491 .name = "Capture Volume", \
2492 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2493 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2494 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2495 .count = num, \
2496 .info = alc_cap_vol_info, \
2497 .get = alc_cap_vol_get, \
2498 .put = alc_cap_vol_put, \
2499 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002500 }
2501
2502#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002503 { \
2504 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2505 /* .name = "Capture Source", */ \
2506 .name = "Input Source", \
2507 .count = num, \
2508 .info = alc_mux_enum_info, \
2509 .get = alc_mux_enum_get, \
2510 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002511 }
2512
2513#define DEFINE_CAPMIX(num) \
2514static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2515 _DEFINE_CAPMIX(num), \
2516 _DEFINE_CAPSRC(num), \
2517 { } /* end */ \
2518}
2519
2520#define DEFINE_CAPMIX_NOSRC(num) \
2521static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2522 _DEFINE_CAPMIX(num), \
2523 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002524}
2525
2526/* up to three ADCs */
2527DEFINE_CAPMIX(1);
2528DEFINE_CAPMIX(2);
2529DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002530DEFINE_CAPMIX_NOSRC(1);
2531DEFINE_CAPMIX_NOSRC(2);
2532DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002533
2534/*
2535 * ALC880 5-stack model
2536 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002537 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2538 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002539 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2540 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2541 */
2542
2543/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002544static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002545 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002546 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002547 { } /* end */
2548};
2549
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002550/* channel source setting (6/8 channel selection for 5-stack) */
2551/* 6ch mode */
2552static struct hda_verb alc880_fivestack_ch6_init[] = {
2553 /* set line-in to input, mute it */
2554 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2555 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002556 { } /* end */
2557};
2558
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002559/* 8ch mode */
2560static struct hda_verb alc880_fivestack_ch8_init[] = {
2561 /* set line-in to output, unmute it */
2562 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2563 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2564 { } /* end */
2565};
2566
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002567static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002568 { 6, alc880_fivestack_ch6_init },
2569 { 8, alc880_fivestack_ch8_init },
2570};
2571
2572
2573/*
2574 * ALC880 6-stack model
2575 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002576 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2577 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002578 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2579 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2580 */
2581
2582static hda_nid_t alc880_6st_dac_nids[4] = {
2583 /* front, rear, clfe, rear_surr */
2584 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002585};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002586
2587static struct hda_input_mux alc880_6stack_capture_source = {
2588 .num_items = 4,
2589 .items = {
2590 { "Mic", 0x0 },
2591 { "Front Mic", 0x1 },
2592 { "Line", 0x2 },
2593 { "CD", 0x4 },
2594 },
2595};
2596
2597/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002598static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002599 { 8, NULL },
2600};
2601
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002602static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002603 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002604 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002605 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002606 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002607 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2608 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002609 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2610 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002611 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002612 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002613 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2614 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2615 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2616 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2617 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2618 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2619 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2620 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002621 {
2622 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2623 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002624 .info = alc_ch_mode_info,
2625 .get = alc_ch_mode_get,
2626 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002627 },
2628 { } /* end */
2629};
2630
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002631
2632/*
2633 * ALC880 W810 model
2634 *
2635 * W810 has rear IO for:
2636 * Front (DAC 02)
2637 * Surround (DAC 03)
2638 * Center/LFE (DAC 04)
2639 * Digital out (06)
2640 *
2641 * The system also has a pair of internal speakers, and a headphone jack.
2642 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002643 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002644 * There is a variable resistor to control the speaker or headphone
2645 * volume. This is a hardware-only device without a software API.
2646 *
2647 * Plugging headphones in will disable the internal speakers. This is
2648 * implemented in hardware, not via the driver using jack sense. In
2649 * a similar fashion, plugging into the rear socket marked "front" will
2650 * disable both the speakers and headphones.
2651 *
2652 * For input, there's a microphone jack, and an "audio in" jack.
2653 * These may not do anything useful with this driver yet, because I
2654 * haven't setup any initialization verbs for these yet...
2655 */
2656
2657static hda_nid_t alc880_w810_dac_nids[3] = {
2658 /* front, rear/surround, clfe */
2659 0x02, 0x03, 0x04
2660};
2661
2662/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002663static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002664 { 6, NULL }
2665};
2666
2667/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002668static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002669 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002670 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002671 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002672 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002673 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2674 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002675 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2676 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002677 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2678 { } /* end */
2679};
2680
2681
2682/*
2683 * Z710V model
2684 *
2685 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002686 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2687 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002688 */
2689
2690static hda_nid_t alc880_z71v_dac_nids[1] = {
2691 0x02
2692};
2693#define ALC880_Z71V_HP_DAC 0x03
2694
2695/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002696static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002697 { 2, NULL }
2698};
2699
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002700static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002701 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002702 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002703 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002704 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002705 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2706 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2709 { } /* end */
2710};
2711
2712
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002713/*
2714 * ALC880 F1734 model
2715 *
2716 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2717 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2718 */
2719
2720static hda_nid_t alc880_f1734_dac_nids[1] = {
2721 0x03
2722};
2723#define ALC880_F1734_HP_DAC 0x02
2724
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002725static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002726 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002727 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002728 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2729 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002730 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2731 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002732 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2733 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002734 { } /* end */
2735};
2736
Takashi Iwai937b4162008-02-11 14:52:36 +01002737static struct hda_input_mux alc880_f1734_capture_source = {
2738 .num_items = 2,
2739 .items = {
2740 { "Mic", 0x1 },
2741 { "CD", 0x4 },
2742 },
2743};
2744
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002745
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002746/*
2747 * ALC880 ASUS model
2748 *
2749 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2750 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2751 * Mic = 0x18, Line = 0x1a
2752 */
2753
2754#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2755#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2756
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002757static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002758 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002759 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002760 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002761 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002762 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2763 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002764 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2765 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002766 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2767 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2768 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2769 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2770 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2771 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002772 {
2773 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2774 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002775 .info = alc_ch_mode_info,
2776 .get = alc_ch_mode_get,
2777 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002778 },
2779 { } /* end */
2780};
2781
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002782/*
2783 * ALC880 ASUS W1V model
2784 *
2785 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2786 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2787 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2788 */
2789
2790/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002791static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002792 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2793 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002794 { } /* end */
2795};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002796
Kailang Yangdf694da2005-12-05 19:42:22 +01002797/* TCL S700 */
2798static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2799 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2800 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2801 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2802 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2803 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2804 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2805 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2806 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2807 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002808 { } /* end */
2809};
2810
Kailang Yangccc656c2006-10-17 12:32:26 +02002811/* Uniwill */
2812static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002813 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2814 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2815 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2816 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002817 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2818 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2819 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2820 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2821 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2822 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2823 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2824 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2825 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2826 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2827 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2828 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002829 {
2830 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2831 .name = "Channel Mode",
2832 .info = alc_ch_mode_info,
2833 .get = alc_ch_mode_get,
2834 .put = alc_ch_mode_put,
2835 },
2836 { } /* end */
2837};
2838
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002839static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2840 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2841 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2842 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2843 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2844 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2845 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +01002846 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2847 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01002848 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2849 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002850 { } /* end */
2851};
2852
Kailang Yangccc656c2006-10-17 12:32:26 +02002853static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002854 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2855 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2856 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2857 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002858 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2859 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2860 { } /* end */
2861};
2862
Linus Torvalds1da177e2005-04-16 15:20:36 -07002863/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002864 * virtual master controls
2865 */
2866
2867/*
2868 * slave controls for virtual master
2869 */
Takashi Iwaiea734962011-01-17 11:29:34 +01002870static const char * const alc_slave_vols[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002871 "Front Playback Volume",
2872 "Surround Playback Volume",
2873 "Center Playback Volume",
2874 "LFE Playback Volume",
2875 "Side Playback Volume",
2876 "Headphone Playback Volume",
2877 "Speaker Playback Volume",
2878 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002879 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002880 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002881 NULL,
2882};
2883
Takashi Iwaiea734962011-01-17 11:29:34 +01002884static const char * const alc_slave_sws[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002885 "Front Playback Switch",
2886 "Surround Playback Switch",
2887 "Center Playback Switch",
2888 "LFE Playback Switch",
2889 "Side Playback Switch",
2890 "Headphone Playback Switch",
2891 "Speaker Playback Switch",
2892 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002893 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002894 "Line-Out Playback Switch",
2895 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002896 NULL,
2897};
2898
2899/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002900 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002901 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002902
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002903#define NID_MAPPING (-1)
2904
2905#define SUBDEV_SPEAKER_ (0 << 6)
2906#define SUBDEV_HP_ (1 << 6)
2907#define SUBDEV_LINE_ (2 << 6)
2908#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2909#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2910#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2911
Takashi Iwai603c4012008-07-30 15:01:44 +02002912static void alc_free_kctls(struct hda_codec *codec);
2913
Takashi Iwai67d634c2009-11-16 15:35:59 +01002914#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002915/* additional beep mixers; the actual parameters are overwritten at build */
2916static struct snd_kcontrol_new alc_beep_mixer[] = {
2917 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002918 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002919 { } /* end */
2920};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002921#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002922
Linus Torvalds1da177e2005-04-16 15:20:36 -07002923static int alc_build_controls(struct hda_codec *codec)
2924{
2925 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02002926 struct snd_kcontrol *kctl = NULL;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002927 struct snd_kcontrol_new *knew;
2928 int i, j, err;
2929 unsigned int u;
2930 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002931
2932 for (i = 0; i < spec->num_mixers; i++) {
2933 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2934 if (err < 0)
2935 return err;
2936 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002937 if (spec->cap_mixer) {
2938 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2939 if (err < 0)
2940 return err;
2941 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002942 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002943 err = snd_hda_create_spdif_out_ctls(codec,
2944 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002945 if (err < 0)
2946 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002947 if (!spec->no_analog) {
2948 err = snd_hda_create_spdif_share_sw(codec,
2949 &spec->multiout);
2950 if (err < 0)
2951 return err;
2952 spec->multiout.share_spdif = 1;
2953 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002954 }
2955 if (spec->dig_in_nid) {
2956 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2957 if (err < 0)
2958 return err;
2959 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002960
Takashi Iwai67d634c2009-11-16 15:35:59 +01002961#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002962 /* create beep controls if needed */
2963 if (spec->beep_amp) {
2964 struct snd_kcontrol_new *knew;
2965 for (knew = alc_beep_mixer; knew->name; knew++) {
2966 struct snd_kcontrol *kctl;
2967 kctl = snd_ctl_new1(knew, codec);
2968 if (!kctl)
2969 return -ENOMEM;
2970 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002971 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002972 if (err < 0)
2973 return err;
2974 }
2975 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002976#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002977
Takashi Iwai2134ea42008-01-10 16:53:55 +01002978 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002979 if (!spec->no_analog &&
2980 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002981 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002982 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002983 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002984 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002985 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002986 if (err < 0)
2987 return err;
2988 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002989 if (!spec->no_analog &&
2990 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002991 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2992 NULL, alc_slave_sws);
2993 if (err < 0)
2994 return err;
2995 }
2996
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002997 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02002998 if (spec->capsrc_nids || spec->adc_nids) {
2999 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
3000 if (!kctl)
3001 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
3002 for (i = 0; kctl && i < kctl->count; i++) {
3003 hda_nid_t *nids = spec->capsrc_nids;
3004 if (!nids)
3005 nids = spec->adc_nids;
3006 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
3007 if (err < 0)
3008 return err;
3009 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003010 }
3011 if (spec->cap_mixer) {
3012 const char *kname = kctl ? kctl->id.name : NULL;
3013 for (knew = spec->cap_mixer; knew->name; knew++) {
3014 if (kname && strcmp(knew->name, kname) == 0)
3015 continue;
3016 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3017 for (i = 0; kctl && i < kctl->count; i++) {
3018 err = snd_hda_add_nid(codec, kctl, i,
3019 spec->adc_nids[i]);
3020 if (err < 0)
3021 return err;
3022 }
3023 }
3024 }
3025
3026 /* other nid->control mapping */
3027 for (i = 0; i < spec->num_mixers; i++) {
3028 for (knew = spec->mixers[i]; knew->name; knew++) {
3029 if (knew->iface != NID_MAPPING)
3030 continue;
3031 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3032 if (kctl == NULL)
3033 continue;
3034 u = knew->subdevice;
3035 for (j = 0; j < 4; j++, u >>= 8) {
3036 nid = u & 0x3f;
3037 if (nid == 0)
3038 continue;
3039 switch (u & 0xc0) {
3040 case SUBDEV_SPEAKER_:
3041 nid = spec->autocfg.speaker_pins[nid];
3042 break;
3043 case SUBDEV_LINE_:
3044 nid = spec->autocfg.line_out_pins[nid];
3045 break;
3046 case SUBDEV_HP_:
3047 nid = spec->autocfg.hp_pins[nid];
3048 break;
3049 default:
3050 continue;
3051 }
3052 err = snd_hda_add_nid(codec, kctl, 0, nid);
3053 if (err < 0)
3054 return err;
3055 }
3056 u = knew->private_value;
3057 for (j = 0; j < 4; j++, u >>= 8) {
3058 nid = u & 0xff;
3059 if (nid == 0)
3060 continue;
3061 err = snd_hda_add_nid(codec, kctl, 0, nid);
3062 if (err < 0)
3063 return err;
3064 }
3065 }
3066 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01003067
3068 alc_free_kctls(codec); /* no longer needed */
3069
Linus Torvalds1da177e2005-04-16 15:20:36 -07003070 return 0;
3071}
3072
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003073
Linus Torvalds1da177e2005-04-16 15:20:36 -07003074/*
3075 * initialize the codec volumes, etc
3076 */
3077
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003078/*
3079 * generic initialization of ADC, input mixers and output mixers
3080 */
3081static struct hda_verb alc880_volume_init_verbs[] = {
3082 /*
3083 * Unmute ADC0-2 and set the default input to mic-in
3084 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003085 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003086 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003087 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003088 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003089 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003090 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003091
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003092 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3093 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003094 * Note: PASD motherboards uses the Line In 2 as the input for front
3095 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003096 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003097 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003098 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3099 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3101 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3104 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003105
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003106 /*
3107 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003108 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003109 /* set vol=0 to output mixers */
3110 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3111 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3112 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3113 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3114 /* set up input amps for analog loopback */
3115 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003116 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3117 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003118 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3119 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003120 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3121 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003122 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3123 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003124
3125 { }
3126};
3127
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003128/*
3129 * 3-stack pin configuration:
3130 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
3131 */
3132static struct hda_verb alc880_pin_3stack_init_verbs[] = {
3133 /*
3134 * preset connection lists of input pins
3135 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3136 */
3137 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3138 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3139 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3140
3141 /*
3142 * Set pin mode and muting
3143 */
3144 /* set front pin widgets 0x14 for output */
3145 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3146 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3147 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3148 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3149 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3150 /* Mic2 (as headphone out) for HP output */
3151 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3152 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3153 /* Line In pin widget for input */
3154 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3155 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3156 /* Line2 (as front mic) pin widget for input and vref at 80% */
3157 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3158 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3159 /* CD pin widget for input */
3160 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3161
3162 { }
3163};
3164
3165/*
3166 * 5-stack pin configuration:
3167 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3168 * line-in/side = 0x1a, f-mic = 0x1b
3169 */
3170static struct hda_verb alc880_pin_5stack_init_verbs[] = {
3171 /*
3172 * preset connection lists of input pins
3173 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3174 */
3175 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3176 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3177
3178 /*
3179 * Set pin mode and muting
3180 */
3181 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02003182 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3183 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3184 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3185 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003186 /* unmute pins for output (no gain on this amp) */
3187 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3188 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3189 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3190 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3191
Linus Torvalds1da177e2005-04-16 15:20:36 -07003192 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003193 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003194 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3195 /* Mic2 (as headphone out) for HP output */
3196 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003197 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003198 /* Line In pin widget for input */
3199 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3200 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3201 /* Line2 (as front mic) pin widget for input and vref at 80% */
3202 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3203 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3204 /* CD pin widget for input */
3205 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003206
3207 { }
3208};
3209
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003210/*
3211 * W810 pin configuration:
3212 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3213 */
3214static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003215 /* hphone/speaker input selector: front DAC */
3216 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3217
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003218 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3219 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3220 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3221 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3222 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3223 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3224
3225 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003226 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003227
Linus Torvalds1da177e2005-04-16 15:20:36 -07003228 { }
3229};
3230
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003231/*
3232 * Z71V pin configuration:
3233 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3234 */
3235static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003236 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003237 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02003238 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003239 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003240
Takashi Iwai16ded522005-06-10 19:58:24 +02003241 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003242 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003243 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003244 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003245
3246 { }
3247};
3248
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003249/*
3250 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003251 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3252 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003253 */
3254static struct hda_verb alc880_pin_6stack_init_verbs[] = {
3255 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3256
Takashi Iwai16ded522005-06-10 19:58:24 +02003257 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003258 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003259 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003260 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003261 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003262 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003263 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003264 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3265
Takashi Iwai16ded522005-06-10 19:58:24 +02003266 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003267 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003268 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003269 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003270 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003271 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003272 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003273 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003274 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003275
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003276 { }
3277};
Takashi Iwai16ded522005-06-10 19:58:24 +02003278
Kailang Yangccc656c2006-10-17 12:32:26 +02003279/*
3280 * Uniwill pin configuration:
3281 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3282 * line = 0x1a
3283 */
3284static struct hda_verb alc880_uniwill_init_verbs[] = {
3285 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3286
3287 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3288 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3289 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3290 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3291 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3292 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3293 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3294 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3295 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3296 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3297 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3298 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3299 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3300 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3301
3302 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3303 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3304 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3305 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3306 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3307 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3308 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3309 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3310 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3311
3312 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3313 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3314
3315 { }
3316};
3317
3318/*
3319* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003320* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003321 */
3322static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3323 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3324
3325 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3326 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3327 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3328 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3329 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3330 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3331 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3332 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3333 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3334 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3335 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3336 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3337
3338 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3339 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3340 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3341 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3342 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3343 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3344
3345 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3346 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3347
3348 { }
3349};
3350
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003351static struct hda_verb alc880_beep_init_verbs[] = {
3352 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3353 { }
3354};
3355
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003356/* auto-toggle front mic */
Anisse Astiereeb43382010-12-16 12:19:47 +01003357static void alc88x_simple_mic_automute(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003358{
3359 unsigned int present;
3360 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003361
Wu Fengguang864f92b2009-11-18 12:38:02 +08003362 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003363 bits = present ? HDA_AMP_MUTE : 0;
3364 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003365}
3366
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003367static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003368{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003369 struct alc_spec *spec = codec->spec;
3370
3371 spec->autocfg.hp_pins[0] = 0x14;
3372 spec->autocfg.speaker_pins[0] = 0x15;
3373 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003374}
3375
3376static void alc880_uniwill_init_hook(struct hda_codec *codec)
3377{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003378 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01003379 alc88x_simple_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003380}
3381
3382static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3383 unsigned int res)
3384{
3385 /* Looks like the unsol event is incompatible with the standard
3386 * definition. 4bit tag is placed at 28 bit!
3387 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003388 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003389 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01003390 alc88x_simple_mic_automute(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003391 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003392 default:
3393 alc_automute_amp_unsol_event(codec, res);
3394 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003395 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003396}
3397
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003398static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003399{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003400 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003401
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003402 spec->autocfg.hp_pins[0] = 0x14;
3403 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02003404}
3405
3406static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3407{
3408 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003409
Kailang Yangccc656c2006-10-17 12:32:26 +02003410 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003411 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3412 present &= HDA_AMP_VOLMASK;
3413 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3414 HDA_AMP_VOLMASK, present);
3415 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3416 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003417}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003418
Kailang Yangccc656c2006-10-17 12:32:26 +02003419static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3420 unsigned int res)
3421{
3422 /* Looks like the unsol event is incompatible with the standard
3423 * definition. 4bit tag is placed at 28 bit!
3424 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003425 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003426 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003427 else
3428 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003429}
3430
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003431/*
3432 * F1734 pin configuration:
3433 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3434 */
3435static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003436 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003437 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3438 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3439 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3440 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3441
3442 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3443 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3444 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3445 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3446
3447 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3448 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003449 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003450 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3451 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3452 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3453 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3454 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3455 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003456
Takashi Iwai937b4162008-02-11 14:52:36 +01003457 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3458 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3459
Takashi Iwai16ded522005-06-10 19:58:24 +02003460 { }
3461};
3462
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003463/*
3464 * ASUS pin configuration:
3465 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3466 */
3467static struct hda_verb alc880_pin_asus_init_verbs[] = {
3468 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3469 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3470 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3471 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3472
3473 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3474 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3475 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3476 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3477 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3478 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3479 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3480 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3481
3482 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3483 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3484 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3485 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3486 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3487 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3488 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3489 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3490 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003491
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003492 { }
3493};
3494
3495/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003496#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3497#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003498#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003499
Kailang Yangdf694da2005-12-05 19:42:22 +01003500/* Clevo m520g init */
3501static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3502 /* headphone output */
3503 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3504 /* line-out */
3505 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3506 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3507 /* Line-in */
3508 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3509 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3510 /* CD */
3511 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3512 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3513 /* Mic1 (rear panel) */
3514 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3515 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3516 /* Mic2 (front panel) */
3517 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3518 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3519 /* headphone */
3520 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3521 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3522 /* change to EAPD mode */
3523 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3524 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3525
3526 { }
3527};
3528
3529static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003530 /* change to EAPD mode */
3531 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3532 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3533
Kailang Yangdf694da2005-12-05 19:42:22 +01003534 /* Headphone output */
3535 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3536 /* Front output*/
3537 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3538 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3539
3540 /* Line In pin widget for input */
3541 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3542 /* CD pin widget for input */
3543 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3544 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3545 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3546
3547 /* change to EAPD mode */
3548 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3549 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3550
3551 { }
3552};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003553
3554/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003555 * LG m1 express dual
3556 *
3557 * Pin assignment:
3558 * Rear Line-In/Out (blue): 0x14
3559 * Build-in Mic-In: 0x15
3560 * Speaker-out: 0x17
3561 * HP-Out (green): 0x1b
3562 * Mic-In/Out (red): 0x19
3563 * SPDIF-Out: 0x1e
3564 */
3565
3566/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3567static hda_nid_t alc880_lg_dac_nids[3] = {
3568 0x05, 0x02, 0x03
3569};
3570
3571/* seems analog CD is not working */
3572static struct hda_input_mux alc880_lg_capture_source = {
3573 .num_items = 3,
3574 .items = {
3575 { "Mic", 0x1 },
3576 { "Line", 0x5 },
3577 { "Internal Mic", 0x6 },
3578 },
3579};
3580
3581/* 2,4,6 channel modes */
3582static struct hda_verb alc880_lg_ch2_init[] = {
3583 /* set line-in and mic-in to input */
3584 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3585 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3586 { }
3587};
3588
3589static struct hda_verb alc880_lg_ch4_init[] = {
3590 /* set line-in to out and mic-in to input */
3591 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3592 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3593 { }
3594};
3595
3596static struct hda_verb alc880_lg_ch6_init[] = {
3597 /* set line-in and mic-in to output */
3598 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3599 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3600 { }
3601};
3602
3603static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3604 { 2, alc880_lg_ch2_init },
3605 { 4, alc880_lg_ch4_init },
3606 { 6, alc880_lg_ch6_init },
3607};
3608
3609static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003610 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3611 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003612 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3613 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3614 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3615 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3616 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3617 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3618 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3619 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3620 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3621 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3622 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3623 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3624 {
3625 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3626 .name = "Channel Mode",
3627 .info = alc_ch_mode_info,
3628 .get = alc_ch_mode_get,
3629 .put = alc_ch_mode_put,
3630 },
3631 { } /* end */
3632};
3633
3634static struct hda_verb alc880_lg_init_verbs[] = {
3635 /* set capture source to mic-in */
3636 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3637 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3638 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3639 /* mute all amp mixer inputs */
3640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003643 /* line-in to input */
3644 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3645 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3646 /* built-in mic */
3647 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3648 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3649 /* speaker-out */
3650 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3651 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3652 /* mic-in to input */
3653 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3654 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3655 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3656 /* HP-out */
3657 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3658 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3659 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3660 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003661 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003662 { }
3663};
3664
3665/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003666static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003667{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003668 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003669
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003670 spec->autocfg.hp_pins[0] = 0x1b;
3671 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003672}
3673
3674/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003675 * LG LW20
3676 *
3677 * Pin assignment:
3678 * Speaker-out: 0x14
3679 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003680 * Built-in Mic-In: 0x19
3681 * Line-In: 0x1b
3682 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003683 * SPDIF-Out: 0x1e
3684 */
3685
Takashi Iwaid6815182006-03-23 16:06:23 +01003686static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003687 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003688 .items = {
3689 { "Mic", 0x0 },
3690 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003691 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003692 },
3693};
3694
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003695#define alc880_lg_lw_modes alc880_threestack_modes
3696
Takashi Iwaid6815182006-03-23 16:06:23 +01003697static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003698 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3699 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3700 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3701 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3702 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3703 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3704 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3705 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3706 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3707 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003708 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3709 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3710 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3711 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003712 {
3713 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3714 .name = "Channel Mode",
3715 .info = alc_ch_mode_info,
3716 .get = alc_ch_mode_get,
3717 .put = alc_ch_mode_put,
3718 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003719 { } /* end */
3720};
3721
3722static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003723 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3724 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3725 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3726
Takashi Iwaid6815182006-03-23 16:06:23 +01003727 /* set capture source to mic-in */
3728 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3729 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3730 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003731 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003732 /* speaker-out */
3733 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3734 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3735 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003736 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3737 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3738 /* mic-in to input */
3739 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3740 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3741 /* built-in mic */
3742 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3743 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3744 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003745 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003746 { }
3747};
3748
3749/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003750static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003751{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003752 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003753
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003754 spec->autocfg.hp_pins[0] = 0x1b;
3755 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003756}
3757
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003758static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3759 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3760 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3761 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3762 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3763 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3764 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3765 { } /* end */
3766};
3767
3768static struct hda_input_mux alc880_medion_rim_capture_source = {
3769 .num_items = 2,
3770 .items = {
3771 { "Mic", 0x0 },
3772 { "Internal Mic", 0x1 },
3773 },
3774};
3775
3776static struct hda_verb alc880_medion_rim_init_verbs[] = {
3777 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3778
3779 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3780 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3781
3782 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3783 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3784 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3785 /* Mic2 (as headphone out) for HP output */
3786 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3787 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3788 /* Internal Speaker */
3789 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3790 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3791
3792 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3793 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3794
3795 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3796 { }
3797};
3798
3799/* toggle speaker-output according to the hp-jack state */
3800static void alc880_medion_rim_automute(struct hda_codec *codec)
3801{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003802 struct alc_spec *spec = codec->spec;
3803 alc_automute_amp(codec);
3804 /* toggle EAPD */
3805 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003806 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3807 else
3808 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3809}
3810
3811static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3812 unsigned int res)
3813{
3814 /* Looks like the unsol event is incompatible with the standard
3815 * definition. 4bit tag is placed at 28 bit!
3816 */
3817 if ((res >> 28) == ALC880_HP_EVENT)
3818 alc880_medion_rim_automute(codec);
3819}
3820
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003821static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003822{
3823 struct alc_spec *spec = codec->spec;
3824
3825 spec->autocfg.hp_pins[0] = 0x14;
3826 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003827}
3828
Takashi Iwaicb53c622007-08-10 17:21:45 +02003829#ifdef CONFIG_SND_HDA_POWER_SAVE
3830static struct hda_amp_list alc880_loopbacks[] = {
3831 { 0x0b, HDA_INPUT, 0 },
3832 { 0x0b, HDA_INPUT, 1 },
3833 { 0x0b, HDA_INPUT, 2 },
3834 { 0x0b, HDA_INPUT, 3 },
3835 { 0x0b, HDA_INPUT, 4 },
3836 { } /* end */
3837};
3838
3839static struct hda_amp_list alc880_lg_loopbacks[] = {
3840 { 0x0b, HDA_INPUT, 1 },
3841 { 0x0b, HDA_INPUT, 6 },
3842 { 0x0b, HDA_INPUT, 7 },
3843 { } /* end */
3844};
3845#endif
3846
Takashi Iwaid6815182006-03-23 16:06:23 +01003847/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003848 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003849 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003850
Takashi Iwai584c0c42011-03-10 12:51:11 +01003851static void alc_init_special_input_src(struct hda_codec *codec);
3852
Linus Torvalds1da177e2005-04-16 15:20:36 -07003853static int alc_init(struct hda_codec *codec)
3854{
3855 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003856 unsigned int i;
3857
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003858 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003859 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003860
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003861 for (i = 0; i < spec->num_init_verbs; i++)
3862 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwai584c0c42011-03-10 12:51:11 +01003863 alc_init_special_input_src(codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003864
3865 if (spec->init_hook)
3866 spec->init_hook(codec);
3867
Takashi Iwai58701122011-01-13 15:41:45 +01003868 alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT);
3869
Takashi Iwai9e5341b2010-09-21 09:57:06 +02003870 hda_call_check_power_status(codec, 0x01);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003871 return 0;
3872}
3873
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003874static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3875{
3876 struct alc_spec *spec = codec->spec;
3877
3878 if (spec->unsol_event)
3879 spec->unsol_event(codec, res);
3880}
3881
Takashi Iwaicb53c622007-08-10 17:21:45 +02003882#ifdef CONFIG_SND_HDA_POWER_SAVE
3883static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3884{
3885 struct alc_spec *spec = codec->spec;
3886 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3887}
3888#endif
3889
Linus Torvalds1da177e2005-04-16 15:20:36 -07003890/*
3891 * Analog playback callbacks
3892 */
3893static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3894 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003895 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003896{
3897 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003898 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3899 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003900}
3901
3902static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3903 struct hda_codec *codec,
3904 unsigned int stream_tag,
3905 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003906 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003907{
3908 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003909 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3910 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003911}
3912
3913static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3914 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003915 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003916{
3917 struct alc_spec *spec = codec->spec;
3918 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3919}
3920
3921/*
3922 * Digital out
3923 */
3924static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3925 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003926 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003927{
3928 struct alc_spec *spec = codec->spec;
3929 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3930}
3931
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003932static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3933 struct hda_codec *codec,
3934 unsigned int stream_tag,
3935 unsigned int format,
3936 struct snd_pcm_substream *substream)
3937{
3938 struct alc_spec *spec = codec->spec;
3939 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3940 stream_tag, format, substream);
3941}
3942
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003943static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3944 struct hda_codec *codec,
3945 struct snd_pcm_substream *substream)
3946{
3947 struct alc_spec *spec = codec->spec;
3948 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3949}
3950
Linus Torvalds1da177e2005-04-16 15:20:36 -07003951static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3952 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003953 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003954{
3955 struct alc_spec *spec = codec->spec;
3956 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3957}
3958
3959/*
3960 * Analog capture
3961 */
Takashi Iwai63300792008-01-24 15:31:36 +01003962static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003963 struct hda_codec *codec,
3964 unsigned int stream_tag,
3965 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003966 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003967{
3968 struct alc_spec *spec = codec->spec;
3969
Takashi Iwai63300792008-01-24 15:31:36 +01003970 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003971 stream_tag, 0, format);
3972 return 0;
3973}
3974
Takashi Iwai63300792008-01-24 15:31:36 +01003975static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003976 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003977 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003978{
3979 struct alc_spec *spec = codec->spec;
3980
Takashi Iwai888afa12008-03-18 09:57:50 +01003981 snd_hda_codec_cleanup_stream(codec,
3982 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003983 return 0;
3984}
3985
Takashi Iwai840b64c2010-07-13 22:49:01 +02003986/* analog capture with dynamic dual-adc changes */
3987static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3988 struct hda_codec *codec,
3989 unsigned int stream_tag,
3990 unsigned int format,
3991 struct snd_pcm_substream *substream)
3992{
3993 struct alc_spec *spec = codec->spec;
3994 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
3995 spec->cur_adc_stream_tag = stream_tag;
3996 spec->cur_adc_format = format;
3997 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
3998 return 0;
3999}
4000
4001static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
4002 struct hda_codec *codec,
4003 struct snd_pcm_substream *substream)
4004{
4005 struct alc_spec *spec = codec->spec;
4006 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
4007 spec->cur_adc = 0;
4008 return 0;
4009}
4010
4011static struct hda_pcm_stream dualmic_pcm_analog_capture = {
4012 .substreams = 1,
4013 .channels_min = 2,
4014 .channels_max = 2,
4015 .nid = 0, /* fill later */
4016 .ops = {
4017 .prepare = dualmic_capture_pcm_prepare,
4018 .cleanup = dualmic_capture_pcm_cleanup
4019 },
4020};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004021
4022/*
4023 */
4024static struct hda_pcm_stream alc880_pcm_analog_playback = {
4025 .substreams = 1,
4026 .channels_min = 2,
4027 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004028 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004029 .ops = {
4030 .open = alc880_playback_pcm_open,
4031 .prepare = alc880_playback_pcm_prepare,
4032 .cleanup = alc880_playback_pcm_cleanup
4033 },
4034};
4035
4036static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01004037 .substreams = 1,
4038 .channels_min = 2,
4039 .channels_max = 2,
4040 /* NID is set in alc_build_pcms */
4041};
4042
4043static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
4044 .substreams = 1,
4045 .channels_min = 2,
4046 .channels_max = 2,
4047 /* NID is set in alc_build_pcms */
4048};
4049
4050static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
4051 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004052 .channels_min = 2,
4053 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004054 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004055 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01004056 .prepare = alc880_alt_capture_pcm_prepare,
4057 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004058 },
4059};
4060
4061static struct hda_pcm_stream alc880_pcm_digital_playback = {
4062 .substreams = 1,
4063 .channels_min = 2,
4064 .channels_max = 2,
4065 /* NID is set in alc_build_pcms */
4066 .ops = {
4067 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02004068 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01004069 .prepare = alc880_dig_playback_pcm_prepare,
4070 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004071 },
4072};
4073
4074static struct hda_pcm_stream alc880_pcm_digital_capture = {
4075 .substreams = 1,
4076 .channels_min = 2,
4077 .channels_max = 2,
4078 /* NID is set in alc_build_pcms */
4079};
4080
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004081/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01004082static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004083 .substreams = 0,
4084 .channels_min = 0,
4085 .channels_max = 0,
4086};
4087
Linus Torvalds1da177e2005-04-16 15:20:36 -07004088static int alc_build_pcms(struct hda_codec *codec)
4089{
4090 struct alc_spec *spec = codec->spec;
4091 struct hda_pcm *info = spec->pcm_rec;
4092 int i;
4093
4094 codec->num_pcms = 1;
4095 codec->pcm_info = info;
4096
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004097 if (spec->no_analog)
4098 goto skip_analog;
4099
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004100 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
4101 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004102 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01004103
Takashi Iwai4a471b72005-12-07 13:56:29 +01004104 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004105 if (snd_BUG_ON(!spec->multiout.dac_nids))
4106 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004107 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
4108 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
4109 }
4110 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004111 if (snd_BUG_ON(!spec->adc_nids))
4112 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004113 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
4114 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
4115 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004116
Takashi Iwai4a471b72005-12-07 13:56:29 +01004117 if (spec->channel_mode) {
4118 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
4119 for (i = 0; i < spec->num_channel_mode; i++) {
4120 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
4121 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
4122 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004123 }
4124 }
4125
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004126 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02004127 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004128 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004129 snprintf(spec->stream_name_digital,
4130 sizeof(spec->stream_name_digital),
4131 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02004132 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08004133 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004134 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004135 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01004136 if (spec->dig_out_type)
4137 info->pcm_type = spec->dig_out_type;
4138 else
4139 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004140 if (spec->multiout.dig_out_nid &&
4141 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004142 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
4143 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
4144 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004145 if (spec->dig_in_nid &&
4146 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004147 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
4148 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
4149 }
Takashi Iwai963f8032008-08-11 10:04:40 +02004150 /* FIXME: do we need this for all Realtek codec models? */
4151 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004152 }
4153
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004154 if (spec->no_analog)
4155 return 0;
4156
Takashi Iwaie08a0072006-09-07 17:52:14 +02004157 /* If the use of more than one ADC is requested for the current
4158 * model, configure a second analog capture-only PCM.
4159 */
4160 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01004161 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
4162 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02004163 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004164 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004165 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01004166 if (spec->alt_dac_nid) {
4167 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4168 *spec->stream_analog_alt_playback;
4169 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
4170 spec->alt_dac_nid;
4171 } else {
4172 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4173 alc_pcm_null_stream;
4174 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
4175 }
4176 if (spec->num_adc_nids > 1) {
4177 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4178 *spec->stream_analog_alt_capture;
4179 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
4180 spec->adc_nids[1];
4181 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
4182 spec->num_adc_nids - 1;
4183 } else {
4184 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4185 alc_pcm_null_stream;
4186 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004187 }
4188 }
4189
Linus Torvalds1da177e2005-04-16 15:20:36 -07004190 return 0;
4191}
4192
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004193static inline void alc_shutup(struct hda_codec *codec)
4194{
4195 snd_hda_shutup_pins(codec);
4196}
4197
Takashi Iwai603c4012008-07-30 15:01:44 +02004198static void alc_free_kctls(struct hda_codec *codec)
4199{
4200 struct alc_spec *spec = codec->spec;
4201
4202 if (spec->kctls.list) {
4203 struct snd_kcontrol_new *kctl = spec->kctls.list;
4204 int i;
4205 for (i = 0; i < spec->kctls.used; i++)
4206 kfree(kctl[i].name);
4207 }
4208 snd_array_free(&spec->kctls);
4209}
4210
Linus Torvalds1da177e2005-04-16 15:20:36 -07004211static void alc_free(struct hda_codec *codec)
4212{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004213 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004214
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004215 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004216 return;
4217
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004218 alc_shutup(codec);
Takashi Iwaicd372fb2011-03-03 14:40:14 +01004219 snd_hda_input_jack_free(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02004220 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004221 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004222 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004223}
4224
Hector Martinf5de24b2009-12-20 22:51:31 +01004225#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05004226static void alc_power_eapd(struct hda_codec *codec)
4227{
4228 /* We currently only handle front, HP */
4229 switch (codec->vendor_id) {
4230 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004231 set_eapd(codec, 0x0f, 0);
4232 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004233 break;
4234 case 0x10ec0262:
4235 case 0x10ec0267:
4236 case 0x10ec0268:
4237 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004238 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05004239 case 0x10ec0272:
4240 case 0x10ec0660:
4241 case 0x10ec0662:
4242 case 0x10ec0663:
4243 case 0x10ec0862:
4244 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004245 set_eapd(codec, 0x14, 0);
4246 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004247 break;
4248 }
4249}
4250
Hector Martinf5de24b2009-12-20 22:51:31 +01004251static int alc_suspend(struct hda_codec *codec, pm_message_t state)
4252{
4253 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004254 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004255 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05004256 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004257 return 0;
4258}
4259#endif
4260
Takashi Iwaie044c392008-10-27 16:56:24 +01004261#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01004262static int alc_resume(struct hda_codec *codec)
4263{
Takashi Iwaie044c392008-10-27 16:56:24 +01004264 codec->patch_ops.init(codec);
4265 snd_hda_codec_resume_amp(codec);
4266 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +02004267 hda_call_check_power_status(codec, 0x01);
Takashi Iwaie044c392008-10-27 16:56:24 +01004268 return 0;
4269}
Takashi Iwaie044c392008-10-27 16:56:24 +01004270#endif
4271
Linus Torvalds1da177e2005-04-16 15:20:36 -07004272/*
4273 */
4274static struct hda_codec_ops alc_patch_ops = {
4275 .build_controls = alc_build_controls,
4276 .build_pcms = alc_build_pcms,
4277 .init = alc_init,
4278 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004279 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004280#ifdef SND_HDA_NEEDS_RESUME
4281 .resume = alc_resume,
4282#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004283#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004284 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004285 .check_power_status = alc_check_power_status,
4286#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004287 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004288};
4289
Kailang Yangc027ddc2010-03-19 11:33:06 +01004290/* replace the codec chip_name with the given string */
4291static int alc_codec_rename(struct hda_codec *codec, const char *name)
4292{
4293 kfree(codec->chip_name);
4294 codec->chip_name = kstrdup(name, GFP_KERNEL);
4295 if (!codec->chip_name) {
4296 alc_free(codec);
4297 return -ENOMEM;
4298 }
4299 return 0;
4300}
4301
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004302/*
4303 * Test configuration for debugging
4304 *
4305 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4306 * enum controls.
4307 */
4308#ifdef CONFIG_SND_DEBUG
4309static hda_nid_t alc880_test_dac_nids[4] = {
4310 0x02, 0x03, 0x04, 0x05
4311};
4312
4313static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004314 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004315 .items = {
4316 { "In-1", 0x0 },
4317 { "In-2", 0x1 },
4318 { "In-3", 0x2 },
4319 { "In-4", 0x3 },
4320 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004321 { "Front", 0x5 },
4322 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004323 },
4324};
4325
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004326static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004327 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004328 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004329 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004330 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004331};
4332
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004333static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4334 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004335{
4336 static char *texts[] = {
4337 "N/A", "Line Out", "HP Out",
4338 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4339 };
4340 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4341 uinfo->count = 1;
4342 uinfo->value.enumerated.items = 8;
4343 if (uinfo->value.enumerated.item >= 8)
4344 uinfo->value.enumerated.item = 7;
4345 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4346 return 0;
4347}
4348
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004349static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4350 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004351{
4352 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4353 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4354 unsigned int pin_ctl, item = 0;
4355
4356 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4357 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4358 if (pin_ctl & AC_PINCTL_OUT_EN) {
4359 if (pin_ctl & AC_PINCTL_HP_EN)
4360 item = 2;
4361 else
4362 item = 1;
4363 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4364 switch (pin_ctl & AC_PINCTL_VREFEN) {
4365 case AC_PINCTL_VREF_HIZ: item = 3; break;
4366 case AC_PINCTL_VREF_50: item = 4; break;
4367 case AC_PINCTL_VREF_GRD: item = 5; break;
4368 case AC_PINCTL_VREF_80: item = 6; break;
4369 case AC_PINCTL_VREF_100: item = 7; break;
4370 }
4371 }
4372 ucontrol->value.enumerated.item[0] = item;
4373 return 0;
4374}
4375
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004376static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
4377 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004378{
4379 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4380 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4381 static unsigned int ctls[] = {
4382 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4383 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4384 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4385 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4386 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4387 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4388 };
4389 unsigned int old_ctl, new_ctl;
4390
4391 old_ctl = snd_hda_codec_read(codec, nid, 0,
4392 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4393 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4394 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004395 int val;
4396 snd_hda_codec_write_cache(codec, nid, 0,
4397 AC_VERB_SET_PIN_WIDGET_CONTROL,
4398 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004399 val = ucontrol->value.enumerated.item[0] >= 3 ?
4400 HDA_AMP_MUTE : 0;
4401 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4402 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004403 return 1;
4404 }
4405 return 0;
4406}
4407
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004408static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4409 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004410{
4411 static char *texts[] = {
4412 "Front", "Surround", "CLFE", "Side"
4413 };
4414 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4415 uinfo->count = 1;
4416 uinfo->value.enumerated.items = 4;
4417 if (uinfo->value.enumerated.item >= 4)
4418 uinfo->value.enumerated.item = 3;
4419 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4420 return 0;
4421}
4422
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004423static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4424 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004425{
4426 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4427 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4428 unsigned int sel;
4429
4430 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4431 ucontrol->value.enumerated.item[0] = sel & 3;
4432 return 0;
4433}
4434
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004435static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4436 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004437{
4438 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4439 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4440 unsigned int sel;
4441
4442 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4443 if (ucontrol->value.enumerated.item[0] != sel) {
4444 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004445 snd_hda_codec_write_cache(codec, nid, 0,
4446 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004447 return 1;
4448 }
4449 return 0;
4450}
4451
4452#define PIN_CTL_TEST(xname,nid) { \
4453 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4454 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004455 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004456 .info = alc_test_pin_ctl_info, \
4457 .get = alc_test_pin_ctl_get, \
4458 .put = alc_test_pin_ctl_put, \
4459 .private_value = nid \
4460 }
4461
4462#define PIN_SRC_TEST(xname,nid) { \
4463 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4464 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004465 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004466 .info = alc_test_pin_src_info, \
4467 .get = alc_test_pin_src_get, \
4468 .put = alc_test_pin_src_put, \
4469 .private_value = nid \
4470 }
4471
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004472static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004473 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4474 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4475 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4476 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004477 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4478 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4479 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4480 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004481 PIN_CTL_TEST("Front Pin Mode", 0x14),
4482 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4483 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4484 PIN_CTL_TEST("Side Pin Mode", 0x17),
4485 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4486 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4487 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4488 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4489 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4490 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4491 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4492 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4493 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4494 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4495 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4496 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4497 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4498 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4499 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4500 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4501 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4502 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004503 {
4504 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4505 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004506 .info = alc_ch_mode_info,
4507 .get = alc_ch_mode_get,
4508 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004509 },
4510 { } /* end */
4511};
4512
4513static struct hda_verb alc880_test_init_verbs[] = {
4514 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004515 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4516 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4517 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4518 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4519 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4520 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4521 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4522 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004523 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004524 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4525 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4526 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4527 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004528 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004529 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4530 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4531 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4532 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004533 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004534 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4535 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4536 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4537 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004538 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004539 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4540 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004541 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4542 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4543 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004544 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004545 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4546 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4547 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4548 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004549 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004550 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004551 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004552 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004553 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004554 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004555 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004556 /* Analog input/passthru */
4557 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4558 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4559 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4560 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4561 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004562 { }
4563};
4564#endif
4565
Linus Torvalds1da177e2005-04-16 15:20:36 -07004566/*
4567 */
4568
Takashi Iwaiea734962011-01-17 11:29:34 +01004569static const char * const alc880_models[ALC880_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004570 [ALC880_3ST] = "3stack",
4571 [ALC880_TCL_S700] = "tcl",
4572 [ALC880_3ST_DIG] = "3stack-digout",
4573 [ALC880_CLEVO] = "clevo",
4574 [ALC880_5ST] = "5stack",
4575 [ALC880_5ST_DIG] = "5stack-digout",
4576 [ALC880_W810] = "w810",
4577 [ALC880_Z71V] = "z71v",
4578 [ALC880_6ST] = "6stack",
4579 [ALC880_6ST_DIG] = "6stack-digout",
4580 [ALC880_ASUS] = "asus",
4581 [ALC880_ASUS_W1V] = "asus-w1v",
4582 [ALC880_ASUS_DIG] = "asus-dig",
4583 [ALC880_ASUS_DIG2] = "asus-dig2",
4584 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004585 [ALC880_UNIWILL_P53] = "uniwill-p53",
4586 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004587 [ALC880_F1734] = "F1734",
4588 [ALC880_LG] = "lg",
4589 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004590 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004591#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004592 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004593#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004594 [ALC880_AUTO] = "auto",
4595};
4596
4597static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004598 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004599 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4600 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4601 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4602 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4603 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4604 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4605 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4606 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004607 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4608 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004609 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4610 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4611 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4612 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4613 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4614 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4615 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4616 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4617 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4618 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004619 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004620 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4621 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4622 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004623 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004624 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004625 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4626 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004627 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4628 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004629 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4630 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4631 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4632 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004633 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4634 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004635 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004636 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004637 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004638 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004639 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4640 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004641 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004642 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004643 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004644 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004645 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004646 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004647 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004648 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004649 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004650 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
Daniel T Chen77c4d5c2010-12-02 22:45:45 -05004651 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004652 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004653 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004654 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4655 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4656 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4657 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004658 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4659 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004660 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004661 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004662 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4663 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004664 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4665 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4666 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004667 /* default Intel */
4668 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004669 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4670 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004671 {}
4672};
4673
Takashi Iwai16ded522005-06-10 19:58:24 +02004674/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004675 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004676 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004677static struct alc_config_preset alc880_presets[] = {
4678 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004679 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004680 .init_verbs = { alc880_volume_init_verbs,
4681 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004682 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004683 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004684 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4685 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004686 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004687 .input_mux = &alc880_capture_source,
4688 },
4689 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004690 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004691 .init_verbs = { alc880_volume_init_verbs,
4692 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004693 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004694 .dac_nids = alc880_dac_nids,
4695 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004696 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4697 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004698 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004699 .input_mux = &alc880_capture_source,
4700 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004701 [ALC880_TCL_S700] = {
4702 .mixers = { alc880_tcl_s700_mixer },
4703 .init_verbs = { alc880_volume_init_verbs,
4704 alc880_pin_tcl_S700_init_verbs,
4705 alc880_gpio2_init_verbs },
4706 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4707 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004708 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4709 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004710 .hp_nid = 0x03,
4711 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4712 .channel_mode = alc880_2_jack_modes,
4713 .input_mux = &alc880_capture_source,
4714 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004715 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004716 .mixers = { alc880_three_stack_mixer,
4717 alc880_five_stack_mixer},
4718 .init_verbs = { alc880_volume_init_verbs,
4719 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004720 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4721 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004722 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4723 .channel_mode = alc880_fivestack_modes,
4724 .input_mux = &alc880_capture_source,
4725 },
4726 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004727 .mixers = { alc880_three_stack_mixer,
4728 alc880_five_stack_mixer },
4729 .init_verbs = { alc880_volume_init_verbs,
4730 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004731 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4732 .dac_nids = alc880_dac_nids,
4733 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004734 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4735 .channel_mode = alc880_fivestack_modes,
4736 .input_mux = &alc880_capture_source,
4737 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004738 [ALC880_6ST] = {
4739 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004740 .init_verbs = { alc880_volume_init_verbs,
4741 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004742 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4743 .dac_nids = alc880_6st_dac_nids,
4744 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4745 .channel_mode = alc880_sixstack_modes,
4746 .input_mux = &alc880_6stack_capture_source,
4747 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004748 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004749 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004750 .init_verbs = { alc880_volume_init_verbs,
4751 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004752 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4753 .dac_nids = alc880_6st_dac_nids,
4754 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004755 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4756 .channel_mode = alc880_sixstack_modes,
4757 .input_mux = &alc880_6stack_capture_source,
4758 },
4759 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004760 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004761 .init_verbs = { alc880_volume_init_verbs,
4762 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004763 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004764 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4765 .dac_nids = alc880_w810_dac_nids,
4766 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004767 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4768 .channel_mode = alc880_w810_modes,
4769 .input_mux = &alc880_capture_source,
4770 },
4771 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004772 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004773 .init_verbs = { alc880_volume_init_verbs,
4774 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004775 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4776 .dac_nids = alc880_z71v_dac_nids,
4777 .dig_out_nid = ALC880_DIGOUT_NID,
4778 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004779 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4780 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004781 .input_mux = &alc880_capture_source,
4782 },
4783 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004784 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004785 .init_verbs = { alc880_volume_init_verbs,
4786 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004787 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4788 .dac_nids = alc880_f1734_dac_nids,
4789 .hp_nid = 0x02,
4790 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4791 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004792 .input_mux = &alc880_f1734_capture_source,
4793 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004794 .setup = alc880_uniwill_p53_setup,
4795 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004796 },
4797 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004798 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004799 .init_verbs = { alc880_volume_init_verbs,
4800 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004801 alc880_gpio1_init_verbs },
4802 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4803 .dac_nids = alc880_asus_dac_nids,
4804 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4805 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004806 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004807 .input_mux = &alc880_capture_source,
4808 },
4809 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004810 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004811 .init_verbs = { alc880_volume_init_verbs,
4812 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004813 alc880_gpio1_init_verbs },
4814 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4815 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004816 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004817 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4818 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004819 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004820 .input_mux = &alc880_capture_source,
4821 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004822 [ALC880_ASUS_DIG2] = {
4823 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004824 .init_verbs = { alc880_volume_init_verbs,
4825 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004826 alc880_gpio2_init_verbs }, /* use GPIO2 */
4827 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4828 .dac_nids = alc880_asus_dac_nids,
4829 .dig_out_nid = ALC880_DIGOUT_NID,
4830 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4831 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004832 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004833 .input_mux = &alc880_capture_source,
4834 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004835 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004836 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004837 .init_verbs = { alc880_volume_init_verbs,
4838 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004839 alc880_gpio1_init_verbs },
4840 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4841 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004842 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004843 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4844 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004845 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004846 .input_mux = &alc880_capture_source,
4847 },
4848 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004849 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004850 .init_verbs = { alc880_volume_init_verbs,
4851 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004852 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4853 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004854 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004855 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4856 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004857 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004858 .input_mux = &alc880_capture_source,
4859 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004860 [ALC880_UNIWILL] = {
4861 .mixers = { alc880_uniwill_mixer },
4862 .init_verbs = { alc880_volume_init_verbs,
4863 alc880_uniwill_init_verbs },
4864 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4865 .dac_nids = alc880_asus_dac_nids,
4866 .dig_out_nid = ALC880_DIGOUT_NID,
4867 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4868 .channel_mode = alc880_threestack_modes,
4869 .need_dac_fix = 1,
4870 .input_mux = &alc880_capture_source,
4871 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004872 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004873 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004874 },
4875 [ALC880_UNIWILL_P53] = {
4876 .mixers = { alc880_uniwill_p53_mixer },
4877 .init_verbs = { alc880_volume_init_verbs,
4878 alc880_uniwill_p53_init_verbs },
4879 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4880 .dac_nids = alc880_asus_dac_nids,
4881 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004882 .channel_mode = alc880_threestack_modes,
4883 .input_mux = &alc880_capture_source,
4884 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004885 .setup = alc880_uniwill_p53_setup,
4886 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004887 },
4888 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004889 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004890 .init_verbs = { alc880_volume_init_verbs,
4891 alc880_uniwill_p53_init_verbs,
4892 alc880_beep_init_verbs },
4893 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4894 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004895 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004896 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4897 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004898 .input_mux = &alc880_capture_source,
4899 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004900 .setup = alc880_uniwill_p53_setup,
4901 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004902 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004903 [ALC880_CLEVO] = {
4904 .mixers = { alc880_three_stack_mixer },
4905 .init_verbs = { alc880_volume_init_verbs,
4906 alc880_pin_clevo_init_verbs },
4907 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4908 .dac_nids = alc880_dac_nids,
4909 .hp_nid = 0x03,
4910 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4911 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004912 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004913 .input_mux = &alc880_capture_source,
4914 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004915 [ALC880_LG] = {
4916 .mixers = { alc880_lg_mixer },
4917 .init_verbs = { alc880_volume_init_verbs,
4918 alc880_lg_init_verbs },
4919 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4920 .dac_nids = alc880_lg_dac_nids,
4921 .dig_out_nid = ALC880_DIGOUT_NID,
4922 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4923 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004924 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004925 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004926 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004927 .setup = alc880_lg_setup,
4928 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004929#ifdef CONFIG_SND_HDA_POWER_SAVE
4930 .loopbacks = alc880_lg_loopbacks,
4931#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004932 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004933 [ALC880_LG_LW] = {
4934 .mixers = { alc880_lg_lw_mixer },
4935 .init_verbs = { alc880_volume_init_verbs,
4936 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004937 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004938 .dac_nids = alc880_dac_nids,
4939 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004940 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4941 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004942 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004943 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004944 .setup = alc880_lg_lw_setup,
4945 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004946 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004947 [ALC880_MEDION_RIM] = {
4948 .mixers = { alc880_medion_rim_mixer },
4949 .init_verbs = { alc880_volume_init_verbs,
4950 alc880_medion_rim_init_verbs,
4951 alc_gpio2_init_verbs },
4952 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4953 .dac_nids = alc880_dac_nids,
4954 .dig_out_nid = ALC880_DIGOUT_NID,
4955 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4956 .channel_mode = alc880_2_jack_modes,
4957 .input_mux = &alc880_medion_rim_capture_source,
4958 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004959 .setup = alc880_medion_rim_setup,
4960 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004961 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004962#ifdef CONFIG_SND_DEBUG
4963 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004964 .mixers = { alc880_test_mixer },
4965 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004966 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4967 .dac_nids = alc880_test_dac_nids,
4968 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004969 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4970 .channel_mode = alc880_test_modes,
4971 .input_mux = &alc880_test_capture_source,
4972 },
4973#endif
4974};
4975
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004976/*
4977 * Automatic parse of I/O pins from the BIOS configuration
4978 */
4979
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004980enum {
4981 ALC_CTL_WIDGET_VOL,
4982 ALC_CTL_WIDGET_MUTE,
4983 ALC_CTL_BIND_MUTE,
4984};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004985static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004986 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4987 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004988 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004989};
4990
4991/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004992static int add_control(struct alc_spec *spec, int type, const char *name,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004993 int cidx, unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004994{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004995 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004996
Takashi Iwai603c4012008-07-30 15:01:44 +02004997 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4998 knew = snd_array_new(&spec->kctls);
4999 if (!knew)
5000 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005001 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07005002 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005003 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005004 return -ENOMEM;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005005 knew->index = cidx;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01005006 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01005007 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005008 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005009 return 0;
5010}
5011
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005012static int add_control_with_pfx(struct alc_spec *spec, int type,
5013 const char *pfx, const char *dir,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005014 const char *sfx, int cidx, unsigned long val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005015{
5016 char name[32];
5017 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005018 return add_control(spec, type, name, cidx, val);
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005019}
5020
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005021#define add_pb_vol_ctrl(spec, type, pfx, val) \
5022 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
5023#define add_pb_sw_ctrl(spec, type, pfx, val) \
5024 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
5025#define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
5026 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
5027#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
5028 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005029
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005030#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
5031#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
5032#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
5033#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005034#define alc880_idx_to_dac(nid) ((nid) + 0x02)
5035#define alc880_dac_to_idx(nid) ((nid) - 0x02)
5036#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
5037#define alc880_idx_to_selector(nid) ((nid) + 0x10)
5038#define ALC880_PIN_CD_NID 0x1c
5039
5040/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005041static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
5042 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005043{
5044 hda_nid_t nid;
5045 int assigned[4];
5046 int i, j;
5047
5048 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02005049 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005050
5051 /* check the pins hardwired to audio widget */
5052 for (i = 0; i < cfg->line_outs; i++) {
5053 nid = cfg->line_out_pins[i];
5054 if (alc880_is_fixed_pin(nid)) {
5055 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01005056 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005057 assigned[idx] = 1;
5058 }
5059 }
5060 /* left pins can be connect to any audio widget */
5061 for (i = 0; i < cfg->line_outs; i++) {
5062 nid = cfg->line_out_pins[i];
5063 if (alc880_is_fixed_pin(nid))
5064 continue;
5065 /* search for an empty channel */
5066 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005067 if (!assigned[j]) {
5068 spec->multiout.dac_nids[i] =
5069 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005070 assigned[j] = 1;
5071 break;
5072 }
5073 }
5074 }
5075 spec->multiout.num_dacs = cfg->line_outs;
5076 return 0;
5077}
5078
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005079static const char *alc_get_line_out_pfx(const struct auto_pin_cfg *cfg,
5080 bool can_be_master)
5081{
5082 if (!cfg->hp_outs && !cfg->speaker_outs && can_be_master)
5083 return "Master";
5084
5085 switch (cfg->line_out_type) {
5086 case AUTO_PIN_SPEAKER_OUT:
David Henningssonebbeb3d2011-03-04 14:08:30 +01005087 if (cfg->line_outs == 1)
5088 return "Speaker";
5089 break;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005090 case AUTO_PIN_HP_OUT:
5091 return "Headphone";
5092 default:
5093 if (cfg->line_outs == 1)
5094 return "PCM";
5095 break;
5096 }
5097 return NULL;
5098}
5099
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005100/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01005101static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
5102 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005103{
Takashi Iwaiea734962011-01-17 11:29:34 +01005104 static const char * const chname[4] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005105 "Front", "Surround", NULL /*CLFE*/, "Side"
5106 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005107 const char *pfx = alc_get_line_out_pfx(cfg, false);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005108 hda_nid_t nid;
5109 int i, err;
5110
5111 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005112 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005113 continue;
5114 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005115 if (!pfx && i == 2) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005116 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005117 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5118 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005119 HDA_COMPOSE_AMP_VAL(nid, 1, 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_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5124 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005125 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
5126 HDA_OUTPUT));
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 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005131 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
5132 HDA_INPUT));
5133 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005134 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005135 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5136 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005137 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
5138 HDA_INPUT));
5139 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005140 return err;
5141 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005142 const char *name = pfx;
David Henningsson7e59e092011-03-04 14:22:25 +01005143 int index = i;
5144 if (!name) {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005145 name = chname[i];
David Henningsson7e59e092011-03-04 14:22:25 +01005146 index = 0;
5147 }
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005148 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
David Henningsson7e59e092011-03-04 14:22:25 +01005149 name, index,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005150 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
5151 HDA_OUTPUT));
5152 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005153 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005154 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
David Henningsson7e59e092011-03-04 14:22:25 +01005155 name, index,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005156 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
5157 HDA_INPUT));
5158 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005159 return err;
5160 }
5161 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005162 return 0;
5163}
5164
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005165/* add playback controls for speaker and HP outputs */
5166static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
5167 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005168{
5169 hda_nid_t nid;
5170 int err;
5171
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005172 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005173 return 0;
5174
5175 if (alc880_is_fixed_pin(pin)) {
5176 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01005177 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005178 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005179 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005180 else
5181 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005182 /* control HP volume/switch on the output mixer amp */
5183 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005184 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005185 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
5186 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005187 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005188 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005189 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
5190 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005191 return err;
5192 } else if (alc880_is_multi_pin(pin)) {
5193 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005194 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005195 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005196 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
5197 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005198 return err;
5199 }
5200 return 0;
5201}
5202
5203/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005204static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005205 const char *ctlname, int ctlidx,
Kailang Yangdf694da2005-12-05 19:42:22 +01005206 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005207{
Kailang Yangdf694da2005-12-05 19:42:22 +01005208 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005209
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005210 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005211 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5212 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005213 return err;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005214 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005215 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5216 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005217 return err;
5218 return 0;
5219}
5220
Takashi Iwai05f5f472009-08-25 13:10:18 +02005221static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005222{
Takashi Iwai05f5f472009-08-25 13:10:18 +02005223 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
5224 return (pincap & AC_PINCAP_IN) != 0;
5225}
5226
5227/* create playback/capture controls for input pins */
5228static int alc_auto_create_input_ctls(struct hda_codec *codec,
5229 const struct auto_pin_cfg *cfg,
5230 hda_nid_t mixer,
5231 hda_nid_t cap1, hda_nid_t cap2)
5232{
5233 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005234 struct hda_input_mux *imux = &spec->private_imux[0];
David Henningsson5322bf22011-01-05 11:03:56 +01005235 int i, err, idx, type_idx = 0;
5236 const char *prev_label = NULL;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005237
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005238 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02005239 hda_nid_t pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005240 const char *label;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005241
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005242 pin = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005243 if (!alc_is_input_pin(codec, pin))
5244 continue;
5245
David Henningsson5322bf22011-01-05 11:03:56 +01005246 label = hda_get_autocfg_input_label(codec, cfg, i);
5247 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005248 type_idx++;
5249 else
5250 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +01005251 prev_label = label;
5252
Takashi Iwai05f5f472009-08-25 13:10:18 +02005253 if (mixer) {
5254 idx = get_connection_index(codec, mixer, pin);
5255 if (idx >= 0) {
5256 err = new_analog_input(spec, pin,
Takashi Iwai10a20af2010-09-09 16:28:02 +02005257 label, type_idx,
5258 idx, mixer);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005259 if (err < 0)
5260 return err;
5261 }
5262 }
5263
5264 if (!cap1)
5265 continue;
5266 idx = get_connection_index(codec, cap1, pin);
5267 if (idx < 0 && cap2)
5268 idx = get_connection_index(codec, cap2, pin);
Takashi Iwai10a20af2010-09-09 16:28:02 +02005269 if (idx >= 0)
5270 snd_hda_add_imux_item(imux, label, idx, NULL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005271 }
5272 return 0;
5273}
5274
Takashi Iwai05f5f472009-08-25 13:10:18 +02005275static int alc880_auto_create_input_ctls(struct hda_codec *codec,
5276 const struct auto_pin_cfg *cfg)
5277{
5278 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
5279}
5280
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005281static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
5282 unsigned int pin_type)
5283{
5284 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5285 pin_type);
5286 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01005287 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5288 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005289}
5290
Kailang Yangdf694da2005-12-05 19:42:22 +01005291static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
5292 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005293 int dac_idx)
5294{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005295 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005296 /* need the manual connection? */
5297 if (alc880_is_multi_pin(nid)) {
5298 struct alc_spec *spec = codec->spec;
5299 int idx = alc880_multi_pin_idx(nid);
5300 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
5301 AC_VERB_SET_CONNECT_SEL,
5302 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
5303 }
5304}
5305
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005306static int get_pin_type(int line_out_type)
5307{
5308 if (line_out_type == AUTO_PIN_HP_OUT)
5309 return PIN_HP;
5310 else
5311 return PIN_OUT;
5312}
5313
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005314static void alc880_auto_init_multi_out(struct hda_codec *codec)
5315{
5316 struct alc_spec *spec = codec->spec;
5317 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005318
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005319 for (i = 0; i < spec->autocfg.line_outs; i++) {
5320 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005321 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5322 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005323 }
5324}
5325
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005326static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005327{
5328 struct alc_spec *spec = codec->spec;
5329 hda_nid_t pin;
5330
Takashi Iwai82bc9552006-03-21 11:24:42 +01005331 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005332 if (pin) /* connect to front */
5333 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005334 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005335 if (pin) /* connect to front */
5336 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5337}
5338
5339static void alc880_auto_init_analog_input(struct hda_codec *codec)
5340{
5341 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005342 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005343 int i;
5344
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005345 for (i = 0; i < cfg->num_inputs; i++) {
5346 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005347 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02005348 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005349 if (nid != ALC880_PIN_CD_NID &&
5350 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005351 snd_hda_codec_write(codec, nid, 0,
5352 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005353 AMP_OUT_MUTE);
5354 }
5355 }
5356}
5357
Takashi Iwai7f311a42010-04-09 17:32:23 +02005358static void alc880_auto_init_input_src(struct hda_codec *codec)
5359{
5360 struct alc_spec *spec = codec->spec;
5361 int c;
5362
5363 for (c = 0; c < spec->num_adc_nids; c++) {
5364 unsigned int mux_idx;
5365 const struct hda_input_mux *imux;
5366 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5367 imux = &spec->input_mux[mux_idx];
5368 if (!imux->num_items && mux_idx > 0)
5369 imux = &spec->input_mux[0];
5370 if (imux)
5371 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5372 AC_VERB_SET_CONNECT_SEL,
5373 imux->items[0].index);
5374 }
5375}
5376
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005377/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005378/* return 1 if successful, 0 if the proper config is not found,
5379 * or a negative error code
5380 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005381static int alc880_parse_auto_config(struct hda_codec *codec)
5382{
5383 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005384 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005385 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005386
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005387 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5388 alc880_ignore);
5389 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005390 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005391 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005392 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005393
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005394 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5395 if (err < 0)
5396 return err;
5397 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5398 if (err < 0)
5399 return err;
5400 err = alc880_auto_create_extra_out(spec,
5401 spec->autocfg.speaker_pins[0],
5402 "Speaker");
5403 if (err < 0)
5404 return err;
5405 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5406 "Headphone");
5407 if (err < 0)
5408 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005409 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005410 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005411 return err;
5412
5413 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5414
Takashi Iwai757899a2010-07-30 10:48:14 +02005415 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005416
Takashi Iwai603c4012008-07-30 15:01:44 +02005417 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005418 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005419
Takashi Iwaid88897e2008-10-31 15:01:37 +01005420 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005421
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005422 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005423 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005424
Kailang Yang6227cdc2010-02-25 08:36:52 +01005425 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005426
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005427 return 1;
5428}
5429
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005430/* additional initialization for auto-configuration model */
5431static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005432{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005433 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005434 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005435 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005436 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005437 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005438 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005439 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005440 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005441}
5442
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005443/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5444 * one of two digital mic pins, e.g. on ALC272
5445 */
5446static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005447{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005448 struct alc_spec *spec = codec->spec;
5449 int i;
5450
5451 for (i = 0; i < spec->num_adc_nids; i++) {
5452 hda_nid_t cap = spec->capsrc_nids ?
5453 spec->capsrc_nids[i] : spec->adc_nids[i];
5454 int iidx, eidx;
5455
5456 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5457 if (iidx < 0)
5458 continue;
5459 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5460 if (eidx < 0)
5461 continue;
5462 spec->int_mic.mux_idx = iidx;
5463 spec->ext_mic.mux_idx = eidx;
5464 if (spec->capsrc_nids)
5465 spec->capsrc_nids += i;
5466 spec->adc_nids += i;
5467 spec->num_adc_nids = 1;
5468 return;
5469 }
5470 snd_printd(KERN_INFO "hda_codec: %s: "
5471 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5472 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5473 spec->auto_mic = 0; /* disable auto-mic to be sure */
5474}
5475
Takashi Iwai748cce42010-08-04 07:37:39 +02005476/* select or unmute the given capsrc route */
5477static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5478 int idx)
5479{
5480 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5481 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5482 HDA_AMP_MUTE, 0);
5483 } else {
5484 snd_hda_codec_write_cache(codec, cap, 0,
5485 AC_VERB_SET_CONNECT_SEL, idx);
5486 }
5487}
5488
Takashi Iwai840b64c2010-07-13 22:49:01 +02005489/* set the default connection to that pin */
5490static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5491{
5492 struct alc_spec *spec = codec->spec;
5493 int i;
5494
5495 for (i = 0; i < spec->num_adc_nids; i++) {
5496 hda_nid_t cap = spec->capsrc_nids ?
5497 spec->capsrc_nids[i] : spec->adc_nids[i];
5498 int idx;
5499
5500 idx = get_connection_index(codec, cap, pin);
5501 if (idx < 0)
5502 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005503 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005504 return i; /* return the found index */
5505 }
5506 return -1; /* not found */
5507}
5508
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005509/* choose the ADC/MUX containing the input pin and initialize the setup */
5510static void fixup_single_adc(struct hda_codec *codec)
5511{
5512 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005513 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005514 int i;
5515
5516 /* search for the input pin; there must be only one */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005517 if (cfg->num_inputs != 1)
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005518 return;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005519 i = init_capsrc_for_pin(codec, cfg->inputs[0].pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005520 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005521 /* use only this ADC */
5522 if (spec->capsrc_nids)
5523 spec->capsrc_nids += i;
5524 spec->adc_nids += i;
5525 spec->num_adc_nids = 1;
Takashi Iwai584c0c42011-03-10 12:51:11 +01005526 spec->single_input_src = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005527 }
5528}
5529
Takashi Iwai840b64c2010-07-13 22:49:01 +02005530/* initialize dual adcs */
5531static void fixup_dual_adc_switch(struct hda_codec *codec)
5532{
5533 struct alc_spec *spec = codec->spec;
5534 init_capsrc_for_pin(codec, spec->ext_mic.pin);
5535 init_capsrc_for_pin(codec, spec->int_mic.pin);
5536}
5537
Takashi Iwai584c0c42011-03-10 12:51:11 +01005538/* initialize some special cases for input sources */
5539static void alc_init_special_input_src(struct hda_codec *codec)
5540{
5541 struct alc_spec *spec = codec->spec;
5542 if (spec->dual_adc_switch)
5543 fixup_dual_adc_switch(codec);
5544 else if (spec->single_input_src)
5545 init_capsrc_for_pin(codec, spec->autocfg.inputs[0].pin);
5546}
5547
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005548static void set_capture_mixer(struct hda_codec *codec)
5549{
5550 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005551 static struct snd_kcontrol_new *caps[2][3] = {
5552 { alc_capture_mixer_nosrc1,
5553 alc_capture_mixer_nosrc2,
5554 alc_capture_mixer_nosrc3 },
5555 { alc_capture_mixer1,
5556 alc_capture_mixer2,
5557 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005558 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005559 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005560 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005561 int num_adcs = spec->num_adc_nids;
5562 if (spec->dual_adc_switch)
Takashi Iwai584c0c42011-03-10 12:51:11 +01005563 num_adcs = 1;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005564 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005565 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005566 else if (spec->input_mux) {
5567 if (spec->input_mux->num_items > 1)
5568 mux = 1;
5569 else if (spec->input_mux->num_items == 1)
5570 fixup_single_adc(codec);
5571 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005572 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005573 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005574}
5575
Takashi Iwai66946352010-03-29 17:21:45 +02005576/* fill adc_nids (and capsrc_nids) containing all active input pins */
5577static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5578 int num_nids)
5579{
5580 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005581 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai66946352010-03-29 17:21:45 +02005582 int n;
5583 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5584
5585 for (n = 0; n < num_nids; n++) {
5586 hda_nid_t adc, cap;
5587 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5588 int nconns, i, j;
5589
5590 adc = nids[n];
5591 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5592 continue;
5593 cap = adc;
5594 nconns = snd_hda_get_connections(codec, cap, conn,
5595 ARRAY_SIZE(conn));
5596 if (nconns == 1) {
5597 cap = conn[0];
5598 nconns = snd_hda_get_connections(codec, cap, conn,
5599 ARRAY_SIZE(conn));
5600 }
5601 if (nconns <= 0)
5602 continue;
5603 if (!fallback_adc) {
5604 fallback_adc = adc;
5605 fallback_cap = cap;
5606 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005607 for (i = 0; i < cfg->num_inputs; i++) {
5608 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai66946352010-03-29 17:21:45 +02005609 for (j = 0; j < nconns; j++) {
5610 if (conn[j] == nid)
5611 break;
5612 }
5613 if (j >= nconns)
5614 break;
5615 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005616 if (i >= cfg->num_inputs) {
Takashi Iwai66946352010-03-29 17:21:45 +02005617 int num_adcs = spec->num_adc_nids;
5618 spec->private_adc_nids[num_adcs] = adc;
5619 spec->private_capsrc_nids[num_adcs] = cap;
5620 spec->num_adc_nids++;
5621 spec->adc_nids = spec->private_adc_nids;
5622 if (adc != cap)
5623 spec->capsrc_nids = spec->private_capsrc_nids;
5624 }
5625 }
5626 if (!spec->num_adc_nids) {
5627 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005628 " using fallback 0x%x\n",
5629 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005630 spec->private_adc_nids[0] = fallback_adc;
5631 spec->adc_nids = spec->private_adc_nids;
5632 if (fallback_adc != fallback_cap) {
5633 spec->private_capsrc_nids[0] = fallback_cap;
5634 spec->capsrc_nids = spec->private_adc_nids;
5635 }
5636 }
5637}
5638
Takashi Iwai67d634c2009-11-16 15:35:59 +01005639#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005640#define set_beep_amp(spec, nid, idx, dir) \
5641 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005642
5643static struct snd_pci_quirk beep_white_list[] = {
5644 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005645 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005646 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005647 {}
5648};
5649
5650static inline int has_cdefine_beep(struct hda_codec *codec)
5651{
5652 struct alc_spec *spec = codec->spec;
5653 const struct snd_pci_quirk *q;
5654 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5655 if (q)
5656 return q->value;
5657 return spec->cdefine.enable_pcbeep;
5658}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005659#else
5660#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005661#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005662#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005663
5664/*
5665 * OK, here we have finally the patch for ALC880
5666 */
5667
Linus Torvalds1da177e2005-04-16 15:20:36 -07005668static int patch_alc880(struct hda_codec *codec)
5669{
5670 struct alc_spec *spec;
5671 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005672 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005673
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005674 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005675 if (spec == NULL)
5676 return -ENOMEM;
5677
5678 codec->spec = spec;
5679
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005680 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5681 alc880_models,
5682 alc880_cfg_tbl);
5683 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005684 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5685 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005686 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005687 }
5688
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005689 if (board_config == ALC880_AUTO) {
5690 /* automatic parse from the BIOS config */
5691 err = alc880_parse_auto_config(codec);
5692 if (err < 0) {
5693 alc_free(codec);
5694 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005695 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005696 printk(KERN_INFO
5697 "hda_codec: Cannot set up configuration "
5698 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005699 board_config = ALC880_3ST;
5700 }
5701 }
5702
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005703 err = snd_hda_attach_beep_device(codec, 0x1);
5704 if (err < 0) {
5705 alc_free(codec);
5706 return err;
5707 }
5708
Kailang Yangdf694da2005-12-05 19:42:22 +01005709 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005710 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005711
Linus Torvalds1da177e2005-04-16 15:20:36 -07005712 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5713 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005714 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005715
Linus Torvalds1da177e2005-04-16 15:20:36 -07005716 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5717 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5718
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005719 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005720 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005721 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005722 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005723 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005724 if (wcap != AC_WID_AUD_IN) {
5725 spec->adc_nids = alc880_adc_nids_alt;
5726 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005727 } else {
5728 spec->adc_nids = alc880_adc_nids;
5729 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005730 }
5731 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005732 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005733 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005734
Takashi Iwai2134ea42008-01-10 16:53:55 +01005735 spec->vmaster_nid = 0x0c;
5736
Linus Torvalds1da177e2005-04-16 15:20:36 -07005737 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005738 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005739 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005740#ifdef CONFIG_SND_HDA_POWER_SAVE
5741 if (!spec->loopback.amplist)
5742 spec->loopback.amplist = alc880_loopbacks;
5743#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005744
5745 return 0;
5746}
5747
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005748
Linus Torvalds1da177e2005-04-16 15:20:36 -07005749/*
5750 * ALC260 support
5751 */
5752
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005753static hda_nid_t alc260_dac_nids[1] = {
5754 /* front */
5755 0x02,
5756};
5757
5758static hda_nid_t alc260_adc_nids[1] = {
5759 /* ADC0 */
5760 0x04,
5761};
5762
Kailang Yangdf694da2005-12-05 19:42:22 +01005763static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005764 /* ADC1 */
5765 0x05,
5766};
5767
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005768/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5769 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5770 */
5771static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005772 /* ADC0, ADC1 */
5773 0x04, 0x05
5774};
5775
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005776#define ALC260_DIGOUT_NID 0x03
5777#define ALC260_DIGIN_NID 0x06
5778
5779static struct hda_input_mux alc260_capture_source = {
5780 .num_items = 4,
5781 .items = {
5782 { "Mic", 0x0 },
5783 { "Front Mic", 0x1 },
5784 { "Line", 0x2 },
5785 { "CD", 0x4 },
5786 },
5787};
5788
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005789/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005790 * headphone jack and the internal CD lines since these are the only pins at
5791 * which audio can appear. For flexibility, also allow the option of
5792 * recording the mixer output on the second ADC (ADC0 doesn't have a
5793 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005794 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005795static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5796 {
5797 .num_items = 3,
5798 .items = {
5799 { "Mic/Line", 0x0 },
5800 { "CD", 0x4 },
5801 { "Headphone", 0x2 },
5802 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005803 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005804 {
5805 .num_items = 4,
5806 .items = {
5807 { "Mic/Line", 0x0 },
5808 { "CD", 0x4 },
5809 { "Headphone", 0x2 },
5810 { "Mixer", 0x5 },
5811 },
5812 },
5813
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005814};
5815
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005816/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5817 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005818 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005819static struct hda_input_mux alc260_acer_capture_sources[2] = {
5820 {
5821 .num_items = 4,
5822 .items = {
5823 { "Mic", 0x0 },
5824 { "Line", 0x2 },
5825 { "CD", 0x4 },
5826 { "Headphone", 0x5 },
5827 },
5828 },
5829 {
5830 .num_items = 5,
5831 .items = {
5832 { "Mic", 0x0 },
5833 { "Line", 0x2 },
5834 { "CD", 0x4 },
5835 { "Headphone", 0x6 },
5836 { "Mixer", 0x5 },
5837 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005838 },
5839};
Michael Schwingencc959482009-02-22 18:58:45 +01005840
5841/* Maxdata Favorit 100XS */
5842static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5843 {
5844 .num_items = 2,
5845 .items = {
5846 { "Line/Mic", 0x0 },
5847 { "CD", 0x4 },
5848 },
5849 },
5850 {
5851 .num_items = 3,
5852 .items = {
5853 { "Line/Mic", 0x0 },
5854 { "CD", 0x4 },
5855 { "Mixer", 0x5 },
5856 },
5857 },
5858};
5859
Linus Torvalds1da177e2005-04-16 15:20:36 -07005860/*
5861 * This is just place-holder, so there's something for alc_build_pcms to look
5862 * at when it calculates the maximum number of channels. ALC260 has no mixer
5863 * element which allows changing the channel mode, so the verb list is
5864 * never used.
5865 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005866static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005867 { 2, NULL },
5868};
5869
Kailang Yangdf694da2005-12-05 19:42:22 +01005870
5871/* Mixer combinations
5872 *
5873 * basic: base_output + input + pc_beep + capture
5874 * HP: base_output + input + capture_alt
5875 * HP_3013: hp_3013 + input + capture
5876 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005877 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005878 */
5879
5880static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005881 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005882 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005883 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5884 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5885 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5886 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5887 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005888};
Kailang Yangdf694da2005-12-05 19:42:22 +01005889
5890static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005891 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5892 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5893 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5894 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5895 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5896 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5897 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5898 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005899 { } /* end */
5900};
5901
Takashi Iwaibec15c32008-01-28 18:16:30 +01005902/* update HP, line and mono out pins according to the master switch */
5903static void alc260_hp_master_update(struct hda_codec *codec,
5904 hda_nid_t hp, hda_nid_t line,
5905 hda_nid_t mono)
5906{
5907 struct alc_spec *spec = codec->spec;
5908 unsigned int val = spec->master_sw ? PIN_HP : 0;
5909 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005910 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005911 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005912 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005913 val);
5914 /* mono (speaker) depending on the HP jack sense */
5915 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005916 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005917 val);
5918}
5919
5920static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5921 struct snd_ctl_elem_value *ucontrol)
5922{
5923 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5924 struct alc_spec *spec = codec->spec;
5925 *ucontrol->value.integer.value = spec->master_sw;
5926 return 0;
5927}
5928
5929static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5930 struct snd_ctl_elem_value *ucontrol)
5931{
5932 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5933 struct alc_spec *spec = codec->spec;
5934 int val = !!*ucontrol->value.integer.value;
5935 hda_nid_t hp, line, mono;
5936
5937 if (val == spec->master_sw)
5938 return 0;
5939 spec->master_sw = val;
5940 hp = (kcontrol->private_value >> 16) & 0xff;
5941 line = (kcontrol->private_value >> 8) & 0xff;
5942 mono = kcontrol->private_value & 0xff;
5943 alc260_hp_master_update(codec, hp, line, mono);
5944 return 1;
5945}
5946
5947static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5948 {
5949 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5950 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005951 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005952 .info = snd_ctl_boolean_mono_info,
5953 .get = alc260_hp_master_sw_get,
5954 .put = alc260_hp_master_sw_put,
5955 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5956 },
5957 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5958 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5959 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5960 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5961 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5962 HDA_OUTPUT),
5963 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5964 { } /* end */
5965};
5966
5967static struct hda_verb alc260_hp_unsol_verbs[] = {
5968 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5969 {},
5970};
5971
5972static void alc260_hp_automute(struct hda_codec *codec)
5973{
5974 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005975
Wu Fengguang864f92b2009-11-18 12:38:02 +08005976 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005977 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5978}
5979
5980static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5981{
5982 if ((res >> 26) == ALC880_HP_EVENT)
5983 alc260_hp_automute(codec);
5984}
5985
Kailang Yangdf694da2005-12-05 19:42:22 +01005986static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005987 {
5988 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5989 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005990 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005991 .info = snd_ctl_boolean_mono_info,
5992 .get = alc260_hp_master_sw_get,
5993 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005994 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005995 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005996 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5997 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5998 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5999 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
6000 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6001 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01006002 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6003 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02006004 { } /* end */
6005};
6006
Kailang Yang3f878302008-08-26 13:02:23 +02006007static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
6008 .ops = &snd_hda_bind_vol,
6009 .values = {
6010 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
6011 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
6012 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
6013 0
6014 },
6015};
6016
6017static struct hda_bind_ctls alc260_dc7600_bind_switch = {
6018 .ops = &snd_hda_bind_sw,
6019 .values = {
6020 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
6021 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
6022 0
6023 },
6024};
6025
6026static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
6027 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
6028 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
6029 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
6030 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
6031 { } /* end */
6032};
6033
Takashi Iwaibec15c32008-01-28 18:16:30 +01006034static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
6035 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6036 {},
6037};
6038
6039static void alc260_hp_3013_automute(struct hda_codec *codec)
6040{
6041 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006042
Wu Fengguang864f92b2009-11-18 12:38:02 +08006043 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01006044 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01006045}
6046
6047static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
6048 unsigned int res)
6049{
6050 if ((res >> 26) == ALC880_HP_EVENT)
6051 alc260_hp_3013_automute(codec);
6052}
6053
Kailang Yang3f878302008-08-26 13:02:23 +02006054static void alc260_hp_3012_automute(struct hda_codec *codec)
6055{
Wu Fengguang864f92b2009-11-18 12:38:02 +08006056 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02006057
Kailang Yang3f878302008-08-26 13:02:23 +02006058 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6059 bits);
6060 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6061 bits);
6062 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6063 bits);
6064}
6065
6066static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
6067 unsigned int res)
6068{
6069 if ((res >> 26) == ALC880_HP_EVENT)
6070 alc260_hp_3012_automute(codec);
6071}
6072
6073/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006074 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
6075 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006076static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006077 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006078 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006079 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006080 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6081 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6082 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
6083 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006084 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006085 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6086 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006087 { } /* end */
6088};
6089
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006090/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
6091 * versions of the ALC260 don't act on requests to enable mic bias from NID
6092 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
6093 * datasheet doesn't mention this restriction. At this stage it's not clear
6094 * whether this behaviour is intentional or is a hardware bug in chip
6095 * revisions available in early 2006. Therefore for now allow the
6096 * "Headphone Jack Mode" control to span all choices, but if it turns out
6097 * that the lack of mic bias for this NID is intentional we could change the
6098 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6099 *
6100 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
6101 * don't appear to make the mic bias available from the "line" jack, even
6102 * though the NID used for this jack (0x14) can supply it. The theory is
6103 * that perhaps Acer have included blocking capacitors between the ALC260
6104 * and the output jack. If this turns out to be the case for all such
6105 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
6106 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01006107 *
6108 * The C20x Tablet series have a mono internal speaker which is controlled
6109 * via the chip's Mono sum widget and pin complex, so include the necessary
6110 * controls for such models. On models without a "mono speaker" the control
6111 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006112 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006113static struct snd_kcontrol_new alc260_acer_mixer[] = {
6114 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6115 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006116 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006117 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01006118 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006119 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01006120 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006121 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6122 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6123 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6124 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6125 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6126 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6127 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6128 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006129 { } /* end */
6130};
6131
Michael Schwingencc959482009-02-22 18:58:45 +01006132/* Maxdata Favorit 100XS: one output and one input (0x12) jack
6133 */
6134static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
6135 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6136 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
6137 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
6138 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6139 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6140 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6141 { } /* end */
6142};
6143
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006144/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
6145 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
6146 */
6147static struct snd_kcontrol_new alc260_will_mixer[] = {
6148 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6149 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6150 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6151 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6152 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6153 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6154 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6155 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6156 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6157 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006158 { } /* end */
6159};
6160
6161/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
6162 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
6163 */
6164static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
6165 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6166 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6167 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6168 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6169 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6170 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
6171 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
6172 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6173 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6174 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6175 { } /* end */
6176};
6177
Kailang Yangdf694da2005-12-05 19:42:22 +01006178/*
6179 * initialization verbs
6180 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006181static struct hda_verb alc260_init_verbs[] = {
6182 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006183 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006184 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006185 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006186 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006187 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006188 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006189 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006190 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02006191 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006192 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01006193 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006194 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02006195 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006196 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02006197 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006198 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02006199 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6200 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02006201 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006202 /* set connection select to line in (default select for this ADC) */
6203 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02006204 /* mute capture amp left and right */
6205 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6206 /* set connection select to line in (default select for this ADC) */
6207 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02006208 /* set vol=0 Line-Out mixer amp left and right */
6209 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6210 /* unmute pin widget amp left and right (no gain on this amp) */
6211 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6212 /* set vol=0 HP mixer amp left and right */
6213 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6214 /* unmute pin widget amp left and right (no gain on this amp) */
6215 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6216 /* set vol=0 Mono mixer amp left and right */
6217 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6218 /* unmute pin widget amp left and right (no gain on this amp) */
6219 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6220 /* unmute LINE-2 out pin */
6221 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006222 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6223 * Line In 2 = 0x03
6224 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006225 /* mute analog inputs */
6226 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6227 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6228 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6229 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6230 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006231 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006232 /* mute Front out path */
6233 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6234 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6235 /* mute Headphone out path */
6236 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6237 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6238 /* mute Mono out path */
6239 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6240 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006241 { }
6242};
6243
Takashi Iwai474167d2006-05-17 17:17:43 +02006244#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01006245static struct hda_verb alc260_hp_init_verbs[] = {
6246 /* Headphone and output */
6247 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6248 /* mono output */
6249 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6250 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6251 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6252 /* Mic2 (front panel) pin widget for input and vref at 80% */
6253 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6254 /* Line In pin widget for input */
6255 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6256 /* Line-2 pin widget for output */
6257 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6258 /* CD pin widget for input */
6259 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6260 /* unmute amp left and right */
6261 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6262 /* set connection select to line in (default select for this ADC) */
6263 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6264 /* unmute Line-Out mixer amp left and right (volume = 0) */
6265 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6266 /* mute pin widget amp left and right (no gain on this amp) */
6267 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6268 /* unmute HP mixer amp left and right (volume = 0) */
6269 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6270 /* mute pin widget amp left and right (no gain on this amp) */
6271 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006272 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6273 * Line In 2 = 0x03
6274 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006275 /* mute analog inputs */
6276 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6277 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6278 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6279 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6280 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006281 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6282 /* Unmute Front out path */
6283 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6284 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6285 /* Unmute Headphone out path */
6286 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6287 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6288 /* Unmute Mono out path */
6289 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6290 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6291 { }
6292};
Takashi Iwai474167d2006-05-17 17:17:43 +02006293#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006294
6295static struct hda_verb alc260_hp_3013_init_verbs[] = {
6296 /* Line out and output */
6297 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6298 /* mono output */
6299 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6300 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6301 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6302 /* Mic2 (front panel) pin widget for input and vref at 80% */
6303 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6304 /* Line In pin widget for input */
6305 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6306 /* Headphone pin widget for output */
6307 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6308 /* CD pin widget for input */
6309 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6310 /* unmute amp left and right */
6311 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6312 /* set connection select to line in (default select for this ADC) */
6313 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6314 /* unmute Line-Out mixer amp left and right (volume = 0) */
6315 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6316 /* mute pin widget amp left and right (no gain on this amp) */
6317 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6318 /* unmute HP mixer amp left and right (volume = 0) */
6319 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6320 /* mute pin widget amp left and right (no gain on this amp) */
6321 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006322 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6323 * Line In 2 = 0x03
6324 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006325 /* mute analog inputs */
6326 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6327 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6328 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6329 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6330 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006331 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6332 /* Unmute Front out path */
6333 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6334 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6335 /* Unmute Headphone out path */
6336 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6337 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6338 /* Unmute Mono out path */
6339 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6340 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6341 { }
6342};
6343
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006344/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006345 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6346 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006347 */
6348static struct hda_verb alc260_fujitsu_init_verbs[] = {
6349 /* Disable all GPIOs */
6350 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6351 /* Internal speaker is connected to headphone pin */
6352 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6353 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6354 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006355 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6356 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6357 /* Ensure all other unused pins are disabled and muted. */
6358 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6359 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006360 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006361 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006362 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006363 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6364 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6365 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006366
Jonathan Woithef7ace402006-02-28 11:46:14 +01006367 /* Disable digital (SPDIF) pins */
6368 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6369 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006370
Kailang Yangea1fb292008-08-26 12:58:38 +02006371 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006372 * when acting as an output.
6373 */
6374 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6375
6376 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006377 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6378 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6379 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6380 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6381 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6382 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6383 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6384 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6385 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006386
Jonathan Woithef7ace402006-02-28 11:46:14 +01006387 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6388 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6389 /* Unmute Line1 pin widget output buffer since it starts as an output.
6390 * If the pin mode is changed by the user the pin mode control will
6391 * take care of enabling the pin's input/output buffers as needed.
6392 * Therefore there's no need to enable the input buffer at this
6393 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006394 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006395 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006396 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006397 * mixer ctrl)
6398 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006399 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006400
Jonathan Woithef7ace402006-02-28 11:46:14 +01006401 /* Mute capture amp left and right */
6402 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006403 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006404 * in (on mic1 pin)
6405 */
6406 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006407
Jonathan Woithef7ace402006-02-28 11:46:14 +01006408 /* Do the same for the second ADC: mute capture input amp and
6409 * set ADC connection to line in (on mic1 pin)
6410 */
6411 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6412 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006413
Jonathan Woithef7ace402006-02-28 11:46:14 +01006414 /* Mute all inputs to mixer widget (even unconnected ones) */
6415 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6416 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6417 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6418 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6419 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6420 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6421 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6422 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006423
6424 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006425};
6426
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006427/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6428 * similar laptops (adapted from Fujitsu init verbs).
6429 */
6430static struct hda_verb alc260_acer_init_verbs[] = {
6431 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6432 * the headphone jack. Turn this on and rely on the standard mute
6433 * methods whenever the user wants to turn these outputs off.
6434 */
6435 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6436 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6437 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6438 /* Internal speaker/Headphone jack is connected to Line-out pin */
6439 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6440 /* Internal microphone/Mic jack is connected to Mic1 pin */
6441 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6442 /* Line In jack is connected to Line1 pin */
6443 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006444 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6445 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006446 /* Ensure all other unused pins are disabled and muted. */
6447 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6448 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006449 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6450 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6451 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6452 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6453 /* Disable digital (SPDIF) pins */
6454 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6455 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6456
Kailang Yangea1fb292008-08-26 12:58:38 +02006457 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006458 * bus when acting as outputs.
6459 */
6460 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6461 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6462
6463 /* Start with output sum widgets muted and their output gains at min */
6464 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6465 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6466 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6467 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6468 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6469 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6470 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6471 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6472 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6473
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006474 /* Unmute Line-out pin widget amp left and right
6475 * (no equiv mixer ctrl)
6476 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006477 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006478 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6479 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006480 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6481 * inputs. If the pin mode is changed by the user the pin mode control
6482 * will take care of enabling the pin's input/output buffers as needed.
6483 * Therefore there's no need to enable the input buffer at this
6484 * stage.
6485 */
6486 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6487 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6488
6489 /* Mute capture amp left and right */
6490 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6491 /* Set ADC connection select to match default mixer setting - mic
6492 * (on mic1 pin)
6493 */
6494 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6495
6496 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006497 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006498 */
6499 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006500 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006501
6502 /* Mute all inputs to mixer widget (even unconnected ones) */
6503 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6504 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6505 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6506 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6507 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6508 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6509 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6510 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6511
6512 { }
6513};
6514
Michael Schwingencc959482009-02-22 18:58:45 +01006515/* Initialisation sequence for Maxdata Favorit 100XS
6516 * (adapted from Acer init verbs).
6517 */
6518static struct hda_verb alc260_favorit100_init_verbs[] = {
6519 /* GPIO 0 enables the output jack.
6520 * Turn this on and rely on the standard mute
6521 * methods whenever the user wants to turn these outputs off.
6522 */
6523 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6524 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6525 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6526 /* Line/Mic input jack is connected to Mic1 pin */
6527 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6528 /* Ensure all other unused pins are disabled and muted. */
6529 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6530 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6531 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6532 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6533 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6534 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6535 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6536 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6537 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6538 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6539 /* Disable digital (SPDIF) pins */
6540 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6541 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6542
6543 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6544 * bus when acting as outputs.
6545 */
6546 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6547 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6548
6549 /* Start with output sum widgets muted and their output gains at min */
6550 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6551 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6552 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6553 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6554 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6555 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6556 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6557 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6558 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6559
6560 /* Unmute Line-out pin widget amp left and right
6561 * (no equiv mixer ctrl)
6562 */
6563 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6564 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6565 * inputs. If the pin mode is changed by the user the pin mode control
6566 * will take care of enabling the pin's input/output buffers as needed.
6567 * Therefore there's no need to enable the input buffer at this
6568 * stage.
6569 */
6570 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6571
6572 /* Mute capture amp left and right */
6573 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6574 /* Set ADC connection select to match default mixer setting - mic
6575 * (on mic1 pin)
6576 */
6577 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6578
6579 /* Do similar with the second ADC: mute capture input amp and
6580 * set ADC connection to mic to match ALSA's default state.
6581 */
6582 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6583 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6584
6585 /* Mute all inputs to mixer widget (even unconnected ones) */
6586 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6587 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6588 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6589 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6590 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6591 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6592 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6593 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6594
6595 { }
6596};
6597
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006598static struct hda_verb alc260_will_verbs[] = {
6599 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6600 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6601 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6602 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6603 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6604 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6605 {}
6606};
6607
6608static struct hda_verb alc260_replacer_672v_verbs[] = {
6609 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6610 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6611 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6612
6613 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6614 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6615 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6616
6617 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6618 {}
6619};
6620
6621/* toggle speaker-output according to the hp-jack state */
6622static void alc260_replacer_672v_automute(struct hda_codec *codec)
6623{
6624 unsigned int present;
6625
6626 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006627 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006628 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006629 snd_hda_codec_write_cache(codec, 0x01, 0,
6630 AC_VERB_SET_GPIO_DATA, 1);
6631 snd_hda_codec_write_cache(codec, 0x0f, 0,
6632 AC_VERB_SET_PIN_WIDGET_CONTROL,
6633 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006634 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006635 snd_hda_codec_write_cache(codec, 0x01, 0,
6636 AC_VERB_SET_GPIO_DATA, 0);
6637 snd_hda_codec_write_cache(codec, 0x0f, 0,
6638 AC_VERB_SET_PIN_WIDGET_CONTROL,
6639 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006640 }
6641}
6642
6643static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6644 unsigned int res)
6645{
6646 if ((res >> 26) == ALC880_HP_EVENT)
6647 alc260_replacer_672v_automute(codec);
6648}
6649
Kailang Yang3f878302008-08-26 13:02:23 +02006650static struct hda_verb alc260_hp_dc7600_verbs[] = {
6651 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6652 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6653 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6654 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6655 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6656 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6657 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6658 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6659 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6660 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6661 {}
6662};
6663
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006664/* Test configuration for debugging, modelled after the ALC880 test
6665 * configuration.
6666 */
6667#ifdef CONFIG_SND_DEBUG
6668static hda_nid_t alc260_test_dac_nids[1] = {
6669 0x02,
6670};
6671static hda_nid_t alc260_test_adc_nids[2] = {
6672 0x04, 0x05,
6673};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006674/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006675 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006676 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006677 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006678static struct hda_input_mux alc260_test_capture_sources[2] = {
6679 {
6680 .num_items = 7,
6681 .items = {
6682 { "MIC1 pin", 0x0 },
6683 { "MIC2 pin", 0x1 },
6684 { "LINE1 pin", 0x2 },
6685 { "LINE2 pin", 0x3 },
6686 { "CD pin", 0x4 },
6687 { "LINE-OUT pin", 0x5 },
6688 { "HP-OUT pin", 0x6 },
6689 },
6690 },
6691 {
6692 .num_items = 8,
6693 .items = {
6694 { "MIC1 pin", 0x0 },
6695 { "MIC2 pin", 0x1 },
6696 { "LINE1 pin", 0x2 },
6697 { "LINE2 pin", 0x3 },
6698 { "CD pin", 0x4 },
6699 { "Mixer", 0x5 },
6700 { "LINE-OUT pin", 0x6 },
6701 { "HP-OUT pin", 0x7 },
6702 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006703 },
6704};
6705static struct snd_kcontrol_new alc260_test_mixer[] = {
6706 /* Output driver widgets */
6707 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6708 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6709 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6710 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6711 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6712 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6713
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006714 /* Modes for retasking pin widgets
6715 * Note: the ALC260 doesn't seem to act on requests to enable mic
6716 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6717 * mention this restriction. At this stage it's not clear whether
6718 * this behaviour is intentional or is a hardware bug in chip
6719 * revisions available at least up until early 2006. Therefore for
6720 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6721 * choices, but if it turns out that the lack of mic bias for these
6722 * NIDs is intentional we could change their modes from
6723 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6724 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006725 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6726 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6727 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6728 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6729 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6730 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6731
6732 /* Loopback mixer controls */
6733 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6734 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6735 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6736 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6737 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6738 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6739 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6740 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6741 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6742 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006743 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6744 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6745 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6746 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006747
6748 /* Controls for GPIO pins, assuming they are configured as outputs */
6749 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6750 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6751 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6752 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6753
Jonathan Woithe92621f12006-02-28 11:47:47 +01006754 /* Switches to allow the digital IO pins to be enabled. The datasheet
6755 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006756 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006757 */
6758 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6759 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6760
Jonathan Woithef8225f62008-01-08 12:16:54 +01006761 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6762 * this output to turn on an external amplifier.
6763 */
6764 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6765 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6766
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006767 { } /* end */
6768};
6769static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006770 /* Enable all GPIOs as outputs with an initial value of 0 */
6771 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6772 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6773 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6774
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006775 /* Enable retasking pins as output, initially without power amp */
6776 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6777 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6778 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6779 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6780 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6781 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6782
Jonathan Woithe92621f12006-02-28 11:47:47 +01006783 /* Disable digital (SPDIF) pins initially, but users can enable
6784 * them via a mixer switch. In the case of SPDIF-out, this initverb
6785 * payload also sets the generation to 0, output to be in "consumer"
6786 * PCM format, copyright asserted, no pre-emphasis and no validity
6787 * control.
6788 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006789 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6790 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6791
Kailang Yangea1fb292008-08-26 12:58:38 +02006792 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006793 * OUT1 sum bus when acting as an output.
6794 */
6795 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6796 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6797 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6798 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6799
6800 /* Start with output sum widgets muted and their output gains at min */
6801 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6802 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6803 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6804 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6805 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6806 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6807 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6808 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6809 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6810
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006811 /* Unmute retasking pin widget output buffers since the default
6812 * state appears to be output. As the pin mode is changed by the
6813 * user the pin mode control will take care of enabling the pin's
6814 * input/output buffers as needed.
6815 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006816 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6817 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6818 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6819 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6820 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6821 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6822 /* Also unmute the mono-out pin widget */
6823 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6824
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006825 /* Mute capture amp left and right */
6826 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006827 /* Set ADC connection select to match default mixer setting (mic1
6828 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006829 */
6830 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6831
6832 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006833 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006834 */
6835 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6836 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6837
6838 /* Mute all inputs to mixer widget (even unconnected ones) */
6839 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6840 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6841 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6842 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6843 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6844 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6845 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6846 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6847
6848 { }
6849};
6850#endif
6851
Takashi Iwai63300792008-01-24 15:31:36 +01006852#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6853#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006854
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006855#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6856#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6857
Kailang Yangdf694da2005-12-05 19:42:22 +01006858/*
6859 * for BIOS auto-configuration
6860 */
6861
6862static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006863 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006864{
6865 hda_nid_t nid_vol;
6866 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006867 int err;
6868
6869 if (nid >= 0x0f && nid < 0x11) {
6870 nid_vol = nid - 0x7;
6871 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6872 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6873 } else if (nid == 0x11) {
6874 nid_vol = nid - 0x7;
6875 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6876 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6877 } else if (nid >= 0x12 && nid <= 0x15) {
6878 nid_vol = 0x08;
6879 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6880 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6881 } else
6882 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006883
Takashi Iwai863b4512008-10-21 17:01:47 +02006884 if (!(*vol_bits & (1 << nid_vol))) {
6885 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006886 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006887 if (err < 0)
6888 return err;
6889 *vol_bits |= (1 << nid_vol);
6890 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006891 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006892 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006893 return err;
6894 return 1;
6895}
6896
6897/* add playback controls from the parsed DAC table */
6898static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6899 const struct auto_pin_cfg *cfg)
6900{
6901 hda_nid_t nid;
6902 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006903 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006904
6905 spec->multiout.num_dacs = 1;
6906 spec->multiout.dac_nids = spec->private_dac_nids;
6907 spec->multiout.dac_nids[0] = 0x02;
6908
6909 nid = cfg->line_out_pins[0];
6910 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006911 const char *pfx;
6912 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6913 pfx = "Master";
6914 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6915 pfx = "Speaker";
6916 else
6917 pfx = "Front";
6918 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006919 if (err < 0)
6920 return err;
6921 }
6922
Takashi Iwai82bc9552006-03-21 11:24:42 +01006923 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006924 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006925 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006926 if (err < 0)
6927 return err;
6928 }
6929
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006930 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006931 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006932 err = alc260_add_playback_controls(spec, nid, "Headphone",
6933 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006934 if (err < 0)
6935 return err;
6936 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006937 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006938}
6939
6940/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006941static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006942 const struct auto_pin_cfg *cfg)
6943{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006944 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006945}
6946
6947static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6948 hda_nid_t nid, int pin_type,
6949 int sel_idx)
6950{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006951 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006952 /* need the manual connection? */
6953 if (nid >= 0x12) {
6954 int idx = nid - 0x12;
6955 snd_hda_codec_write(codec, idx + 0x0b, 0,
6956 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006957 }
6958}
6959
6960static void alc260_auto_init_multi_out(struct hda_codec *codec)
6961{
6962 struct alc_spec *spec = codec->spec;
6963 hda_nid_t nid;
6964
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006965 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006966 if (nid) {
6967 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6968 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6969 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006970
Takashi Iwai82bc9552006-03-21 11:24:42 +01006971 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006972 if (nid)
6973 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6974
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006975 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006976 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006977 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006978}
Kailang Yangdf694da2005-12-05 19:42:22 +01006979
6980#define ALC260_PIN_CD_NID 0x16
6981static void alc260_auto_init_analog_input(struct hda_codec *codec)
6982{
6983 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006984 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +01006985 int i;
6986
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006987 for (i = 0; i < cfg->num_inputs; i++) {
6988 hda_nid_t nid = cfg->inputs[i].pin;
Kailang Yangdf694da2005-12-05 19:42:22 +01006989 if (nid >= 0x12) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02006990 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006991 if (nid != ALC260_PIN_CD_NID &&
6992 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006993 snd_hda_codec_write(codec, nid, 0,
6994 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006995 AMP_OUT_MUTE);
6996 }
6997 }
6998}
6999
Takashi Iwai7f311a42010-04-09 17:32:23 +02007000#define alc260_auto_init_input_src alc880_auto_init_input_src
7001
Kailang Yangdf694da2005-12-05 19:42:22 +01007002/*
7003 * generic initialization of ADC, input mixers and output mixers
7004 */
7005static struct hda_verb alc260_volume_init_verbs[] = {
7006 /*
7007 * Unmute ADC0-1 and set the default input to mic-in
7008 */
7009 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
7010 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7011 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
7012 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02007013
Kailang Yangdf694da2005-12-05 19:42:22 +01007014 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7015 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007016 * Note: PASD motherboards uses the Line In 2 as the input for
7017 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007018 */
7019 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007020 /* mute analog inputs */
7021 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7022 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7023 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7024 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7025 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007026
7027 /*
7028 * Set up output mixers (0x08 - 0x0a)
7029 */
7030 /* set vol=0 to output mixers */
7031 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7032 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7033 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7034 /* set up input amps for analog loopback */
7035 /* Amp Indices: DAC = 0, mixer = 1 */
7036 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7037 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7038 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7039 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7040 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7041 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02007042
Kailang Yangdf694da2005-12-05 19:42:22 +01007043 { }
7044};
7045
7046static int alc260_parse_auto_config(struct hda_codec *codec)
7047{
7048 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007049 int err;
7050 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
7051
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007052 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7053 alc260_ignore);
7054 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007055 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007056 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
7057 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01007058 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02007059 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01007060 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02007061 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007062 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007063 return err;
7064
7065 spec->multiout.max_channels = 2;
7066
Takashi Iwai0852d7a2009-02-11 11:35:15 +01007067 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007068 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02007069 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01007070 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01007071
Takashi Iwaid88897e2008-10-31 15:01:37 +01007072 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01007073
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007074 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007075 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007076
Kailang Yang6227cdc2010-02-25 08:36:52 +01007077 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02007078
Kailang Yangdf694da2005-12-05 19:42:22 +01007079 return 1;
7080}
7081
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007082/* additional initialization for auto-configuration model */
7083static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007084{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007085 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007086 alc260_auto_init_multi_out(codec);
7087 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02007088 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02007089 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007090 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007091 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007092}
7093
Takashi Iwaicb53c622007-08-10 17:21:45 +02007094#ifdef CONFIG_SND_HDA_POWER_SAVE
7095static struct hda_amp_list alc260_loopbacks[] = {
7096 { 0x07, HDA_INPUT, 0 },
7097 { 0x07, HDA_INPUT, 1 },
7098 { 0x07, HDA_INPUT, 2 },
7099 { 0x07, HDA_INPUT, 3 },
7100 { 0x07, HDA_INPUT, 4 },
7101 { } /* end */
7102};
7103#endif
7104
Kailang Yangdf694da2005-12-05 19:42:22 +01007105/*
Takashi Iwaifc091762010-08-04 23:53:36 +02007106 * Pin config fixes
7107 */
7108enum {
7109 PINFIX_HP_DC5750,
7110};
7111
Takashi Iwaifc091762010-08-04 23:53:36 +02007112static const struct alc_fixup alc260_fixups[] = {
7113 [PINFIX_HP_DC5750] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007114 .type = ALC_FIXUP_PINS,
7115 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +02007116 { 0x11, 0x90130110 }, /* speaker */
7117 { }
7118 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007119 },
7120};
7121
7122static struct snd_pci_quirk alc260_fixup_tbl[] = {
7123 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
7124 {}
7125};
7126
7127/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007128 * ALC260 configurations
7129 */
Takashi Iwaiea734962011-01-17 11:29:34 +01007130static const char * const alc260_models[ALC260_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007131 [ALC260_BASIC] = "basic",
7132 [ALC260_HP] = "hp",
7133 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02007134 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007135 [ALC260_FUJITSU_S702X] = "fujitsu",
7136 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007137 [ALC260_WILL] = "will",
7138 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01007139 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007140#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007141 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007142#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007143 [ALC260_AUTO] = "auto",
7144};
7145
7146static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01007147 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05007148 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007149 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01007150 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01007151 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01007152 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007153 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02007154 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02007155 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007156 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
7157 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
7158 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
7159 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
7160 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
7161 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
7162 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
7163 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
7164 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007165 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007166 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02007167 {}
7168};
7169
Kailang Yangdf694da2005-12-05 19:42:22 +01007170static struct alc_config_preset alc260_presets[] = {
7171 [ALC260_BASIC] = {
7172 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007173 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007174 .init_verbs = { alc260_init_verbs },
7175 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7176 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007177 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01007178 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007179 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7180 .channel_mode = alc260_modes,
7181 .input_mux = &alc260_capture_source,
7182 },
7183 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01007184 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007185 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007186 .init_verbs = { alc260_init_verbs,
7187 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007188 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7189 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007190 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7191 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007192 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7193 .channel_mode = alc260_modes,
7194 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007195 .unsol_event = alc260_hp_unsol_event,
7196 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007197 },
Kailang Yang3f878302008-08-26 13:02:23 +02007198 [ALC260_HP_DC7600] = {
7199 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007200 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02007201 .init_verbs = { alc260_init_verbs,
7202 alc260_hp_dc7600_verbs },
7203 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7204 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007205 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7206 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02007207 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7208 .channel_mode = alc260_modes,
7209 .input_mux = &alc260_capture_source,
7210 .unsol_event = alc260_hp_3012_unsol_event,
7211 .init_hook = alc260_hp_3012_automute,
7212 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007213 [ALC260_HP_3013] = {
7214 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007215 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007216 .init_verbs = { alc260_hp_3013_init_verbs,
7217 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007218 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7219 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007220 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7221 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007222 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7223 .channel_mode = alc260_modes,
7224 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007225 .unsol_event = alc260_hp_3013_unsol_event,
7226 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007227 },
7228 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007229 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007230 .init_verbs = { alc260_fujitsu_init_verbs },
7231 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7232 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01007233 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7234 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007235 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7236 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007237 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
7238 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01007239 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007240 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007241 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007242 .init_verbs = { alc260_acer_init_verbs },
7243 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7244 .dac_nids = alc260_dac_nids,
7245 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7246 .adc_nids = alc260_dual_adc_nids,
7247 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7248 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007249 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
7250 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007251 },
Michael Schwingencc959482009-02-22 18:58:45 +01007252 [ALC260_FAVORIT100] = {
7253 .mixers = { alc260_favorit100_mixer },
7254 .init_verbs = { alc260_favorit100_init_verbs },
7255 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7256 .dac_nids = alc260_dac_nids,
7257 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7258 .adc_nids = alc260_dual_adc_nids,
7259 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7260 .channel_mode = alc260_modes,
7261 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
7262 .input_mux = alc260_favorit100_capture_sources,
7263 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007264 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007265 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007266 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
7267 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7268 .dac_nids = alc260_dac_nids,
7269 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7270 .adc_nids = alc260_adc_nids,
7271 .dig_out_nid = ALC260_DIGOUT_NID,
7272 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7273 .channel_mode = alc260_modes,
7274 .input_mux = &alc260_capture_source,
7275 },
7276 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007277 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007278 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
7279 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7280 .dac_nids = alc260_dac_nids,
7281 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7282 .adc_nids = alc260_adc_nids,
7283 .dig_out_nid = ALC260_DIGOUT_NID,
7284 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7285 .channel_mode = alc260_modes,
7286 .input_mux = &alc260_capture_source,
7287 .unsol_event = alc260_replacer_672v_unsol_event,
7288 .init_hook = alc260_replacer_672v_automute,
7289 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007290#ifdef CONFIG_SND_DEBUG
7291 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007292 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007293 .init_verbs = { alc260_test_init_verbs },
7294 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
7295 .dac_nids = alc260_test_dac_nids,
7296 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
7297 .adc_nids = alc260_test_adc_nids,
7298 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7299 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007300 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7301 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007302 },
7303#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007304};
7305
Linus Torvalds1da177e2005-04-16 15:20:36 -07007306static int patch_alc260(struct hda_codec *codec)
7307{
7308 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007309 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007310
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007311 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007312 if (spec == NULL)
7313 return -ENOMEM;
7314
7315 codec->spec = spec;
7316
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007317 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7318 alc260_models,
7319 alc260_cfg_tbl);
7320 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007321 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007322 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007323 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007324 }
7325
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007326 if (board_config == ALC260_AUTO) {
7327 alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups);
7328 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
7329 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007330
Kailang Yangdf694da2005-12-05 19:42:22 +01007331 if (board_config == ALC260_AUTO) {
7332 /* automatic parse from the BIOS config */
7333 err = alc260_parse_auto_config(codec);
7334 if (err < 0) {
7335 alc_free(codec);
7336 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007337 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007338 printk(KERN_INFO
7339 "hda_codec: Cannot set up configuration "
7340 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007341 board_config = ALC260_BASIC;
7342 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007343 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007344
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007345 err = snd_hda_attach_beep_device(codec, 0x1);
7346 if (err < 0) {
7347 alc_free(codec);
7348 return err;
7349 }
7350
Kailang Yangdf694da2005-12-05 19:42:22 +01007351 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007352 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007353
Linus Torvalds1da177e2005-04-16 15:20:36 -07007354 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7355 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307356 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007357
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007358 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7359 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7360
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007361 if (!spec->adc_nids && spec->input_mux) {
7362 /* check whether NID 0x04 is valid */
7363 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007364 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007365 /* get type */
7366 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7367 spec->adc_nids = alc260_adc_nids_alt;
7368 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7369 } else {
7370 spec->adc_nids = alc260_adc_nids;
7371 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7372 }
7373 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007374 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007375 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007376
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007377 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaifc091762010-08-04 23:53:36 +02007378
Takashi Iwai2134ea42008-01-10 16:53:55 +01007379 spec->vmaster_nid = 0x08;
7380
Linus Torvalds1da177e2005-04-16 15:20:36 -07007381 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007382 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007383 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007384#ifdef CONFIG_SND_HDA_POWER_SAVE
7385 if (!spec->loopback.amplist)
7386 spec->loopback.amplist = alc260_loopbacks;
7387#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007388
7389 return 0;
7390}
7391
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007392
Linus Torvalds1da177e2005-04-16 15:20:36 -07007393/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007394 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007395 *
7396 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7397 * configuration. Each pin widget can choose any input DACs and a mixer.
7398 * Each ADC is connected from a mixer of all inputs. This makes possible
7399 * 6-channel independent captures.
7400 *
7401 * In addition, an independent DAC for the multi-playback (not used in this
7402 * driver yet).
7403 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007404#define ALC882_DIGOUT_NID 0x06
7405#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007406#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7407#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7408#define ALC1200_DIGOUT_NID 0x10
7409
Linus Torvalds1da177e2005-04-16 15:20:36 -07007410
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007411static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007412 { 8, NULL }
7413};
7414
Takashi Iwai4953550a2009-06-30 15:28:30 +02007415/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007416static hda_nid_t alc882_dac_nids[4] = {
7417 /* front, rear, clfe, rear_surr */
7418 0x02, 0x03, 0x04, 0x05
7419};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007420#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007421
Takashi Iwai4953550a2009-06-30 15:28:30 +02007422/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007423#define alc882_adc_nids alc880_adc_nids
7424#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007425#define alc883_adc_nids alc882_adc_nids_alt
7426static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7427static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7428#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007429
Takashi Iwaie1406342008-02-11 18:32:32 +01007430static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7431static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007432#define alc883_capsrc_nids alc882_capsrc_nids_alt
7433static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7434#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007435
Linus Torvalds1da177e2005-04-16 15:20:36 -07007436/* input MUX */
7437/* FIXME: should be a matrix-type input source selection */
7438
7439static struct hda_input_mux alc882_capture_source = {
7440 .num_items = 4,
7441 .items = {
7442 { "Mic", 0x0 },
7443 { "Front Mic", 0x1 },
7444 { "Line", 0x2 },
7445 { "CD", 0x4 },
7446 },
7447};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007448
Takashi Iwai4953550a2009-06-30 15:28:30 +02007449#define alc883_capture_source alc882_capture_source
7450
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007451static struct hda_input_mux alc889_capture_source = {
7452 .num_items = 3,
7453 .items = {
7454 { "Front Mic", 0x0 },
7455 { "Mic", 0x3 },
7456 { "Line", 0x2 },
7457 },
7458};
7459
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007460static struct hda_input_mux mb5_capture_source = {
7461 .num_items = 3,
7462 .items = {
7463 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307464 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007465 { "CD", 0x4 },
7466 },
7467};
7468
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007469static struct hda_input_mux macmini3_capture_source = {
7470 .num_items = 2,
7471 .items = {
7472 { "Line", 0x2 },
7473 { "CD", 0x4 },
7474 },
7475};
7476
Takashi Iwai4953550a2009-06-30 15:28:30 +02007477static struct hda_input_mux alc883_3stack_6ch_intel = {
7478 .num_items = 4,
7479 .items = {
7480 { "Mic", 0x1 },
7481 { "Front Mic", 0x0 },
7482 { "Line", 0x2 },
7483 { "CD", 0x4 },
7484 },
7485};
7486
7487static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7488 .num_items = 2,
7489 .items = {
7490 { "Mic", 0x1 },
7491 { "Line", 0x2 },
7492 },
7493};
7494
7495static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7496 .num_items = 4,
7497 .items = {
7498 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007499 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007500 { "Line", 0x2 },
7501 { "CD", 0x4 },
7502 },
7503};
7504
7505static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7506 .num_items = 2,
7507 .items = {
7508 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007509 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007510 },
7511};
7512
7513static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7514 .num_items = 3,
7515 .items = {
7516 { "Mic", 0x0 },
7517 { "Front Mic", 0x1 },
7518 { "Line", 0x4 },
7519 },
7520};
7521
7522static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7523 .num_items = 2,
7524 .items = {
7525 { "Mic", 0x0 },
7526 { "Line", 0x2 },
7527 },
7528};
7529
7530static struct hda_input_mux alc889A_mb31_capture_source = {
7531 .num_items = 2,
7532 .items = {
7533 { "Mic", 0x0 },
7534 /* Front Mic (0x01) unused */
7535 { "Line", 0x2 },
7536 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007537 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007538 },
7539};
7540
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007541static struct hda_input_mux alc889A_imac91_capture_source = {
7542 .num_items = 2,
7543 .items = {
7544 { "Mic", 0x01 },
7545 { "Line", 0x2 }, /* Not sure! */
7546 },
7547};
7548
Takashi Iwai4953550a2009-06-30 15:28:30 +02007549/*
7550 * 2ch mode
7551 */
7552static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7553 { 2, NULL }
7554};
7555
Kailang Yangdf694da2005-12-05 19:42:22 +01007556/*
Kailang Yang272a5272007-05-14 11:00:38 +02007557 * 2ch mode
7558 */
7559static struct hda_verb alc882_3ST_ch2_init[] = {
7560 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7561 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7562 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7563 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7564 { } /* end */
7565};
7566
7567/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007568 * 4ch mode
7569 */
7570static struct hda_verb alc882_3ST_ch4_init[] = {
7571 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7572 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7573 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7574 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7575 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7576 { } /* end */
7577};
7578
7579/*
Kailang Yang272a5272007-05-14 11:00:38 +02007580 * 6ch mode
7581 */
7582static struct hda_verb alc882_3ST_ch6_init[] = {
7583 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7584 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7585 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7586 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7587 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7588 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7589 { } /* end */
7590};
7591
Takashi Iwai4953550a2009-06-30 15:28:30 +02007592static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007593 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007594 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007595 { 6, alc882_3ST_ch6_init },
7596};
7597
Takashi Iwai4953550a2009-06-30 15:28:30 +02007598#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7599
Kailang Yang272a5272007-05-14 11:00:38 +02007600/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307601 * 2ch mode
7602 */
7603static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7604 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7605 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7606 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7607 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7608 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7609 { } /* end */
7610};
7611
7612/*
7613 * 4ch mode
7614 */
7615static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7616 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7617 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7618 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7619 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7620 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7621 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7622 { } /* end */
7623};
7624
7625/*
7626 * 6ch mode
7627 */
7628static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7629 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7630 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7631 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7632 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7633 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7634 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7635 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7636 { } /* end */
7637};
7638
7639static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7640 { 2, alc883_3ST_ch2_clevo_init },
7641 { 4, alc883_3ST_ch4_clevo_init },
7642 { 6, alc883_3ST_ch6_clevo_init },
7643};
7644
7645
7646/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007647 * 6ch mode
7648 */
7649static struct hda_verb alc882_sixstack_ch6_init[] = {
7650 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7651 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7652 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7653 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7654 { } /* end */
7655};
7656
7657/*
7658 * 8ch mode
7659 */
7660static struct hda_verb alc882_sixstack_ch8_init[] = {
7661 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7662 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7663 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7664 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7665 { } /* end */
7666};
7667
7668static struct hda_channel_mode alc882_sixstack_modes[2] = {
7669 { 6, alc882_sixstack_ch6_init },
7670 { 8, alc882_sixstack_ch8_init },
7671};
7672
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007673
7674/* Macbook Air 2,1 */
7675
7676static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7677 { 2, NULL },
7678};
7679
Takashi Iwai87350ad2007-08-16 18:19:38 +02007680/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007681 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007682 */
7683
7684/*
7685 * 2ch mode
7686 */
7687static struct hda_verb alc885_mbp_ch2_init[] = {
7688 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7689 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7690 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7691 { } /* end */
7692};
7693
7694/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007695 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007696 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007697static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007698 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7699 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7700 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7701 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7702 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7703 { } /* end */
7704};
7705
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007706static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007707 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007708 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007709};
7710
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007711/*
7712 * 2ch
7713 * Speakers/Woofer/HP = Front
7714 * LineIn = Input
7715 */
7716static struct hda_verb alc885_mb5_ch2_init[] = {
7717 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7718 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7719 { } /* end */
7720};
7721
7722/*
7723 * 6ch mode
7724 * Speakers/HP = Front
7725 * Woofer = LFE
7726 * LineIn = Surround
7727 */
7728static struct hda_verb alc885_mb5_ch6_init[] = {
7729 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7730 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7731 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7732 { } /* end */
7733};
7734
7735static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7736 { 2, alc885_mb5_ch2_init },
7737 { 6, alc885_mb5_ch6_init },
7738};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007739
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007740#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007741
7742/*
7743 * 2ch mode
7744 */
7745static struct hda_verb alc883_4ST_ch2_init[] = {
7746 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7747 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7748 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7749 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7750 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7751 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7752 { } /* end */
7753};
7754
7755/*
7756 * 4ch mode
7757 */
7758static struct hda_verb alc883_4ST_ch4_init[] = {
7759 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7760 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7761 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7762 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7763 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7764 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7765 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7766 { } /* end */
7767};
7768
7769/*
7770 * 6ch mode
7771 */
7772static struct hda_verb alc883_4ST_ch6_init[] = {
7773 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7774 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7775 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7776 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7777 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7778 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7779 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7780 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7781 { } /* end */
7782};
7783
7784/*
7785 * 8ch mode
7786 */
7787static struct hda_verb alc883_4ST_ch8_init[] = {
7788 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7789 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7790 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7791 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7792 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7793 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7794 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7795 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7796 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7797 { } /* end */
7798};
7799
7800static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7801 { 2, alc883_4ST_ch2_init },
7802 { 4, alc883_4ST_ch4_init },
7803 { 6, alc883_4ST_ch6_init },
7804 { 8, alc883_4ST_ch8_init },
7805};
7806
7807
7808/*
7809 * 2ch mode
7810 */
7811static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7812 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7813 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7814 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7815 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7816 { } /* end */
7817};
7818
7819/*
7820 * 4ch mode
7821 */
7822static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7823 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7824 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7825 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7826 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7827 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7828 { } /* end */
7829};
7830
7831/*
7832 * 6ch mode
7833 */
7834static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7835 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7836 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7837 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7838 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7839 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7840 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7841 { } /* end */
7842};
7843
7844static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7845 { 2, alc883_3ST_ch2_intel_init },
7846 { 4, alc883_3ST_ch4_intel_init },
7847 { 6, alc883_3ST_ch6_intel_init },
7848};
7849
7850/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007851 * 2ch mode
7852 */
7853static struct hda_verb alc889_ch2_intel_init[] = {
7854 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7855 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7856 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7857 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7858 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7859 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7860 { } /* end */
7861};
7862
7863/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007864 * 6ch mode
7865 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007866static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007867 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7868 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7869 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7870 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7871 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007872 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7873 { } /* end */
7874};
7875
7876/*
7877 * 8ch mode
7878 */
7879static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007880 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7881 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7882 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7883 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7884 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007885 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7886 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007887 { } /* end */
7888};
7889
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007890static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7891 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007892 { 6, alc889_ch6_intel_init },
7893 { 8, alc889_ch8_intel_init },
7894};
7895
7896/*
7897 * 6ch mode
7898 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007899static struct hda_verb alc883_sixstack_ch6_init[] = {
7900 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7901 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7902 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7903 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7904 { } /* end */
7905};
7906
7907/*
7908 * 8ch mode
7909 */
7910static struct hda_verb alc883_sixstack_ch8_init[] = {
7911 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7912 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7913 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7914 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7915 { } /* end */
7916};
7917
7918static struct hda_channel_mode alc883_sixstack_modes[2] = {
7919 { 6, alc883_sixstack_ch6_init },
7920 { 8, alc883_sixstack_ch8_init },
7921};
7922
7923
Linus Torvalds1da177e2005-04-16 15:20:36 -07007924/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7925 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7926 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007927static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007928 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007929 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007930 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007931 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007932 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7933 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007934 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7935 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007936 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007937 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007938 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7939 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7940 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7941 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7942 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7943 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007944 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007945 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7946 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007947 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007948 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007949 { } /* end */
7950};
7951
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007952/* Macbook Air 2,1 same control for HP and internal Speaker */
7953
7954static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7955 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7956 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7957 { }
7958};
7959
7960
Takashi Iwai87350ad2007-08-16 18:19:38 +02007961static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007962 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7963 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7964 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7965 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7966 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007967 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7968 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7970 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007971 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
7972 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007973 { } /* end */
7974};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007975
7976static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007977 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),
Alex Murraya76221d2010-01-13 23:15:03 +10307983 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7984 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09307985 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7986 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007987 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7988 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007989 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
7990 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0x00, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007991 { } /* end */
7992};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007993
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007994static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7995 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7996 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7997 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7998 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7999 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
8000 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
8001 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
8002 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
8003 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
8004 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008005 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008006 { } /* end */
8007};
8008
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008009static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008010 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8011 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008012 { } /* end */
8013};
8014
8015
Kailang Yangbdd148a2007-05-08 15:19:08 +02008016static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
8017 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8018 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8019 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8020 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8021 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8022 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8023 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008024 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008025 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008026 { } /* end */
8027};
8028
Kailang Yang272a5272007-05-14 11:00:38 +02008029static struct snd_kcontrol_new alc882_targa_mixer[] = {
8030 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8031 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8032 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8033 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8034 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8035 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8036 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8037 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8038 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008039 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008040 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8041 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008042 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008043 { } /* end */
8044};
8045
8046/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
8047 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
8048 */
8049static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
8050 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8051 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8052 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8053 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8054 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8055 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8056 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8057 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8058 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
8059 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
8060 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8061 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008062 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008063 { } /* end */
8064};
8065
Takashi Iwai914759b2007-09-06 14:52:04 +02008066static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
8067 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8068 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8069 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8070 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8071 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8072 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8073 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8074 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008075 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008076 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008077 { } /* end */
8078};
8079
Kailang Yangdf694da2005-12-05 19:42:22 +01008080static struct snd_kcontrol_new alc882_chmode_mixer[] = {
8081 {
8082 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8083 .name = "Channel Mode",
8084 .info = alc_ch_mode_info,
8085 .get = alc_ch_mode_get,
8086 .put = alc_ch_mode_put,
8087 },
8088 { } /* end */
8089};
8090
Takashi Iwai4953550a2009-06-30 15:28:30 +02008091static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07008092 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008093 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8094 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008095 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008096 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8097 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008098 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008099 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8100 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008101 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008102 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8103 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008104
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008105 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008106 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008107 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008108 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008109 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008110 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008111 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008112 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008113 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008114 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008115 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008116 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008117 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008118 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008119 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008120 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008121 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008122 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008123 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8124 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008125 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008126 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8127 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008128 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008129 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8130 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8131 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8132 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8133 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008134 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008135 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008136
8137 /* FIXME: use matrix-type input source selection */
8138 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008139 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008140 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008141 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008142 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02008143 /* ADC2: mute amp left and right */
8144 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008145 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02008146 /* ADC3: mute amp left and right */
8147 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008148 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008149
8150 { }
8151};
8152
Takashi Iwai4953550a2009-06-30 15:28:30 +02008153static struct hda_verb alc882_adc1_init_verbs[] = {
8154 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8155 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8156 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8157 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8158 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8159 /* ADC1: mute amp left and right */
8160 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8161 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8162 { }
8163};
8164
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008165static struct hda_verb alc882_eapd_verbs[] = {
8166 /* change to EAPD mode */
8167 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008168 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008169 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008170};
8171
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008172static struct hda_verb alc889_eapd_verbs[] = {
8173 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8174 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8175 { }
8176};
8177
Wu Fengguang6732bd02009-07-30 09:19:14 +02008178static struct hda_verb alc_hp15_unsol_verbs[] = {
8179 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8180 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8181 {}
8182};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008183
8184static struct hda_verb alc885_init_verbs[] = {
8185 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01008186 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8187 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008188 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008189 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8190 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008191 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008192 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8193 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008194 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008195 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8196 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008197
8198 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02008199 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008200 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8201 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8202 /* Front Pin: output 0 (0x0c) */
8203 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8204 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8205 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8206 /* Rear Pin: output 1 (0x0d) */
8207 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8208 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8209 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
8210 /* CLFE Pin: output 2 (0x0e) */
8211 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8212 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8213 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8214 /* Side Pin: output 3 (0x0f) */
8215 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8216 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8217 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8218 /* Mic (rear) pin: input vref at 80% */
8219 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8220 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8221 /* Front Mic pin: input vref at 80% */
8222 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8223 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8224 /* Line In pin: input */
8225 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8226 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8227
8228 /* Mixer elements: 0x18, , 0x1a, 0x1b */
8229 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01008230 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008231 /* Input mixer2 */
8232 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008233 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008234 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008235 /* ADC2: mute amp left and right */
8236 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8237 /* ADC3: mute amp left and right */
8238 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8239
8240 { }
8241};
8242
8243static struct hda_verb alc885_init_input_verbs[] = {
8244 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8245 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8246 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8247 { }
8248};
8249
8250
8251/* Unmute Selector 24h and set the default input to front mic */
8252static struct hda_verb alc889_init_input_verbs[] = {
8253 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8254 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8255 { }
8256};
8257
8258
Takashi Iwai4953550a2009-06-30 15:28:30 +02008259#define alc883_init_verbs alc882_base_init_verbs
8260
Tobin Davis9102cd12006-12-15 10:02:12 +01008261/* Mac Pro test */
8262static struct snd_kcontrol_new alc882_macpro_mixer[] = {
8263 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8264 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8265 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
8266 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8267 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008268 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01008269 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
8270 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008271 */
Tobin Davis9102cd12006-12-15 10:02:12 +01008272 { } /* end */
8273};
8274
8275static struct hda_verb alc882_macpro_init_verbs[] = {
8276 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8277 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8278 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8279 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8280 /* Front Pin: output 0 (0x0c) */
8281 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8282 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8283 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8284 /* Front Mic pin: input vref at 80% */
8285 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8286 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8287 /* Speaker: output */
8288 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8289 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8290 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
8291 /* Headphone output (output 0 - 0x0c) */
8292 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8293 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8294 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8295
8296 /* FIXME: use matrix-type input source selection */
8297 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8298 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8299 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8300 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8301 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8302 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8303 /* Input mixer2 */
8304 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8305 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8306 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8307 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8308 /* Input mixer3 */
8309 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8310 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8311 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8312 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8313 /* ADC1: mute amp left and right */
8314 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8315 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8316 /* ADC2: mute amp left and right */
8317 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8318 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8319 /* ADC3: mute amp left and right */
8320 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8321 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8322
8323 { }
8324};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008325
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008326/* Macbook 5,1 */
8327static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008328 /* DACs */
8329 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8330 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8331 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8332 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008333 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008334 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8335 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8336 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008337 /* Surround mixer */
8338 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8339 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8340 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8341 /* LFE mixer */
8342 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8343 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8344 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8345 /* HP mixer */
8346 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8347 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8348 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8349 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008350 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8351 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008352 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8353 /* LFE Pin (0x0e) */
8354 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8355 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8356 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8357 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008358 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8359 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008360 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308361 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008362 /* Front Mic pin: input vref at 80% */
8363 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8364 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8365 /* Line In pin */
8366 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8367 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8368
Alex Murrayb8f171e2010-06-14 12:08:43 +09308369 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8370 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8371 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008372 { }
8373};
8374
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008375/* Macmini 3,1 */
8376static struct hda_verb alc885_macmini3_init_verbs[] = {
8377 /* DACs */
8378 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8379 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8380 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8381 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8382 /* Front mixer */
8383 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8384 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8385 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8386 /* Surround mixer */
8387 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8388 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8389 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8390 /* LFE mixer */
8391 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8392 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8393 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8394 /* HP mixer */
8395 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8396 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8397 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8398 /* Front Pin (0x0c) */
8399 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8400 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8401 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8402 /* LFE Pin (0x0e) */
8403 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8404 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8405 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8406 /* HP Pin (0x0f) */
8407 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8408 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8409 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8410 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8411 /* Line In pin */
8412 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8413 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8414
8415 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8416 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8417 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8418 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8419 { }
8420};
8421
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008422
8423static struct hda_verb alc885_mba21_init_verbs[] = {
8424 /*Internal and HP Speaker Mixer*/
8425 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8426 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8427 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8428 /*Internal Speaker Pin (0x0c)*/
8429 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8430 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8431 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8432 /* HP Pin: output 0 (0x0e) */
8433 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8434 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8435 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8436 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8437 /* Line in (is hp when jack connected)*/
8438 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8439 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8440
8441 { }
8442 };
8443
8444
Takashi Iwai87350ad2007-08-16 18:19:38 +02008445/* Macbook Pro rev3 */
8446static struct hda_verb alc885_mbp3_init_verbs[] = {
8447 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8448 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8449 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8450 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8451 /* Rear mixer */
8452 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8453 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8454 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008455 /* HP mixer */
8456 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8457 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8458 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008459 /* Front Pin: output 0 (0x0c) */
8460 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8461 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8462 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008463 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008464 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008465 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8466 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008467 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8468 /* Mic (rear) pin: input vref at 80% */
8469 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8470 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8471 /* Front Mic pin: input vref at 80% */
8472 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8473 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8474 /* Line In pin: use output 1 when in LineOut mode */
8475 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8476 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8477 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8478
8479 /* FIXME: use matrix-type input source selection */
8480 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8481 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8482 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8483 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8484 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8485 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8486 /* Input mixer2 */
8487 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8488 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8489 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8490 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8491 /* Input mixer3 */
8492 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8493 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8494 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8495 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8496 /* ADC1: mute amp left and right */
8497 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8498 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8499 /* ADC2: mute amp left and right */
8500 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8501 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8502 /* ADC3: mute amp left and right */
8503 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8504 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8505
8506 { }
8507};
8508
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008509/* iMac 9,1 */
8510static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008511 /* Internal Speaker Pin (0x0c) */
8512 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8513 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8514 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8515 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8516 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8517 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8518 /* HP Pin: Rear */
8519 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8520 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8521 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8522 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8523 /* Line in Rear */
8524 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8525 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8526 /* Front Mic pin: input vref at 80% */
8527 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8528 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008529 /* Rear mixer */
8530 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8531 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8532 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008533 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8534 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8535 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8536 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8537 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008538 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8539 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8540 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8541 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008542 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008543 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8544 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8545 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8546 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008547 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008548 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8549 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8550 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8551 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008552 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008553 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8554 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008555 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008556 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8557 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008558 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008559 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8560 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008561 { }
8562};
8563
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008564/* iMac 24 mixer. */
8565static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8566 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8567 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8568 { } /* end */
8569};
8570
8571/* iMac 24 init verbs. */
8572static struct hda_verb alc885_imac24_init_verbs[] = {
8573 /* Internal speakers: output 0 (0x0c) */
8574 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8575 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8576 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8577 /* Internal speakers: output 0 (0x0c) */
8578 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8579 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8580 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8581 /* Headphone: output 0 (0x0c) */
8582 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8583 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8584 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8585 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8586 /* Front Mic: input vref at 80% */
8587 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8588 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8589 { }
8590};
8591
8592/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008593static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008594{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008595 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008596
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008597 spec->autocfg.hp_pins[0] = 0x14;
8598 spec->autocfg.speaker_pins[0] = 0x18;
8599 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008600}
8601
Takashi Iwai9d54f082010-02-22 08:34:40 +01008602#define alc885_mb5_setup alc885_imac24_setup
8603#define alc885_macmini3_setup alc885_imac24_setup
8604
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008605/* Macbook Air 2,1 */
8606static void alc885_mba21_setup(struct hda_codec *codec)
8607{
8608 struct alc_spec *spec = codec->spec;
8609
8610 spec->autocfg.hp_pins[0] = 0x14;
8611 spec->autocfg.speaker_pins[0] = 0x18;
8612}
8613
8614
8615
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008616static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008617{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008618 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008619
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008620 spec->autocfg.hp_pins[0] = 0x15;
8621 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008622}
8623
Takashi Iwai9d54f082010-02-22 08:34:40 +01008624static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308625{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008626 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308627
Takashi Iwai9d54f082010-02-22 08:34:40 +01008628 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008629 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008630 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008631}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008632
Kailang Yang272a5272007-05-14 11:00:38 +02008633static struct hda_verb alc882_targa_verbs[] = {
8634 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8635 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8636
8637 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8638 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008639
Kailang Yang272a5272007-05-14 11:00:38 +02008640 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8641 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8642 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8643
8644 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008645 { } /* end */
8646};
8647
8648/* toggle speaker-output according to the hp-jack state */
8649static void alc882_targa_automute(struct hda_codec *codec)
8650{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008651 struct alc_spec *spec = codec->spec;
8652 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008653 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008654 spec->jack_present ? 1 : 3);
8655}
8656
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008657static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008658{
8659 struct alc_spec *spec = codec->spec;
8660
8661 spec->autocfg.hp_pins[0] = 0x14;
8662 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008663}
8664
8665static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8666{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008667 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008668 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008669}
8670
8671static struct hda_verb alc882_asus_a7j_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
Kailang Yang272a5272007-05-14 11:00:38 +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
Takashi Iwai914759b2007-09-06 14:52:04 +02008689static struct hda_verb alc882_asus_a7m_verbs[] = {
8690 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8691 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8692
8693 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8694 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8695 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008696
Takashi Iwai914759b2007-09-06 14:52:04 +02008697 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8698 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8699 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8700
8701 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8702 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8703 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8704 { } /* end */
8705};
8706
Tobin Davis9102cd12006-12-15 10:02:12 +01008707static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8708{
8709 unsigned int gpiostate, gpiomask, gpiodir;
8710
8711 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8712 AC_VERB_GET_GPIO_DATA, 0);
8713
8714 if (!muted)
8715 gpiostate |= (1 << pin);
8716 else
8717 gpiostate &= ~(1 << pin);
8718
8719 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8720 AC_VERB_GET_GPIO_MASK, 0);
8721 gpiomask |= (1 << pin);
8722
8723 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8724 AC_VERB_GET_GPIO_DIRECTION, 0);
8725 gpiodir |= (1 << pin);
8726
8727
8728 snd_hda_codec_write(codec, codec->afg, 0,
8729 AC_VERB_SET_GPIO_MASK, gpiomask);
8730 snd_hda_codec_write(codec, codec->afg, 0,
8731 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8732
8733 msleep(1);
8734
8735 snd_hda_codec_write(codec, codec->afg, 0,
8736 AC_VERB_SET_GPIO_DATA, gpiostate);
8737}
8738
Takashi Iwai7debbe52007-08-16 15:01:03 +02008739/* set up GPIO at initialization */
8740static void alc885_macpro_init_hook(struct hda_codec *codec)
8741{
8742 alc882_gpio_mute(codec, 0, 0);
8743 alc882_gpio_mute(codec, 1, 0);
8744}
8745
8746/* set up GPIO and update auto-muting at initialization */
8747static void alc885_imac24_init_hook(struct hda_codec *codec)
8748{
8749 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008750 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008751}
8752
Kailang Yangdf694da2005-12-05 19:42:22 +01008753/*
8754 * generic initialization of ADC, input mixers and output mixers
8755 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008756static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008757 /*
8758 * Unmute ADC0-2 and set the default input to mic-in
8759 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008760 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8761 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8762 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8763 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8764
Kailang Yangdf694da2005-12-05 19:42:22 +01008765 /*
8766 * Set up output mixers (0x0c - 0x0f)
8767 */
8768 /* set vol=0 to output mixers */
8769 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8770 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8771 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8772 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8773 /* set up input amps for analog loopback */
8774 /* Amp Indices: DAC = 0, mixer = 1 */
8775 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8776 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8777 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8778 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8779 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8780 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8781 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8782 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8783 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8784 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8785
8786 /* FIXME: use matrix-type input source selection */
8787 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008788 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008789 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008790 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008791 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008792 { }
8793};
8794
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008795/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8796static struct hda_verb alc889A_mb31_ch2_init[] = {
8797 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
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/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8805static struct hda_verb alc889A_mb31_ch4_init[] = {
8806 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8807 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
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
8813/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8814static struct hda_verb alc889A_mb31_ch5_init[] = {
8815 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8816 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8817 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8818 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8819 { } /* end */
8820};
8821
8822/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8823static struct hda_verb alc889A_mb31_ch6_init[] = {
8824 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8825 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8826 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8827 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8828 { } /* end */
8829};
8830
8831static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8832 { 2, alc889A_mb31_ch2_init },
8833 { 4, alc889A_mb31_ch4_init },
8834 { 5, alc889A_mb31_ch5_init },
8835 { 6, alc889A_mb31_ch6_init },
8836};
8837
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008838static struct hda_verb alc883_medion_eapd_verbs[] = {
8839 /* eanable EAPD on medion laptop */
8840 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8841 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8842 { }
8843};
8844
Takashi Iwai4953550a2009-06-30 15:28:30 +02008845#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008846
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008847static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8848 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8849 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8850 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8851 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8852 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8853 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8854 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8855 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008856 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008857 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8858 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008859 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008860 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008861 { } /* end */
8862};
8863
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008864static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008865 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8866 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8867 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8868 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8869 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008870 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008871 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008872 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008873 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008874 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008875 { } /* end */
8876};
8877
Jiang zhefb97dc62008-03-06 11:07:11 +01008878static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8879 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8880 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8881 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8882 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8883 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008884 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008885 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008886 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008887 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008888 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008889 { } /* end */
8890};
8891
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008892static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8893 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8894 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8895 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8896 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8897 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8898 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8899 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8900 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008901 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008902 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8903 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008904 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008905 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008906 { } /* end */
8907};
8908
8909static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8910 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8911 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8912 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8913 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8914 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8915 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8916 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8917 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8918 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8919 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8920 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8921 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8922 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8923 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008924 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008925 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8926 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008927 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008928 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008929 { } /* end */
8930};
8931
Jiang zhe17bba1b2008-06-04 12:11:07 +02008932static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8933 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8934 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8935 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8936 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8937 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8938 HDA_OUTPUT),
8939 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8940 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8941 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8942 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8943 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8944 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8945 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8946 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8947 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008948 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008949 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8950 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008951 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008952 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008953 { } /* end */
8954};
8955
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008956static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8957 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8958 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8959 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8960 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8961 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8962 HDA_OUTPUT),
8963 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8964 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8965 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8966 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8967 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8968 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8969 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8970 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8971 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008972 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008973 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8974 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008975 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008976 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8977 { } /* end */
8978};
8979
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008980static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008981 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008982 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008983 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008984 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008985 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8986 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008987 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8988 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008989 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8990 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8991 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8992 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8993 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8994 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008995 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008996 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8997 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008998 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008999 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009000 { } /* end */
9001};
9002
Sasha Alexandrc2592492009-06-16 14:52:54 -04009003static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009004 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009005 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009006 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009007 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009008 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9009 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9010 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9011 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9012 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9013 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9014 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9015 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9016 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9017 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9018 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009019 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009020 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009021 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009022};
Kailang Yangccc656c2006-10-17 12:32:26 +02009023
Sasha Alexandrc2592492009-06-16 14:52:54 -04009024static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009025 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009026 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009027 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009028 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009029 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9030 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9031 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009032 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009033 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009034 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009035 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009036 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009037 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009038};
Kailang Yangccc656c2006-10-17 12:32:26 +02009039
Takashi Iwaib99dba32009-09-17 18:23:00 +02009040static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
9041 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9042 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009043 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009044 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009045 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009046 { } /* end */
9047};
9048
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009049static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
9050 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9051 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009052 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9053 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009054 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9055 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009056 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009057 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009058 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009059};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009060
Kailang Yang272a5272007-05-14 11:00:38 +02009061static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
9062 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9063 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
9064 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9065 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9066 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9067 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9068 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009069 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9070 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02009071 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02009072};
Kailang Yang272a5272007-05-14 11:00:38 +02009073
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009074static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
9075 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9076 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9077 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9078 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
9079 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
9080 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
9081 { } /* end */
9082};
9083
9084static struct hda_verb alc883_medion_wim2160_verbs[] = {
9085 /* Unmute front mixer */
9086 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9087 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9088
9089 /* Set speaker pin to front mixer */
9090 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9091
9092 /* Init headphone pin */
9093 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9094 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9095 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9096 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9097
9098 { } /* end */
9099};
9100
9101/* toggle speaker-output according to the hp-jack state */
9102static void alc883_medion_wim2160_setup(struct hda_codec *codec)
9103{
9104 struct alc_spec *spec = codec->spec;
9105
9106 spec->autocfg.hp_pins[0] = 0x1a;
9107 spec->autocfg.speaker_pins[0] = 0x15;
9108}
9109
Tobin Davis2880a862007-08-07 11:50:26 +02009110static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02009111 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9112 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009113 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009114 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9115 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009116 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009117 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009118 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009119 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02009120};
Tobin Davis2880a862007-08-07 11:50:26 +02009121
Tony Vroond2fd4b02009-06-21 00:40:10 +01009122static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
9123 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009124 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01009125 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9126 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009127 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9128 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9129 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009130 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009131 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9132 { } /* end */
9133};
9134
Kailang Yange2757d52008-08-26 13:17:46 +02009135static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
9136 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9137 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9138 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9139 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
9140 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
9141 0x0d, 1, 0x0, HDA_OUTPUT),
9142 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
9143 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
9144 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
9145 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9146 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009147 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9148 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9149 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9150 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9151 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009152 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009153 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9154 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009155 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009156 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009157 { } /* end */
9158};
9159
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009160static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
9161 /* Output mixers */
9162 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
9163 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
9164 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
9165 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
9166 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
9167 HDA_OUTPUT),
9168 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
9169 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
9170 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
9171 /* Output switches */
9172 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
9173 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
9174 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
9175 /* Boost mixers */
David Henningsson5f99f862011-01-04 15:24:24 +01009176 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
9177 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009178 /* Input mixers */
9179 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
9180 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
9181 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9182 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9183 { } /* end */
9184};
9185
Guido Günther3e1647c52009-06-05 00:47:26 +02009186static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
9187 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9188 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9189 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9190 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009191 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Guido Günther3e1647c52009-06-05 00:47:26 +02009192 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9193 { } /* end */
9194};
9195
Kailang Yange2757d52008-08-26 13:17:46 +02009196static struct hda_bind_ctls alc883_bind_cap_vol = {
9197 .ops = &snd_hda_bind_vol,
9198 .values = {
9199 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9200 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9201 0
9202 },
9203};
9204
9205static struct hda_bind_ctls alc883_bind_cap_switch = {
9206 .ops = &snd_hda_bind_sw,
9207 .values = {
9208 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9209 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9210 0
9211 },
9212};
9213
9214static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
9215 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9216 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9217 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9218 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9219 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9220 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009221 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009222 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009223 { } /* end */
9224};
9225
9226static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009227 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
9228 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
9229 {
9230 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9231 /* .name = "Capture Source", */
9232 .name = "Input Source",
9233 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009234 .info = alc_mux_enum_info,
9235 .get = alc_mux_enum_get,
9236 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02009237 },
9238 { } /* end */
9239};
9240
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009241static struct snd_kcontrol_new alc883_chmode_mixer[] = {
9242 {
9243 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9244 .name = "Channel Mode",
9245 .info = alc_ch_mode_info,
9246 .get = alc_ch_mode_get,
9247 .put = alc_ch_mode_put,
9248 },
9249 { } /* end */
9250};
9251
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009252/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009253static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009254{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009255 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009256
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009257 spec->autocfg.hp_pins[0] = 0x15;
9258 spec->autocfg.speaker_pins[0] = 0x14;
9259 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009260}
9261
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009262static struct hda_verb alc883_mitac_verbs[] = {
9263 /* HP */
9264 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9265 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9266 /* Subwoofer */
9267 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9268 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9269
9270 /* enable unsolicited event */
9271 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9272 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
9273
9274 { } /* end */
9275};
9276
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309277static struct hda_verb alc883_clevo_m540r_verbs[] = {
9278 /* HP */
9279 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9280 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9281 /* Int speaker */
9282 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9283
9284 /* enable unsolicited event */
9285 /*
9286 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9287 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9288 */
9289
9290 { } /* end */
9291};
9292
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009293static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009294 /* HP */
9295 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9296 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9297 /* Int speaker */
9298 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9299 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9300
9301 /* enable unsolicited event */
9302 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009303 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009304
9305 { } /* end */
9306};
9307
Jiang zhefb97dc62008-03-06 11:07:11 +01009308static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9309 /* HP */
9310 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9311 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9312 /* Subwoofer */
9313 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9314 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9315
9316 /* enable unsolicited event */
9317 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9318
9319 { } /* end */
9320};
9321
Sasha Alexandrc2592492009-06-16 14:52:54 -04009322static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009323 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9324 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9325
9326 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9327 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009328
David Heidelberger64a8be72009-06-08 16:15:18 +02009329/* Connect Line-Out side jack (SPDIF) to Side */
9330 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9331 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9332 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9333/* Connect Mic jack to CLFE */
9334 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9335 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9336 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9337/* Connect Line-in jack to Surround */
9338 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9339 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9340 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9341/* Connect HP out jack to Front */
9342 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9343 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9344 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009345
9346 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009347
9348 { } /* end */
9349};
9350
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009351static struct hda_verb alc883_lenovo_101e_verbs[] = {
9352 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9353 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9354 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9355 { } /* end */
9356};
9357
Kailang Yang272a5272007-05-14 11:00:38 +02009358static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9359 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9360 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9361 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9362 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9363 { } /* end */
9364};
9365
9366static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
9367 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9368 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9369 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9370 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9371 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9372 { } /* end */
9373};
9374
Kailang Yang189609a2007-08-20 11:31:23 +02009375static struct hda_verb alc883_haier_w66_verbs[] = {
9376 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9377 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9378
9379 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9380
9381 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9382 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9383 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9384 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9385 { } /* end */
9386};
9387
Kailang Yange2757d52008-08-26 13:17:46 +02009388static struct hda_verb alc888_lenovo_sky_verbs[] = {
9389 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9390 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9391 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9392 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9393 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9394 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9395 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9396 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9397 { } /* end */
9398};
9399
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009400static struct hda_verb alc888_6st_dell_verbs[] = {
9401 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9402 { }
9403};
9404
Guido Günther3e1647c52009-06-05 00:47:26 +02009405static struct hda_verb alc883_vaiott_verbs[] = {
9406 /* HP */
9407 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9408 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9409
9410 /* enable unsolicited event */
9411 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9412
9413 { } /* end */
9414};
9415
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009416static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009417{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009418 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009419
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009420 spec->autocfg.hp_pins[0] = 0x1b;
9421 spec->autocfg.speaker_pins[0] = 0x14;
9422 spec->autocfg.speaker_pins[1] = 0x16;
9423 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009424}
9425
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009426static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009427 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009428 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9429 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009430 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009431 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009432};
9433
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009434/*
9435 * 2ch mode
9436 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009437static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009438 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9439 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9440 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9441 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009442 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009443};
9444
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009445/*
9446 * 4ch mode
9447 */
9448static struct hda_verb alc888_3st_hp_4ch_init[] = {
9449 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9450 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9451 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9452 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9453 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9454 { } /* end */
9455};
9456
9457/*
9458 * 6ch mode
9459 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009460static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009461 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9462 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009463 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009464 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9465 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009466 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9467 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009468};
9469
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009470static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009471 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009472 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009473 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009474};
9475
Kailang Yang272a5272007-05-14 11:00:38 +02009476/* toggle front-jack and RCA according to the hp-jack state */
9477static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9478{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009479 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02009480
Takashi Iwai47fd8302007-08-10 17:11:07 +02009481 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9482 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9483 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9484 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009485}
9486
9487/* toggle RCA according to the front-jack state */
9488static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9489{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009490 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009491
Takashi Iwai47fd8302007-08-10 17:11:07 +02009492 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9493 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009494}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009495
Kailang Yang272a5272007-05-14 11:00:38 +02009496static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9497 unsigned int res)
9498{
9499 if ((res >> 26) == ALC880_HP_EVENT)
9500 alc888_lenovo_ms7195_front_automute(codec);
9501 if ((res >> 26) == ALC880_FRONT_EVENT)
9502 alc888_lenovo_ms7195_rca_automute(codec);
9503}
9504
Kailang Yang272a5272007-05-14 11:00:38 +02009505/* toggle speaker-output according to the hp-jack state */
Takashi Iwaidc4271702010-11-29 07:42:59 +01009506static void alc883_lenovo_nb0763_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009507{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009508 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009509
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009510 spec->autocfg.hp_pins[0] = 0x14;
9511 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009512}
9513
Kailang Yangccc656c2006-10-17 12:32:26 +02009514/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009515#define alc883_targa_init_hook alc882_targa_init_hook
9516#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009517
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009518static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009519{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009520 struct alc_spec *spec = codec->spec;
9521
9522 spec->autocfg.hp_pins[0] = 0x15;
9523 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009524}
9525
9526static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9527{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009528 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01009529 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009530}
9531
9532static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009533 unsigned int res)
9534{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009535 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009536 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01009537 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009538 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009539 default:
9540 alc_automute_amp_unsol_event(codec, res);
9541 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009542 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009543}
9544
Jiang zhefb97dc62008-03-06 11:07:11 +01009545/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009546static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009547{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009548 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009549
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009550 spec->autocfg.hp_pins[0] = 0x14;
9551 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009552}
9553
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009554static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009555{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009556 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009557
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009558 spec->autocfg.hp_pins[0] = 0x1b;
9559 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009560}
9561
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009562static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9563{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009564 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009565
Takashi Iwai47fd8302007-08-10 17:11:07 +02009566 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9567 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009568}
9569
9570static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9571{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009572 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009573
Takashi Iwai47fd8302007-08-10 17:11:07 +02009574 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9575 HDA_AMP_MUTE, bits);
9576 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9577 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009578}
9579
9580static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9581 unsigned int res)
9582{
9583 if ((res >> 26) == ALC880_HP_EVENT)
9584 alc883_lenovo_101e_all_automute(codec);
9585 if ((res >> 26) == ALC880_FRONT_EVENT)
9586 alc883_lenovo_101e_ispeaker_automute(codec);
9587}
9588
Takashi Iwai676a9b52007-08-16 15:23:35 +02009589/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009590static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009591{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009592 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009593
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009594 spec->autocfg.hp_pins[0] = 0x14;
9595 spec->autocfg.speaker_pins[0] = 0x15;
9596 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009597}
9598
Kailang Yangd1a991a2007-08-15 16:21:59 +02009599static struct hda_verb alc883_acer_eapd_verbs[] = {
9600 /* HP Pin: output 0 (0x0c) */
9601 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9602 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9603 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9604 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009605 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9606 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009607 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009608 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9609 /* eanable EAPD on medion laptop */
9610 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9611 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009612 /* enable unsolicited event */
9613 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009614 { }
9615};
9616
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009617static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009618{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009619 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009620
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009621 spec->autocfg.hp_pins[0] = 0x1b;
9622 spec->autocfg.speaker_pins[0] = 0x14;
9623 spec->autocfg.speaker_pins[1] = 0x15;
9624 spec->autocfg.speaker_pins[2] = 0x16;
9625 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009626}
9627
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009628static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009629{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009630 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009631
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009632 spec->autocfg.hp_pins[0] = 0x1b;
9633 spec->autocfg.speaker_pins[0] = 0x14;
9634 spec->autocfg.speaker_pins[1] = 0x15;
9635 spec->autocfg.speaker_pins[2] = 0x16;
9636 spec->autocfg.speaker_pins[3] = 0x17;
9637 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009638}
9639
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009640static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c52009-06-05 00:47:26 +02009641{
9642 struct alc_spec *spec = codec->spec;
9643
9644 spec->autocfg.hp_pins[0] = 0x15;
9645 spec->autocfg.speaker_pins[0] = 0x14;
9646 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c52009-06-05 00:47:26 +02009647}
9648
Kailang Yange2757d52008-08-26 13:17:46 +02009649static struct hda_verb alc888_asus_m90v_verbs[] = {
9650 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9651 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9652 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9653 /* enable unsolicited event */
9654 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9655 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9656 { } /* end */
9657};
9658
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009659static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009660{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009661 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009662
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009663 spec->autocfg.hp_pins[0] = 0x1b;
9664 spec->autocfg.speaker_pins[0] = 0x14;
9665 spec->autocfg.speaker_pins[1] = 0x15;
9666 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009667 spec->ext_mic.pin = 0x18;
9668 spec->int_mic.pin = 0x19;
9669 spec->ext_mic.mux_idx = 0;
9670 spec->int_mic.mux_idx = 1;
9671 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009672}
9673
9674static struct hda_verb alc888_asus_eee1601_verbs[] = {
9675 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9676 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9677 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9678 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9679 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9680 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9681 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9682 /* enable unsolicited event */
9683 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9684 { } /* end */
9685};
9686
Kailang Yange2757d52008-08-26 13:17:46 +02009687static void alc883_eee1601_inithook(struct hda_codec *codec)
9688{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009689 struct alc_spec *spec = codec->spec;
9690
9691 spec->autocfg.hp_pins[0] = 0x14;
9692 spec->autocfg.speaker_pins[0] = 0x1b;
9693 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009694}
9695
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009696static struct hda_verb alc889A_mb31_verbs[] = {
9697 /* Init rear pin (used as headphone output) */
9698 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9699 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9700 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9701 /* Init line pin (used as output in 4ch and 6ch mode) */
9702 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9703 /* Init line 2 pin (used as headphone out by default) */
9704 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9705 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9706 { } /* end */
9707};
9708
9709/* Mute speakers according to the headphone jack state */
9710static void alc889A_mb31_automute(struct hda_codec *codec)
9711{
9712 unsigned int present;
9713
9714 /* Mute only in 2ch or 4ch mode */
9715 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9716 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009717 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009718 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9719 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9720 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9721 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9722 }
9723}
9724
9725static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9726{
9727 if ((res >> 26) == ALC880_HP_EVENT)
9728 alc889A_mb31_automute(codec);
9729}
9730
Takashi Iwai4953550a2009-06-30 15:28:30 +02009731
Takashi Iwaicb53c622007-08-10 17:21:45 +02009732#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009733#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009734#endif
9735
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009736/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009737#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9738#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9739#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9740#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9741
9742static hda_nid_t alc883_slave_dig_outs[] = {
9743 ALC1200_DIGOUT_NID, 0,
9744};
9745
9746static hda_nid_t alc1200_slave_dig_outs[] = {
9747 ALC883_DIGOUT_NID, 0,
9748};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009749
9750/*
9751 * configuration and preset
9752 */
Takashi Iwaiea734962011-01-17 11:29:34 +01009753static const char * const alc882_models[ALC882_MODEL_LAST] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009754 [ALC882_3ST_DIG] = "3stack-dig",
9755 [ALC882_6ST_DIG] = "6stack-dig",
9756 [ALC882_ARIMA] = "arima",
9757 [ALC882_W2JC] = "w2jc",
9758 [ALC882_TARGA] = "targa",
9759 [ALC882_ASUS_A7J] = "asus-a7j",
9760 [ALC882_ASUS_A7M] = "asus-a7m",
9761 [ALC885_MACPRO] = "macpro",
9762 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009763 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009764 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009765 [ALC885_MBP3] = "mbp3",
9766 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009767 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009768 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009769 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9770 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009771 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009772 [ALC883_TARGA_DIG] = "targa-dig",
9773 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009774 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009775 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009776 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009777 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009778 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009779 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009780 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009781 [ALC883_MEDION] = "medion",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009782 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009783 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009784 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009785 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9786 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009787 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009788 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009789 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009790 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009791 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309792 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009793 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009794 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009795 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009796 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009797 [ALC889A_INTEL] = "intel-alc889a",
9798 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009799 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009800 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c52009-06-05 00:47:26 +02009801 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009802 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009803};
9804
Takashi Iwai4953550a2009-06-30 15:28:30 +02009805static struct snd_pci_quirk alc882_cfg_tbl[] = {
9806 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9807
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009808 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009809 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009810 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009811 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9812 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009813 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009814 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9815 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009816 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009817 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009818 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9819 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009820 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9821 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009822 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9823 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009824 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009825 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009826 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009827 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009828 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9829 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009830 /* default Acer -- disabled as it causes more problems.
9831 * model=auto should work fine now
9832 */
9833 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009834
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009835 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009836
Tobin Davisfebe3372007-06-12 11:27:46 +02009837 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009838 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9839 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009840 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009841 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009842 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009843
9844 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9845 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9846 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009847 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009848 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9849 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9850 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009851 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009852 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009853 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009854 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009855
9856 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009857 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009858 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009859 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009860 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9861 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009862 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009863 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009864 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9865
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009866 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9867 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9868 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009869 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009870 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009871 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009872 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009873 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009874 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9875 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9876 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9877 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9878 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9879 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009880 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009881 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9882 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9883 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009884 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009885 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009886 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9887 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009888 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009889 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009890 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009891 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009892 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009893 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009894 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009895 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009896 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009897
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009898 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009899 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009900 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9901 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309902 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009903 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009904 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009905 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009906 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009907 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009908 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009909 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009910 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009911 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009912 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009913 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9914 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009915 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Takashi Iwai959973b2008-11-05 11:30:56 +01009916 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009917 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009918 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009919
Jiang zhe17bba1b2008-06-04 12:11:07 +02009920 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9921 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009922 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009923 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9924 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9925 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009926 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009927
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009928 {}
9929};
9930
Takashi Iwai4953550a2009-06-30 15:28:30 +02009931/* codec SSID table for Intel Mac */
9932static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9933 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9934 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9935 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9936 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9937 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9938 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9939 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009940 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009941 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009942 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009943 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009944 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9945 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9946 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009947 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009948 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +10009949 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009950 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9951 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009952 */
9953 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009954 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009955 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009956 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009957};
9958
Takashi Iwai4953550a2009-06-30 15:28:30 +02009959static struct alc_config_preset alc882_presets[] = {
9960 [ALC882_3ST_DIG] = {
9961 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009962 .init_verbs = { alc882_base_init_verbs,
9963 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009964 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9965 .dac_nids = alc882_dac_nids,
9966 .dig_out_nid = ALC882_DIGOUT_NID,
9967 .dig_in_nid = ALC882_DIGIN_NID,
9968 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9969 .channel_mode = alc882_ch_modes,
9970 .need_dac_fix = 1,
9971 .input_mux = &alc882_capture_source,
9972 },
9973 [ALC882_6ST_DIG] = {
9974 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009975 .init_verbs = { alc882_base_init_verbs,
9976 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009977 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9978 .dac_nids = alc882_dac_nids,
9979 .dig_out_nid = ALC882_DIGOUT_NID,
9980 .dig_in_nid = ALC882_DIGIN_NID,
9981 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9982 .channel_mode = alc882_sixstack_modes,
9983 .input_mux = &alc882_capture_source,
9984 },
9985 [ALC882_ARIMA] = {
9986 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009987 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9988 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009989 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9990 .dac_nids = alc882_dac_nids,
9991 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9992 .channel_mode = alc882_sixstack_modes,
9993 .input_mux = &alc882_capture_source,
9994 },
9995 [ALC882_W2JC] = {
9996 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009997 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9998 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009999 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10000 .dac_nids = alc882_dac_nids,
10001 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10002 .channel_mode = alc880_threestack_modes,
10003 .need_dac_fix = 1,
10004 .input_mux = &alc882_capture_source,
10005 .dig_out_nid = ALC882_DIGOUT_NID,
10006 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -080010007 [ALC885_MBA21] = {
10008 .mixers = { alc885_mba21_mixer },
10009 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
10010 .num_dacs = 2,
10011 .dac_nids = alc882_dac_nids,
10012 .channel_mode = alc885_mba21_ch_modes,
10013 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10014 .input_mux = &alc882_capture_source,
10015 .unsol_event = alc_automute_amp_unsol_event,
10016 .setup = alc885_mba21_setup,
10017 .init_hook = alc_automute_amp,
10018 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010019 [ALC885_MBP3] = {
10020 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
10021 .init_verbs = { alc885_mbp3_init_verbs,
10022 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010023 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010024 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010025 .hp_nid = 0x04,
10026 .channel_mode = alc885_mbp_4ch_modes,
10027 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010028 .input_mux = &alc882_capture_source,
10029 .dig_out_nid = ALC882_DIGOUT_NID,
10030 .dig_in_nid = ALC882_DIGIN_NID,
10031 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010032 .setup = alc885_mbp3_setup,
10033 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010034 },
10035 [ALC885_MB5] = {
10036 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
10037 .init_verbs = { alc885_mb5_init_verbs,
10038 alc880_gpio1_init_verbs },
10039 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10040 .dac_nids = alc882_dac_nids,
10041 .channel_mode = alc885_mb5_6ch_modes,
10042 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
10043 .input_mux = &mb5_capture_source,
10044 .dig_out_nid = ALC882_DIGOUT_NID,
10045 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010046 .unsol_event = alc_automute_amp_unsol_event,
10047 .setup = alc885_mb5_setup,
10048 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010049 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010050 [ALC885_MACMINI3] = {
10051 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
10052 .init_verbs = { alc885_macmini3_init_verbs,
10053 alc880_gpio1_init_verbs },
10054 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10055 .dac_nids = alc882_dac_nids,
10056 .channel_mode = alc885_macmini3_6ch_modes,
10057 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
10058 .input_mux = &macmini3_capture_source,
10059 .dig_out_nid = ALC882_DIGOUT_NID,
10060 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010061 .unsol_event = alc_automute_amp_unsol_event,
10062 .setup = alc885_macmini3_setup,
10063 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010064 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010065 [ALC885_MACPRO] = {
10066 .mixers = { alc882_macpro_mixer },
10067 .init_verbs = { alc882_macpro_init_verbs },
10068 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10069 .dac_nids = alc882_dac_nids,
10070 .dig_out_nid = ALC882_DIGOUT_NID,
10071 .dig_in_nid = ALC882_DIGIN_NID,
10072 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10073 .channel_mode = alc882_ch_modes,
10074 .input_mux = &alc882_capture_source,
10075 .init_hook = alc885_macpro_init_hook,
10076 },
10077 [ALC885_IMAC24] = {
10078 .mixers = { alc885_imac24_mixer },
10079 .init_verbs = { alc885_imac24_init_verbs },
10080 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10081 .dac_nids = alc882_dac_nids,
10082 .dig_out_nid = ALC882_DIGOUT_NID,
10083 .dig_in_nid = ALC882_DIGIN_NID,
10084 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10085 .channel_mode = alc882_ch_modes,
10086 .input_mux = &alc882_capture_source,
10087 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010088 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010089 .init_hook = alc885_imac24_init_hook,
10090 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010091 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010092 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010093 .init_verbs = { alc885_imac91_init_verbs,
10094 alc880_gpio1_init_verbs },
10095 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10096 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010097 .channel_mode = alc885_mba21_ch_modes,
10098 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10099 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010100 .dig_out_nid = ALC882_DIGOUT_NID,
10101 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010102 .unsol_event = alc_automute_amp_unsol_event,
10103 .setup = alc885_imac91_setup,
10104 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010105 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010106 [ALC882_TARGA] = {
10107 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010108 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +020010109 alc880_gpio3_init_verbs, alc882_targa_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 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010121 .setup = alc882_targa_setup,
10122 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010123 },
10124 [ALC882_ASUS_A7J] = {
10125 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010126 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10127 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010128 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10129 .dac_nids = alc882_dac_nids,
10130 .dig_out_nid = ALC882_DIGOUT_NID,
10131 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10132 .adc_nids = alc882_adc_nids,
10133 .capsrc_nids = alc882_capsrc_nids,
10134 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10135 .channel_mode = alc882_3ST_6ch_modes,
10136 .need_dac_fix = 1,
10137 .input_mux = &alc882_capture_source,
10138 },
10139 [ALC882_ASUS_A7M] = {
10140 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010141 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10142 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010143 alc882_asus_a7m_verbs },
10144 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10145 .dac_nids = alc882_dac_nids,
10146 .dig_out_nid = ALC882_DIGOUT_NID,
10147 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10148 .channel_mode = alc880_threestack_modes,
10149 .need_dac_fix = 1,
10150 .input_mux = &alc882_capture_source,
10151 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010152 [ALC883_3ST_2ch_DIG] = {
10153 .mixers = { alc883_3ST_2ch_mixer },
10154 .init_verbs = { alc883_init_verbs },
10155 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10156 .dac_nids = alc883_dac_nids,
10157 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010158 .dig_in_nid = ALC883_DIGIN_NID,
10159 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10160 .channel_mode = alc883_3ST_2ch_modes,
10161 .input_mux = &alc883_capture_source,
10162 },
10163 [ALC883_3ST_6ch_DIG] = {
10164 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10165 .init_verbs = { alc883_init_verbs },
10166 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10167 .dac_nids = alc883_dac_nids,
10168 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010169 .dig_in_nid = ALC883_DIGIN_NID,
10170 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10171 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010172 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010173 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010174 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010175 [ALC883_3ST_6ch] = {
10176 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10177 .init_verbs = { alc883_init_verbs },
10178 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10179 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010180 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10181 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010182 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010183 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010184 },
Jiang zhe17bba1b2008-06-04 12:11:07 +020010185 [ALC883_3ST_6ch_INTEL] = {
10186 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
10187 .init_verbs = { alc883_init_verbs },
10188 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10189 .dac_nids = alc883_dac_nids,
10190 .dig_out_nid = ALC883_DIGOUT_NID,
10191 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010192 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +020010193 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
10194 .channel_mode = alc883_3ST_6ch_intel_modes,
10195 .need_dac_fix = 1,
10196 .input_mux = &alc883_3stack_6ch_intel,
10197 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010198 [ALC889A_INTEL] = {
10199 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020010200 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
10201 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010202 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10203 .dac_nids = alc883_dac_nids,
10204 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10205 .adc_nids = alc889_adc_nids,
10206 .dig_out_nid = ALC883_DIGOUT_NID,
10207 .dig_in_nid = ALC883_DIGIN_NID,
10208 .slave_dig_outs = alc883_slave_dig_outs,
10209 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10210 .channel_mode = alc889_8ch_intel_modes,
10211 .capsrc_nids = alc889_capsrc_nids,
10212 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010213 .setup = alc889_automute_setup,
10214 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010215 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010216 .need_dac_fix = 1,
10217 },
10218 [ALC889_INTEL] = {
10219 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
10220 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010221 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010222 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10223 .dac_nids = alc883_dac_nids,
10224 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10225 .adc_nids = alc889_adc_nids,
10226 .dig_out_nid = ALC883_DIGOUT_NID,
10227 .dig_in_nid = ALC883_DIGIN_NID,
10228 .slave_dig_outs = alc883_slave_dig_outs,
10229 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10230 .channel_mode = alc889_8ch_intel_modes,
10231 .capsrc_nids = alc889_capsrc_nids,
10232 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010233 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010234 .init_hook = alc889_intel_init_hook,
10235 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010236 .need_dac_fix = 1,
10237 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010238 [ALC883_6ST_DIG] = {
10239 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10240 .init_verbs = { alc883_init_verbs },
10241 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10242 .dac_nids = alc883_dac_nids,
10243 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010244 .dig_in_nid = ALC883_DIGIN_NID,
10245 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10246 .channel_mode = alc883_sixstack_modes,
10247 .input_mux = &alc883_capture_source,
10248 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010249 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010250 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010251 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10252 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010253 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10254 .dac_nids = alc883_dac_nids,
10255 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010256 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10257 .channel_mode = alc883_3ST_6ch_modes,
10258 .need_dac_fix = 1,
10259 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010260 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010261 .setup = alc882_targa_setup,
10262 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010263 },
10264 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010265 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010266 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10267 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010268 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10269 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010270 .adc_nids = alc883_adc_nids_alt,
10271 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010272 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010273 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010274 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10275 .channel_mode = alc883_3ST_2ch_modes,
10276 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010277 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010278 .setup = alc882_targa_setup,
10279 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010280 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010281 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010282 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10283 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010284 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010285 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010286 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10287 .dac_nids = alc883_dac_nids,
10288 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10289 .adc_nids = alc883_adc_nids_rev,
10290 .capsrc_nids = alc883_capsrc_nids_rev,
10291 .dig_out_nid = ALC883_DIGOUT_NID,
10292 .dig_in_nid = ALC883_DIGIN_NID,
10293 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10294 .channel_mode = alc883_4ST_8ch_modes,
10295 .need_dac_fix = 1,
10296 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010297 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010298 .setup = alc882_targa_setup,
10299 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010300 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010301 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010302 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010303 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10304 * and the headphone jack. Turn this on and rely on the
10305 * standard mute methods whenever the user wants to turn
10306 * these outputs off.
10307 */
10308 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10309 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10310 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010311 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10312 .channel_mode = alc883_3ST_2ch_modes,
10313 .input_mux = &alc883_capture_source,
10314 },
Tobin Davis2880a862007-08-07 11:50:26 +020010315 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010316 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010317 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010318 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10319 .dac_nids = alc883_dac_nids,
10320 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010321 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10322 .channel_mode = alc883_3ST_2ch_modes,
10323 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010324 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010325 .setup = alc883_acer_aspire_setup,
10326 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010327 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010328 [ALC888_ACER_ASPIRE_4930G] = {
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +010010329 .mixers = { alc888_acer_aspire_4930g_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010330 alc883_chmode_mixer },
10331 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10332 alc888_acer_aspire_4930g_verbs },
10333 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10334 .dac_nids = alc883_dac_nids,
10335 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10336 .adc_nids = alc883_adc_nids_rev,
10337 .capsrc_nids = alc883_capsrc_nids_rev,
10338 .dig_out_nid = ALC883_DIGOUT_NID,
10339 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10340 .channel_mode = alc883_3ST_6ch_modes,
10341 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010342 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010343 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010344 ARRAY_SIZE(alc888_2_capture_sources),
10345 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010346 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010347 .setup = alc888_acer_aspire_4930g_setup,
10348 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010349 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010350 [ALC888_ACER_ASPIRE_6530G] = {
10351 .mixers = { alc888_acer_aspire_6530_mixer },
10352 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10353 alc888_acer_aspire_6530g_verbs },
10354 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10355 .dac_nids = alc883_dac_nids,
10356 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10357 .adc_nids = alc883_adc_nids_rev,
10358 .capsrc_nids = alc883_capsrc_nids_rev,
10359 .dig_out_nid = ALC883_DIGOUT_NID,
10360 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10361 .channel_mode = alc883_3ST_2ch_modes,
10362 .num_mux_defs =
10363 ARRAY_SIZE(alc888_2_capture_sources),
10364 .input_mux = alc888_acer_aspire_6530_sources,
10365 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010366 .setup = alc888_acer_aspire_6530g_setup,
10367 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010368 },
Hector Martin3b315d72009-06-02 10:54:19 +020010369 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010370 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010371 alc883_chmode_mixer },
10372 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010373 alc889_acer_aspire_8930g_verbs,
10374 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010375 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10376 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010377 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10378 .adc_nids = alc889_adc_nids,
10379 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010380 .dig_out_nid = ALC883_DIGOUT_NID,
10381 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10382 .channel_mode = alc883_3ST_6ch_modes,
10383 .need_dac_fix = 1,
10384 .const_channel_count = 6,
10385 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010386 ARRAY_SIZE(alc889_capture_sources),
10387 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +020010388 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010389 .setup = alc889_acer_aspire_8930g_setup,
10390 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +010010391#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010392 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010393#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010394 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010395 [ALC888_ACER_ASPIRE_7730G] = {
10396 .mixers = { alc883_3ST_6ch_mixer,
10397 alc883_chmode_mixer },
10398 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10399 alc888_acer_aspire_7730G_verbs },
10400 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10401 .dac_nids = alc883_dac_nids,
10402 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10403 .adc_nids = alc883_adc_nids_rev,
10404 .capsrc_nids = alc883_capsrc_nids_rev,
10405 .dig_out_nid = ALC883_DIGOUT_NID,
10406 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10407 .channel_mode = alc883_3ST_6ch_modes,
10408 .need_dac_fix = 1,
10409 .const_channel_count = 6,
10410 .input_mux = &alc883_capture_source,
10411 .unsol_event = alc_automute_amp_unsol_event,
Denis Kuplyakovd9477202010-11-24 06:01:09 +010010412 .setup = alc888_acer_aspire_7730g_setup,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010413 .init_hook = alc_automute_amp,
10414 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010415 [ALC883_MEDION] = {
10416 .mixers = { alc883_fivestack_mixer,
10417 alc883_chmode_mixer },
10418 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010419 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010420 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10421 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010422 .adc_nids = alc883_adc_nids_alt,
10423 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010424 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010425 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10426 .channel_mode = alc883_sixstack_modes,
10427 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010428 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010429 [ALC883_MEDION_WIM2160] = {
10430 .mixers = { alc883_medion_wim2160_mixer },
10431 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10432 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10433 .dac_nids = alc883_dac_nids,
10434 .dig_out_nid = ALC883_DIGOUT_NID,
10435 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10436 .adc_nids = alc883_adc_nids,
10437 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10438 .channel_mode = alc883_3ST_2ch_modes,
10439 .input_mux = &alc883_capture_source,
10440 .unsol_event = alc_automute_amp_unsol_event,
10441 .setup = alc883_medion_wim2160_setup,
10442 .init_hook = alc_automute_amp,
10443 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010444 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010445 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010446 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10447 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10448 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010449 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10450 .channel_mode = alc883_3ST_2ch_modes,
10451 .input_mux = &alc883_capture_source,
10452 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010453 [ALC883_CLEVO_M540R] = {
10454 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10455 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10456 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10457 .dac_nids = alc883_dac_nids,
10458 .dig_out_nid = ALC883_DIGOUT_NID,
10459 .dig_in_nid = ALC883_DIGIN_NID,
10460 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10461 .channel_mode = alc883_3ST_6ch_clevo_modes,
10462 .need_dac_fix = 1,
10463 .input_mux = &alc883_capture_source,
10464 /* This machine has the hardware HP auto-muting, thus
10465 * we need no software mute via unsol event
10466 */
10467 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010468 [ALC883_CLEVO_M720] = {
10469 .mixers = { alc883_clevo_m720_mixer },
10470 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010471 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10472 .dac_nids = alc883_dac_nids,
10473 .dig_out_nid = ALC883_DIGOUT_NID,
10474 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10475 .channel_mode = alc883_3ST_2ch_modes,
10476 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010477 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010478 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010479 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010480 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010481 [ALC883_LENOVO_101E_2ch] = {
10482 .mixers = { alc883_lenovo_101e_2ch_mixer},
10483 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10484 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10485 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010486 .adc_nids = alc883_adc_nids_alt,
10487 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010488 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010489 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10490 .channel_mode = alc883_3ST_2ch_modes,
10491 .input_mux = &alc883_lenovo_101e_capture_source,
10492 .unsol_event = alc883_lenovo_101e_unsol_event,
10493 .init_hook = alc883_lenovo_101e_all_automute,
10494 },
Kailang Yang272a5272007-05-14 11:00:38 +020010495 [ALC883_LENOVO_NB0763] = {
10496 .mixers = { alc883_lenovo_nb0763_mixer },
10497 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10498 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10499 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010500 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10501 .channel_mode = alc883_3ST_2ch_modes,
10502 .need_dac_fix = 1,
10503 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010504 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwaidc4271702010-11-29 07:42:59 +010010505 .setup = alc883_lenovo_nb0763_setup,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010506 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010507 },
10508 [ALC888_LENOVO_MS7195_DIG] = {
10509 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10510 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10511 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10512 .dac_nids = alc883_dac_nids,
10513 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010514 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10515 .channel_mode = alc883_3ST_6ch_modes,
10516 .need_dac_fix = 1,
10517 .input_mux = &alc883_capture_source,
10518 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10519 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010520 },
10521 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010522 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010523 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10524 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10525 .dac_nids = alc883_dac_nids,
10526 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010527 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10528 .channel_mode = alc883_3ST_2ch_modes,
10529 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010530 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010531 .setup = alc883_haier_w66_setup,
10532 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010533 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010534 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010535 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010536 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010537 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10538 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010539 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10540 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010541 .need_dac_fix = 1,
10542 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010543 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010544 .setup = alc888_3st_hp_setup,
10545 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010546 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010547 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010548 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010549 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10550 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10551 .dac_nids = alc883_dac_nids,
10552 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010553 .dig_in_nid = ALC883_DIGIN_NID,
10554 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10555 .channel_mode = alc883_sixstack_modes,
10556 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010557 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010558 .setup = alc888_6st_dell_setup,
10559 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010560 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010561 [ALC883_MITAC] = {
10562 .mixers = { alc883_mitac_mixer },
10563 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10564 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10565 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010566 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10567 .channel_mode = alc883_3ST_2ch_modes,
10568 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010569 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010570 .setup = alc883_mitac_setup,
10571 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010572 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010573 [ALC883_FUJITSU_PI2515] = {
10574 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10575 .init_verbs = { alc883_init_verbs,
10576 alc883_2ch_fujitsu_pi2515_verbs},
10577 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10578 .dac_nids = alc883_dac_nids,
10579 .dig_out_nid = ALC883_DIGOUT_NID,
10580 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10581 .channel_mode = alc883_3ST_2ch_modes,
10582 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010583 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010584 .setup = alc883_2ch_fujitsu_pi2515_setup,
10585 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010586 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010587 [ALC888_FUJITSU_XA3530] = {
10588 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10589 .init_verbs = { alc883_init_verbs,
10590 alc888_fujitsu_xa3530_verbs },
10591 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10592 .dac_nids = alc883_dac_nids,
10593 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10594 .adc_nids = alc883_adc_nids_rev,
10595 .capsrc_nids = alc883_capsrc_nids_rev,
10596 .dig_out_nid = ALC883_DIGOUT_NID,
10597 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10598 .channel_mode = alc888_4ST_8ch_intel_modes,
10599 .num_mux_defs =
10600 ARRAY_SIZE(alc888_2_capture_sources),
10601 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010602 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010603 .setup = alc888_fujitsu_xa3530_setup,
10604 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010605 },
Kailang Yange2757d52008-08-26 13:17:46 +020010606 [ALC888_LENOVO_SKY] = {
10607 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10608 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10609 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10610 .dac_nids = alc883_dac_nids,
10611 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010612 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10613 .channel_mode = alc883_sixstack_modes,
10614 .need_dac_fix = 1,
10615 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010616 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010617 .setup = alc888_lenovo_sky_setup,
10618 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010619 },
10620 [ALC888_ASUS_M90V] = {
10621 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10622 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10623 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10624 .dac_nids = alc883_dac_nids,
10625 .dig_out_nid = ALC883_DIGOUT_NID,
10626 .dig_in_nid = ALC883_DIGIN_NID,
10627 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10628 .channel_mode = alc883_3ST_6ch_modes,
10629 .need_dac_fix = 1,
10630 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010631 .unsol_event = alc_sku_unsol_event,
10632 .setup = alc883_mode2_setup,
10633 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010634 },
10635 [ALC888_ASUS_EEE1601] = {
10636 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010637 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010638 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10639 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10640 .dac_nids = alc883_dac_nids,
10641 .dig_out_nid = ALC883_DIGOUT_NID,
10642 .dig_in_nid = ALC883_DIGIN_NID,
10643 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10644 .channel_mode = alc883_3ST_2ch_modes,
10645 .need_dac_fix = 1,
10646 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010647 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010648 .init_hook = alc883_eee1601_inithook,
10649 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010650 [ALC1200_ASUS_P5Q] = {
10651 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10652 .init_verbs = { alc883_init_verbs },
10653 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10654 .dac_nids = alc883_dac_nids,
10655 .dig_out_nid = ALC1200_DIGOUT_NID,
10656 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010657 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010658 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10659 .channel_mode = alc883_sixstack_modes,
10660 .input_mux = &alc883_capture_source,
10661 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010662 [ALC889A_MB31] = {
10663 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10664 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10665 alc880_gpio1_init_verbs },
10666 .adc_nids = alc883_adc_nids,
10667 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010668 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010669 .dac_nids = alc883_dac_nids,
10670 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10671 .channel_mode = alc889A_mb31_6ch_modes,
10672 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10673 .input_mux = &alc889A_mb31_capture_source,
10674 .dig_out_nid = ALC883_DIGOUT_NID,
10675 .unsol_event = alc889A_mb31_unsol_event,
10676 .init_hook = alc889A_mb31_automute,
10677 },
Guido Günther3e1647c52009-06-05 00:47:26 +020010678 [ALC883_SONY_VAIO_TT] = {
10679 .mixers = { alc883_vaiott_mixer },
10680 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10681 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10682 .dac_nids = alc883_dac_nids,
10683 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10684 .channel_mode = alc883_3ST_2ch_modes,
10685 .input_mux = &alc883_capture_source,
10686 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010687 .setup = alc883_vaiott_setup,
10688 .init_hook = alc_automute_amp,
Guido Günther3e1647c52009-06-05 00:47:26 +020010689 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010690};
10691
10692
10693/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010694 * Pin config fixes
10695 */
10696enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010697 PINFIX_ABIT_AW9D_MAX,
David Henningsson32eea382011-03-04 13:37:50 +010010698 PINFIX_LENOVO_Y530,
Takashi Iwai954a29c2010-07-30 10:55:44 +020010699 PINFIX_PB_M5210,
David Henningssonc3d226a2010-10-14 15:42:08 +020010700 PINFIX_ACER_ASPIRE_7736,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010701};
10702
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010703static const struct alc_fixup alc882_fixups[] = {
10704 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010705 .type = ALC_FIXUP_PINS,
10706 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020010707 { 0x15, 0x01080104 }, /* side */
10708 { 0x16, 0x01011012 }, /* rear */
10709 { 0x17, 0x01016011 }, /* clfe */
10710 { }
10711 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010712 },
David Henningsson32eea382011-03-04 13:37:50 +010010713 [PINFIX_LENOVO_Y530] = {
10714 .type = ALC_FIXUP_PINS,
10715 .v.pins = (const struct alc_pincfg[]) {
10716 { 0x15, 0x99130112 }, /* rear int speakers */
10717 { 0x16, 0x99130111 }, /* subwoofer */
10718 { }
10719 }
10720 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010721 [PINFIX_PB_M5210] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010722 .type = ALC_FIXUP_VERBS,
10723 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020010724 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10725 {}
10726 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020010727 },
David Henningssonc3d226a2010-10-14 15:42:08 +020010728 [PINFIX_ACER_ASPIRE_7736] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010729 .type = ALC_FIXUP_SKU,
10730 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonc3d226a2010-10-14 15:42:08 +020010731 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010732};
10733
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010734static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010735 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
David Henningsson32eea382011-03-04 13:37:50 +010010736 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", PINFIX_LENOVO_Y530),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010737 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
David Henningssonc3d226a2010-10-14 15:42:08 +020010738 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010739 {}
10740};
10741
10742/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010743 * BIOS auto configuration
10744 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010745static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10746 const struct auto_pin_cfg *cfg)
10747{
10748 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10749}
10750
Takashi Iwai4953550a2009-06-30 15:28:30 +020010751static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010752 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010753 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010754{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010755 int idx;
10756
Takashi Iwai489008c2010-04-07 09:06:00 +020010757 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010758 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010759
Takashi Iwai489008c2010-04-07 09:06:00 +020010760 if (dac == 0x25)
10761 idx = 4;
10762 else if (dac >= 0x02 && dac <= 0x05)
10763 idx = dac - 2;
10764 else
10765 return;
10766 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010767}
10768
Takashi Iwai4953550a2009-06-30 15:28:30 +020010769static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010770{
10771 struct alc_spec *spec = codec->spec;
10772 int i;
10773
10774 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010775 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010776 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010777 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010778 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010779 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010780 }
10781}
10782
Takashi Iwai4953550a2009-06-30 15:28:30 +020010783static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010784{
10785 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010786 hda_nid_t pin, dac;
Takashi Iwai5855fb82010-09-16 18:24:02 +020010787 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010788
David Henningsson0a3fabe2011-03-04 16:54:52 +010010789 if (spec->autocfg.line_out_type != AUTO_PIN_HP_OUT) {
10790 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
10791 pin = spec->autocfg.hp_pins[i];
10792 if (!pin)
10793 break;
10794 dac = spec->multiout.hp_nid;
10795 if (!dac)
10796 dac = spec->multiout.dac_nids[0]; /* to front */
10797 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10798 }
Takashi Iwai489008c2010-04-07 09:06:00 +020010799 }
David Henningsson0a3fabe2011-03-04 16:54:52 +010010800
10801 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT) {
10802 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
10803 pin = spec->autocfg.speaker_pins[i];
10804 if (!pin)
10805 break;
10806 dac = spec->multiout.extra_out_nid[0];
10807 if (!dac)
10808 dac = spec->multiout.dac_nids[0]; /* to front */
10809 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10810 }
Takashi Iwai489008c2010-04-07 09:06:00 +020010811 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010812}
10813
Takashi Iwai4953550a2009-06-30 15:28:30 +020010814static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010815{
10816 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010817 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010818 int i;
10819
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010820 for (i = 0; i < cfg->num_inputs; i++) {
10821 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai30ea0982010-09-16 18:47:56 +020010822 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010823 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10824 snd_hda_codec_write(codec, nid, 0,
10825 AC_VERB_SET_AMP_GAIN_MUTE,
10826 AMP_OUT_MUTE);
10827 }
10828}
10829
10830static void alc882_auto_init_input_src(struct hda_codec *codec)
10831{
10832 struct alc_spec *spec = codec->spec;
10833 int c;
10834
10835 for (c = 0; c < spec->num_adc_nids; c++) {
10836 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10837 hda_nid_t nid = spec->capsrc_nids[c];
10838 unsigned int mux_idx;
10839 const struct hda_input_mux *imux;
10840 int conns, mute, idx, item;
10841
10842 conns = snd_hda_get_connections(codec, nid, conn_list,
10843 ARRAY_SIZE(conn_list));
10844 if (conns < 0)
10845 continue;
10846 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10847 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010848 if (!imux->num_items && mux_idx > 0)
10849 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010850 for (idx = 0; idx < conns; idx++) {
10851 /* if the current connection is the selected one,
10852 * unmute it as default - otherwise mute it
10853 */
10854 mute = AMP_IN_MUTE(idx);
10855 for (item = 0; item < imux->num_items; item++) {
10856 if (imux->items[item].index == idx) {
10857 if (spec->cur_mux[c] == item)
10858 mute = AMP_IN_UNMUTE(idx);
10859 break;
10860 }
10861 }
10862 /* check if we have a selector or mixer
10863 * we could check for the widget type instead, but
10864 * just check for Amp-In presence (in case of mixer
10865 * without amp-in there is something wrong, this
10866 * function shouldn't be used or capsrc nid is wrong)
10867 */
10868 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010869 snd_hda_codec_write(codec, nid, 0,
10870 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010871 mute);
10872 else if (mute != AMP_IN_MUTE(idx))
10873 snd_hda_codec_write(codec, nid, 0,
10874 AC_VERB_SET_CONNECT_SEL,
10875 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010876 }
10877 }
10878}
10879
Takashi Iwai4953550a2009-06-30 15:28:30 +020010880/* add mic boosts if needed */
10881static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010882{
10883 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010884 struct auto_pin_cfg *cfg = &spec->autocfg;
David Henningsson5322bf22011-01-05 11:03:56 +010010885 int i, err;
Takashi Iwai53e8c322010-12-17 15:23:41 +010010886 int type_idx = 0;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010887 hda_nid_t nid;
David Henningsson5322bf22011-01-05 11:03:56 +010010888 const char *prev_label = NULL;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010889
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010890 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020010891 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010892 break;
10893 nid = cfg->inputs[i].pin;
10894 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
David Henningsson5322bf22011-01-05 11:03:56 +010010895 const char *label;
10896 char boost_label[32];
10897
10898 label = hda_get_autocfg_input_label(codec, cfg, i);
10899 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai53e8c322010-12-17 15:23:41 +010010900 type_idx++;
10901 else
10902 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +010010903 prev_label = label;
10904
10905 snprintf(boost_label, sizeof(boost_label),
10906 "%s Boost Volume", label);
10907 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10908 boost_label, type_idx,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010909 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010910 if (err < 0)
10911 return err;
10912 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010913 }
10914 return 0;
10915}
10916
10917/* almost identical with ALC880 parser... */
10918static int alc882_parse_auto_config(struct hda_codec *codec)
10919{
10920 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010921 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020010922 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010923
Takashi Iwai05f5f472009-08-25 13:10:18 +020010924 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10925 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010926 if (err < 0)
10927 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010928 if (!spec->autocfg.line_outs)
10929 return 0; /* can't find valid BIOS pin config */
10930
10931 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10932 if (err < 0)
10933 return err;
Takashi Iwai569ed342011-01-19 10:14:46 +010010934 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010935 if (err < 0)
10936 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010937 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10938 "Headphone");
10939 if (err < 0)
10940 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010941 err = alc880_auto_create_extra_out(spec,
10942 spec->autocfg.speaker_pins[0],
10943 "Speaker");
10944 if (err < 0)
10945 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010946 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10947 if (err < 0)
10948 return err;
10949
10950 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10951
Takashi Iwai757899a2010-07-30 10:48:14 +020010952 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010953
10954 if (spec->kctls.list)
10955 add_mixer(spec, spec->kctls.list);
10956
10957 add_verb(spec, alc883_auto_init_verbs);
10958 /* if ADC 0x07 is available, initialize it, too */
10959 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10960 add_verb(spec, alc882_adc1_init_verbs);
10961
10962 spec->num_mux_defs = 1;
10963 spec->input_mux = &spec->private_imux[0];
10964
Kailang Yang6227cdc2010-02-25 08:36:52 +010010965 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010966
10967 err = alc_auto_add_mic_boost(codec);
10968 if (err < 0)
10969 return err;
10970
Takashi Iwai776e1842007-08-29 15:07:11 +020010971 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010972}
10973
10974/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010975static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010976{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010977 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010978 alc882_auto_init_multi_out(codec);
10979 alc882_auto_init_hp_out(codec);
10980 alc882_auto_init_analog_input(codec);
10981 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020010982 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010983 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010984 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010985}
10986
Takashi Iwai4953550a2009-06-30 15:28:30 +020010987static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010988{
10989 struct alc_spec *spec;
10990 int err, board_config;
10991
10992 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10993 if (spec == NULL)
10994 return -ENOMEM;
10995
10996 codec->spec = spec;
10997
Takashi Iwai4953550a2009-06-30 15:28:30 +020010998 switch (codec->vendor_id) {
10999 case 0x10ec0882:
11000 case 0x10ec0885:
11001 break;
11002 default:
11003 /* ALC883 and variants */
11004 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11005 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011006 }
11007
Takashi Iwai4953550a2009-06-30 15:28:30 +020011008 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
11009 alc882_models,
11010 alc882_cfg_tbl);
11011
11012 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
11013 board_config = snd_hda_check_board_codec_sid_config(codec,
11014 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
11015
11016 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011017 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020011018 codec->chip_name);
11019 board_config = ALC882_AUTO;
11020 }
11021
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011022 if (board_config == ALC882_AUTO) {
11023 alc_pick_fixup(codec, NULL, alc882_fixup_tbl, alc882_fixups);
11024 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
11025 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011026
David Henningsson90622912010-10-14 14:50:18 +020011027 alc_auto_parse_customize_define(codec);
11028
Takashi Iwai4953550a2009-06-30 15:28:30 +020011029 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011030 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020011031 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011032 if (err < 0) {
11033 alc_free(codec);
11034 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011035 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011036 printk(KERN_INFO
11037 "hda_codec: Cannot set up configuration "
11038 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020011039 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011040 }
11041 }
11042
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011043 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020011044 err = snd_hda_attach_beep_device(codec, 0x1);
11045 if (err < 0) {
11046 alc_free(codec);
11047 return err;
11048 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011049 }
11050
Takashi Iwai4953550a2009-06-30 15:28:30 +020011051 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011052 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011053
Takashi Iwai4953550a2009-06-30 15:28:30 +020011054 spec->stream_analog_playback = &alc882_pcm_analog_playback;
11055 spec->stream_analog_capture = &alc882_pcm_analog_capture;
11056 /* FIXME: setup DAC5 */
11057 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
11058 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
11059
11060 spec->stream_digital_playback = &alc882_pcm_digital_playback;
11061 spec->stream_digital_capture = &alc882_pcm_digital_capture;
11062
Takashi Iwai4953550a2009-06-30 15:28:30 +020011063 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011064 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011065 spec->num_adc_nids = 0;
11066 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011067 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011068 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011069 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020011070 hda_nid_t nid = alc882_adc_nids[i];
11071 unsigned int wcap = get_wcaps(codec, nid);
11072 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011073 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020011074 if (wcap != AC_WID_AUD_IN)
11075 continue;
11076 spec->private_adc_nids[spec->num_adc_nids] = nid;
11077 err = snd_hda_get_connections(codec, nid, &cap, 1);
11078 if (err < 0)
11079 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011080 err = snd_hda_get_connections(codec, cap, items,
11081 ARRAY_SIZE(items));
11082 if (err < 0)
11083 continue;
11084 for (j = 0; j < imux->num_items; j++)
11085 if (imux->items[j].index >= err)
11086 break;
11087 if (j < imux->num_items)
11088 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011089 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
11090 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011091 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011092 spec->adc_nids = spec->private_adc_nids;
11093 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020011094 }
11095
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011096 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010011097
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011098 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010011099 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011100
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011101 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020011102
Takashi Iwai2134ea42008-01-10 16:53:55 +010011103 spec->vmaster_nid = 0x0c;
11104
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011105 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011106 if (board_config == ALC882_AUTO)
11107 spec->init_hook = alc882_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020011108
11109 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020011110#ifdef CONFIG_SND_HDA_POWER_SAVE
11111 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020011112 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011113#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011114
11115 return 0;
11116}
11117
Takashi Iwai4953550a2009-06-30 15:28:30 +020011118
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011119/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011120 * ALC262 support
11121 */
11122
11123#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
11124#define ALC262_DIGIN_NID ALC880_DIGIN_NID
11125
11126#define alc262_dac_nids alc260_dac_nids
11127#define alc262_adc_nids alc882_adc_nids
11128#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010011129#define alc262_capsrc_nids alc882_capsrc_nids
11130#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010011131
11132#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010011133#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010011134
Kailang Yang4e555fe2008-08-26 13:05:55 +020011135static hda_nid_t alc262_dmic_adc_nids[1] = {
11136 /* ADC0 */
11137 0x09
11138};
11139
11140static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
11141
Kailang Yangdf694da2005-12-05 19:42:22 +010011142static struct snd_kcontrol_new alc262_base_mixer[] = {
11143 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11144 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11145 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11146 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11147 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11148 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11149 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11150 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011151 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011152 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11153 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011154 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011155 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
11156 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11157 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
11158 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011159 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010011160};
11161
Takashi Iwaice875f02008-01-28 18:17:43 +010011162/* update HP, line and mono-out pins according to the master switch */
11163static void alc262_hp_master_update(struct hda_codec *codec)
11164{
11165 struct alc_spec *spec = codec->spec;
11166 int val = spec->master_sw;
11167
11168 /* HP & line-out */
11169 snd_hda_codec_write_cache(codec, 0x1b, 0,
11170 AC_VERB_SET_PIN_WIDGET_CONTROL,
11171 val ? PIN_HP : 0);
11172 snd_hda_codec_write_cache(codec, 0x15, 0,
11173 AC_VERB_SET_PIN_WIDGET_CONTROL,
11174 val ? PIN_HP : 0);
11175 /* mono (speaker) depending on the HP jack sense */
11176 val = val && !spec->jack_present;
11177 snd_hda_codec_write_cache(codec, 0x16, 0,
11178 AC_VERB_SET_PIN_WIDGET_CONTROL,
11179 val ? PIN_OUT : 0);
11180}
11181
11182static void alc262_hp_bpc_automute(struct hda_codec *codec)
11183{
11184 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011185
11186 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010011187 alc262_hp_master_update(codec);
11188}
11189
11190static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
11191{
11192 if ((res >> 26) != ALC880_HP_EVENT)
11193 return;
11194 alc262_hp_bpc_automute(codec);
11195}
11196
11197static void alc262_hp_wildwest_automute(struct hda_codec *codec)
11198{
11199 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011200
11201 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010011202 alc262_hp_master_update(codec);
11203}
11204
11205static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
11206 unsigned int res)
11207{
11208 if ((res >> 26) != ALC880_HP_EVENT)
11209 return;
11210 alc262_hp_wildwest_automute(codec);
11211}
11212
Takashi Iwaib72519b2009-05-08 14:31:55 +020011213#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010011214
11215static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
11216 struct snd_ctl_elem_value *ucontrol)
11217{
11218 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11219 struct alc_spec *spec = codec->spec;
11220 int val = !!*ucontrol->value.integer.value;
11221
11222 if (val == spec->master_sw)
11223 return 0;
11224 spec->master_sw = val;
11225 alc262_hp_master_update(codec);
11226 return 1;
11227}
11228
Takashi Iwaib72519b2009-05-08 14:31:55 +020011229#define ALC262_HP_MASTER_SWITCH \
11230 { \
11231 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11232 .name = "Master Playback Switch", \
11233 .info = snd_ctl_boolean_mono_info, \
11234 .get = alc262_hp_master_sw_get, \
11235 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011236 }, \
11237 { \
11238 .iface = NID_MAPPING, \
11239 .name = "Master Playback Switch", \
11240 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020011241 }
11242
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011243
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011244static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011245 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011246 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11247 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11248 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011249 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11250 HDA_OUTPUT),
11251 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11252 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011253 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11254 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011255 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011256 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11257 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011258 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011259 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11260 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11261 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11262 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011263 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
11264 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
11265 { } /* end */
11266};
11267
Kailang Yangcd7509a2007-01-26 18:33:17 +010011268static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011269 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010011270 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11271 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11272 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11273 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011274 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11275 HDA_OUTPUT),
11276 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11277 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011278 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11279 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011280 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011281 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11282 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11283 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11284 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011285 { } /* end */
11286};
11287
11288static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11289 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11290 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011291 HDA_CODEC_VOLUME("Rear Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011292 { } /* end */
11293};
11294
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011295/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011296static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011297{
11298 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011299
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011300 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011301 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011302}
11303
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011304static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011305 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11306 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011307 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11308 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11309 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11310 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011311 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011312 { } /* end */
11313};
11314
11315static struct hda_verb alc262_hp_t5735_verbs[] = {
11316 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11317 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11318
11319 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11320 { }
11321};
11322
Kailang Yang8c427222008-01-10 13:03:59 +010011323static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011324 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11325 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011326 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11327 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011328 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11329 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11330 { } /* end */
11331};
11332
11333static struct hda_verb alc262_hp_rp5700_verbs[] = {
11334 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11335 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11336 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11337 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11338 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11339 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11340 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11341 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11342 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11343 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11344 {}
11345};
11346
11347static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11348 .num_items = 1,
11349 .items = {
11350 { "Line", 0x1 },
11351 },
11352};
11353
Takashi Iwai42171c12009-05-08 14:11:43 +020011354/* bind hp and internal speaker mute (with plug check) as master switch */
11355static void alc262_hippo_master_update(struct hda_codec *codec)
11356{
11357 struct alc_spec *spec = codec->spec;
11358 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11359 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11360 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11361 unsigned int mute;
11362
11363 /* HP */
11364 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11365 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11366 HDA_AMP_MUTE, mute);
11367 /* mute internal speaker per jack sense */
11368 if (spec->jack_present)
11369 mute = HDA_AMP_MUTE;
11370 if (line_nid)
11371 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11372 HDA_AMP_MUTE, mute);
11373 if (speaker_nid && speaker_nid != line_nid)
11374 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11375 HDA_AMP_MUTE, mute);
11376}
11377
11378#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
11379
11380static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11381 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020011382{
11383 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020011384 struct alc_spec *spec = codec->spec;
11385 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011386
Takashi Iwai42171c12009-05-08 14:11:43 +020011387 if (val == spec->master_sw)
11388 return 0;
11389 spec->master_sw = val;
11390 alc262_hippo_master_update(codec);
11391 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011392}
Takashi Iwai5b319542007-07-26 11:49:22 +020011393
Takashi Iwai42171c12009-05-08 14:11:43 +020011394#define ALC262_HIPPO_MASTER_SWITCH \
11395 { \
11396 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11397 .name = "Master Playback Switch", \
11398 .info = snd_ctl_boolean_mono_info, \
11399 .get = alc262_hippo_master_sw_get, \
11400 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011401 }, \
11402 { \
11403 .iface = NID_MAPPING, \
11404 .name = "Master Playback Switch", \
11405 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11406 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011407 }
11408
11409static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11410 ALC262_HIPPO_MASTER_SWITCH,
11411 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11412 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11413 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11414 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11415 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11416 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11417 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011418 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011419 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11420 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011421 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011422 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11423 { } /* end */
11424};
11425
11426static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11427 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11428 ALC262_HIPPO_MASTER_SWITCH,
11429 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11430 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11431 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11432 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11433 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11434 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011435 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011436 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11437 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011438 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011439 { } /* end */
11440};
11441
11442/* mute/unmute internal speaker according to the hp jack and mute state */
11443static void alc262_hippo_automute(struct hda_codec *codec)
11444{
11445 struct alc_spec *spec = codec->spec;
11446 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020011447
Wu Fengguang864f92b2009-11-18 12:38:02 +080011448 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020011449 alc262_hippo_master_update(codec);
11450}
11451
11452static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11453{
11454 if ((res >> 26) != ALC880_HP_EVENT)
11455 return;
11456 alc262_hippo_automute(codec);
11457}
11458
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011459static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011460{
11461 struct alc_spec *spec = codec->spec;
11462
11463 spec->autocfg.hp_pins[0] = 0x15;
11464 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011465}
11466
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011467static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011468{
11469 struct alc_spec *spec = codec->spec;
11470
11471 spec->autocfg.hp_pins[0] = 0x1b;
11472 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011473}
11474
11475
Kailang Yang272a5272007-05-14 11:00:38 +020011476static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011477 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011478 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011479 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11480 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11481 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11482 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11483 { } /* end */
11484};
11485
Kailang Yang83c34212007-07-05 11:43:05 +020011486static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011487 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11488 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011489 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11490 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11491 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11492 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11493 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11494 { } /* end */
11495};
Kailang Yang272a5272007-05-14 11:00:38 +020011496
Tony Vroonba340e82009-02-02 19:01:30 +000011497static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11498 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11499 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11500 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11501 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11502 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11503 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11504 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11505 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011506 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011507 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11508 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011509 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011510 { } /* end */
11511};
11512
11513static struct hda_verb alc262_tyan_verbs[] = {
11514 /* Headphone automute */
11515 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11516 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11517 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11518
11519 /* P11 AUX_IN, white 4-pin connector */
11520 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11521 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11522 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11523 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11524
11525 {}
11526};
11527
11528/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011529static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011530{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011531 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011532
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011533 spec->autocfg.hp_pins[0] = 0x1b;
11534 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011535}
11536
Tony Vroonba340e82009-02-02 19:01:30 +000011537
Kailang Yangdf694da2005-12-05 19:42:22 +010011538#define alc262_capture_mixer alc882_capture_mixer
11539#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11540
11541/*
11542 * generic initialization of ADC, input mixers and output mixers
11543 */
11544static struct hda_verb alc262_init_verbs[] = {
11545 /*
11546 * Unmute ADC0-2 and set the default input to mic-in
11547 */
11548 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11549 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11550 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11551 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11552 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11553 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11554
Takashi Iwaicb53c622007-08-10 17:21:45 +020011555 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011556 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011557 * Note: PASD motherboards uses the Line In 2 as the input for
11558 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011559 */
11560 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011561 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11562 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11563 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11564 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11565 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011566
11567 /*
11568 * Set up output mixers (0x0c - 0x0e)
11569 */
11570 /* set vol=0 to output mixers */
11571 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11572 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11573 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11574 /* set up input amps for analog loopback */
11575 /* Amp Indices: DAC = 0, mixer = 1 */
11576 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11577 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11578 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11579 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11580 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11581 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11582
11583 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11584 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11585 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11586 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11587 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11588 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11589
11590 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11591 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11592 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11593 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11594 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011595
Kailang Yangdf694da2005-12-05 19:42:22 +010011596 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11597 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011598
Kailang Yangdf694da2005-12-05 19:42:22 +010011599 /* FIXME: use matrix-type input source selection */
11600 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11601 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11602 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11603 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11604 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11605 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11606 /* Input mixer2 */
11607 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11608 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11609 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11610 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11611 /* Input mixer3 */
11612 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11613 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11614 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011615 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011616
11617 { }
11618};
11619
Kailang Yang4e555fe2008-08-26 13:05:55 +020011620static struct hda_verb alc262_eapd_verbs[] = {
11621 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11622 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11623 { }
11624};
11625
Kailang Yangccc656c2006-10-17 12:32:26 +020011626static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11627 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11628 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11629 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11630
11631 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11632 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11633 {}
11634};
11635
Kailang Yang272a5272007-05-14 11:00:38 +020011636static struct hda_verb alc262_sony_unsol_verbs[] = {
11637 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11638 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11639 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11640
11641 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11642 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011643 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011644};
11645
Kailang Yang4e555fe2008-08-26 13:05:55 +020011646static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11647 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11648 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11649 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11650 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11651 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011652 { } /* end */
11653};
11654
11655static struct hda_verb alc262_toshiba_s06_verbs[] = {
11656 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11657 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11658 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11659 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11660 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11661 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11662 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11663 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11664 {}
11665};
11666
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011667static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011668{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011669 struct alc_spec *spec = codec->spec;
11670
11671 spec->autocfg.hp_pins[0] = 0x15;
11672 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011673 spec->ext_mic.pin = 0x18;
11674 spec->ext_mic.mux_idx = 0;
11675 spec->int_mic.pin = 0x12;
11676 spec->int_mic.mux_idx = 9;
11677 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011678}
11679
Takashi Iwai834be882006-03-01 14:16:17 +010011680/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011681 * nec model
11682 * 0x15 = headphone
11683 * 0x16 = internal speaker
11684 * 0x18 = external mic
11685 */
11686
11687static struct snd_kcontrol_new alc262_nec_mixer[] = {
11688 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11689 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11690
11691 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11692 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011693 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011694
11695 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11696 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11697 { } /* end */
11698};
11699
11700static struct hda_verb alc262_nec_verbs[] = {
11701 /* Unmute Speaker */
11702 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11703
11704 /* Headphone */
11705 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11706 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11707
11708 /* External mic to headphone */
11709 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11710 /* External mic to speaker */
11711 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11712 {}
11713};
11714
11715/*
Takashi Iwai834be882006-03-01 14:16:17 +010011716 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011717 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11718 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011719 */
11720
11721#define ALC_HP_EVENT 0x37
11722
11723static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11724 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11725 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011726 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11727 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011728 {}
11729};
11730
Jiang zhe0e31daf2008-03-20 12:12:39 +010011731static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11732 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11733 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11734 {}
11735};
11736
Daniel T Chene2595322009-12-19 18:19:02 -050011737static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11738 /* Front Mic pin: input vref at 50% */
11739 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11740 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11741 {}
11742};
11743
Takashi Iwai834be882006-03-01 14:16:17 +010011744static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011745 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011746 .items = {
11747 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010011748 { "Internal Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011749 { "CD", 0x4 },
11750 },
11751};
11752
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011753static struct hda_input_mux alc262_HP_capture_source = {
11754 .num_items = 5,
11755 .items = {
11756 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011757 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011758 { "Line", 0x2 },
11759 { "CD", 0x4 },
11760 { "AUX IN", 0x6 },
11761 },
11762};
11763
zhejiangaccbe492007-08-31 12:36:05 +020011764static struct hda_input_mux alc262_HP_D7000_capture_source = {
11765 .num_items = 4,
11766 .items = {
11767 { "Mic", 0x0 },
11768 { "Front Mic", 0x2 },
11769 { "Line", 0x1 },
11770 { "CD", 0x4 },
11771 },
11772};
11773
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011774/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011775static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11776{
11777 struct alc_spec *spec = codec->spec;
11778 unsigned int mute;
11779
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011780 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011781 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11782 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011783 spec->sense_updated = 1;
11784 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011785 /* unmute internal speaker only if both HPs are unplugged and
11786 * master switch is on
11787 */
11788 if (spec->jack_present)
11789 mute = HDA_AMP_MUTE;
11790 else
Takashi Iwai834be882006-03-01 14:16:17 +010011791 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011792 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11793 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011794}
11795
11796/* unsolicited event for HP jack sensing */
11797static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11798 unsigned int res)
11799{
11800 if ((res >> 26) != ALC_HP_EVENT)
11801 return;
11802 alc262_fujitsu_automute(codec, 1);
11803}
11804
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011805static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11806{
11807 alc262_fujitsu_automute(codec, 1);
11808}
11809
Takashi Iwai834be882006-03-01 14:16:17 +010011810/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011811static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11812 .ops = &snd_hda_bind_vol,
11813 .values = {
11814 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11815 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11816 0
11817 },
11818};
Takashi Iwai834be882006-03-01 14:16:17 +010011819
Jiang zhe0e31daf2008-03-20 12:12:39 +010011820/* mute/unmute internal speaker according to the hp jack and mute state */
11821static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11822{
11823 struct alc_spec *spec = codec->spec;
11824 unsigned int mute;
11825
11826 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011827 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011828 spec->sense_updated = 1;
11829 }
11830 if (spec->jack_present) {
11831 /* mute internal speaker */
11832 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11833 HDA_AMP_MUTE, HDA_AMP_MUTE);
11834 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11835 HDA_AMP_MUTE, HDA_AMP_MUTE);
11836 } else {
11837 /* unmute internal speaker if necessary */
11838 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11839 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11840 HDA_AMP_MUTE, mute);
11841 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11842 HDA_AMP_MUTE, mute);
11843 }
11844}
11845
11846/* unsolicited event for HP jack sensing */
11847static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11848 unsigned int res)
11849{
11850 if ((res >> 26) != ALC_HP_EVENT)
11851 return;
11852 alc262_lenovo_3000_automute(codec, 1);
11853}
11854
Takashi Iwai8de56b72009-07-24 16:51:47 +020011855static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11856 int dir, int idx, long *valp)
11857{
11858 int i, change = 0;
11859
11860 for (i = 0; i < 2; i++, valp++)
11861 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11862 HDA_AMP_MUTE,
11863 *valp ? 0 : HDA_AMP_MUTE);
11864 return change;
11865}
11866
Takashi Iwai834be882006-03-01 14:16:17 +010011867/* bind hp and internal speaker mute (with plug check) */
11868static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11869 struct snd_ctl_elem_value *ucontrol)
11870{
11871 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11872 long *valp = ucontrol->value.integer.value;
11873 int change;
11874
Takashi Iwai8de56b72009-07-24 16:51:47 +020011875 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11876 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011877 if (change)
11878 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011879 return change;
11880}
11881
11882static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011883 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011884 {
11885 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11886 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011887 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011888 .info = snd_hda_mixer_amp_switch_info,
11889 .get = snd_hda_mixer_amp_switch_get,
11890 .put = alc262_fujitsu_master_sw_put,
11891 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11892 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011893 {
11894 .iface = NID_MAPPING,
11895 .name = "Master Playback Switch",
11896 .private_value = 0x1b,
11897 },
Takashi Iwai834be882006-03-01 14:16:17 +010011898 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11899 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011900 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011901 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11902 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011903 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010011904 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11905 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011906 { } /* end */
11907};
11908
Jiang zhe0e31daf2008-03-20 12:12:39 +010011909/* bind hp and internal speaker mute (with plug check) */
11910static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11911 struct snd_ctl_elem_value *ucontrol)
11912{
11913 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11914 long *valp = ucontrol->value.integer.value;
11915 int change;
11916
Takashi Iwai8de56b72009-07-24 16:51:47 +020011917 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011918 if (change)
11919 alc262_lenovo_3000_automute(codec, 0);
11920 return change;
11921}
11922
11923static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11924 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11925 {
11926 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11927 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011928 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011929 .info = snd_hda_mixer_amp_switch_info,
11930 .get = snd_hda_mixer_amp_switch_get,
11931 .put = alc262_lenovo_3000_master_sw_put,
11932 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11933 },
11934 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11935 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011936 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011937 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11938 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011939 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010011940 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11941 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011942 { } /* end */
11943};
11944
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011945static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11946 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011947 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011948 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11949 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011950 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011951 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11952 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011953 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011954 { } /* end */
11955};
11956
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011957/* additional init verbs for Benq laptops */
11958static struct hda_verb alc262_EAPD_verbs[] = {
11959 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11960 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11961 {}
11962};
11963
Kailang Yang83c34212007-07-05 11:43:05 +020011964static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11965 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11966 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11967
11968 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11969 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11970 {}
11971};
11972
Tobin Davisf651b502007-10-26 12:40:47 +020011973/* Samsung Q1 Ultra Vista model setup */
11974static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011975 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11976 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011977 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11978 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011979 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
11980 HDA_CODEC_VOLUME("Headphone Mic Boost Volume", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011981 { } /* end */
11982};
11983
11984static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011985 /* output mixer */
11986 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11987 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11988 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11989 /* speaker */
11990 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11991 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11992 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11993 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11994 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011995 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011996 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11997 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11998 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11999 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12000 /* internal mic */
12001 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12002 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12003 /* ADC, choose mic */
12004 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12005 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12006 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12007 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12008 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12009 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12010 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12011 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12012 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
12013 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020012014 {}
12015};
12016
Tobin Davisf651b502007-10-26 12:40:47 +020012017/* mute/unmute internal speaker according to the hp jack and mute state */
12018static void alc262_ultra_automute(struct hda_codec *codec)
12019{
12020 struct alc_spec *spec = codec->spec;
12021 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020012022
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012023 mute = 0;
12024 /* auto-mute only when HP is used as HP */
12025 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012026 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012027 if (spec->jack_present)
12028 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020012029 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012030 /* mute/unmute internal speaker */
12031 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12032 HDA_AMP_MUTE, mute);
12033 /* mute/unmute HP */
12034 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12035 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020012036}
12037
12038/* unsolicited event for HP jack sensing */
12039static void alc262_ultra_unsol_event(struct hda_codec *codec,
12040 unsigned int res)
12041{
12042 if ((res >> 26) != ALC880_HP_EVENT)
12043 return;
12044 alc262_ultra_automute(codec);
12045}
12046
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012047static struct hda_input_mux alc262_ultra_capture_source = {
12048 .num_items = 2,
12049 .items = {
12050 { "Mic", 0x1 },
12051 { "Headphone", 0x7 },
12052 },
12053};
12054
12055static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
12056 struct snd_ctl_elem_value *ucontrol)
12057{
12058 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12059 struct alc_spec *spec = codec->spec;
12060 int ret;
12061
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012062 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012063 if (!ret)
12064 return 0;
12065 /* reprogram the HP pin as mic or HP according to the input source */
12066 snd_hda_codec_write_cache(codec, 0x15, 0,
12067 AC_VERB_SET_PIN_WIDGET_CONTROL,
12068 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
12069 alc262_ultra_automute(codec); /* mute/unmute HP */
12070 return ret;
12071}
12072
12073static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
12074 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
12075 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
12076 {
12077 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12078 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012079 .info = alc_mux_enum_info,
12080 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012081 .put = alc262_ultra_mux_enum_put,
12082 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010012083 {
12084 .iface = NID_MAPPING,
12085 .name = "Capture Source",
12086 .private_value = 0x15,
12087 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012088 { } /* end */
12089};
12090
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012091/* We use two mixers depending on the output pin; 0x16 is a mono output
12092 * and thus it's bound with a different mixer.
12093 * This function returns which mixer amp should be used.
12094 */
12095static int alc262_check_volbit(hda_nid_t nid)
12096{
12097 if (!nid)
12098 return 0;
12099 else if (nid == 0x16)
12100 return 2;
12101 else
12102 return 1;
12103}
12104
12105static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012106 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012107{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012108 unsigned long val;
12109 int vbit;
12110
12111 vbit = alc262_check_volbit(nid);
12112 if (!vbit)
12113 return 0;
12114 if (*vbits & vbit) /* a volume control for this mixer already there */
12115 return 0;
12116 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012117 if (vbit == 2)
12118 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
12119 else
12120 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012121 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012122}
12123
12124static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012125 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012126{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012127 unsigned long val;
12128
12129 if (!nid)
12130 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012131 if (nid == 0x16)
12132 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
12133 else
12134 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012135 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012136}
12137
Kailang Yangdf694da2005-12-05 19:42:22 +010012138/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012139static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
12140 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012141{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012142 const char *pfx;
12143 int vbits;
Takashi Iwai033688a2010-09-08 15:47:09 +020012144 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010012145
12146 spec->multiout.num_dacs = 1; /* only use one dac */
12147 spec->multiout.dac_nids = spec->private_dac_nids;
12148 spec->multiout.dac_nids[0] = 2;
12149
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010012150 pfx = alc_get_line_out_pfx(cfg, true);
12151 if (!pfx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012152 pfx = "Front";
Takashi Iwai033688a2010-09-08 15:47:09 +020012153 for (i = 0; i < 2; i++) {
12154 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
12155 if (err < 0)
12156 return err;
12157 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12158 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
12159 "Speaker", i);
12160 if (err < 0)
12161 return err;
12162 }
12163 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12164 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
12165 "Headphone", i);
12166 if (err < 0)
12167 return err;
12168 }
12169 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012170
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012171 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
12172 alc262_check_volbit(cfg->speaker_pins[0]) |
12173 alc262_check_volbit(cfg->hp_pins[0]);
12174 if (vbits == 1 || vbits == 2)
12175 pfx = "Master"; /* only one mixer is used */
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012176 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020012177 for (i = 0; i < 2; i++) {
12178 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
12179 &vbits, i);
12180 if (err < 0)
12181 return err;
12182 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12183 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
12184 "Speaker", &vbits, i);
12185 if (err < 0)
12186 return err;
12187 }
12188 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12189 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
12190 "Headphone", &vbits, i);
12191 if (err < 0)
12192 return err;
12193 }
12194 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012195 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010012196}
12197
Takashi Iwai05f5f472009-08-25 13:10:18 +020012198#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010012199 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010012200
12201/*
12202 * generic initialization of ADC, input mixers and output mixers
12203 */
12204static struct hda_verb alc262_volume_init_verbs[] = {
12205 /*
12206 * Unmute ADC0-2 and set the default input to mic-in
12207 */
12208 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12209 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12210 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12211 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12212 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12213 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12214
Takashi Iwaicb53c622007-08-10 17:21:45 +020012215 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010012216 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012217 * Note: PASD motherboards uses the Line In 2 as the input for
12218 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010012219 */
12220 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012221 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12222 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12223 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12224 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12225 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012226
12227 /*
12228 * Set up output mixers (0x0c - 0x0f)
12229 */
12230 /* set vol=0 to output mixers */
12231 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12232 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12233 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020012234
Kailang Yangdf694da2005-12-05 19:42:22 +010012235 /* set up input amps for analog loopback */
12236 /* Amp Indices: DAC = 0, mixer = 1 */
12237 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12238 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12239 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12240 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12241 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12242 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12243
12244 /* FIXME: use matrix-type input source selection */
12245 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12246 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12247 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12248 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12249 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12250 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12251 /* Input mixer2 */
12252 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12253 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12254 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12255 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12256 /* Input mixer3 */
12257 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12258 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12259 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12260 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12261
12262 { }
12263};
12264
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012265static struct hda_verb alc262_HP_BPC_init_verbs[] = {
12266 /*
12267 * Unmute ADC0-2 and set the default input to mic-in
12268 */
12269 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12270 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12271 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12272 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12273 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12274 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12275
Takashi Iwaicb53c622007-08-10 17:21:45 +020012276 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012277 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012278 * Note: PASD motherboards uses the Line In 2 as the input for
12279 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012280 */
12281 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012282 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12283 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12284 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12285 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12286 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12287 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12288 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012289
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012290 /*
12291 * Set up output mixers (0x0c - 0x0e)
12292 */
12293 /* set vol=0 to output mixers */
12294 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12295 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12296 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12297
12298 /* set up input amps for analog loopback */
12299 /* Amp Indices: DAC = 0, mixer = 1 */
12300 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12301 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12302 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12303 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12304 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12305 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12306
Takashi Iwaice875f02008-01-28 18:17:43 +010012307 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012308 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12309 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12310
12311 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12312 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12313
12314 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12315 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12316
12317 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12318 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12319 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12320 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12321 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12322
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012323 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012324 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12325 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012326 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012327 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12328 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12329
12330
12331 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012332 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12333 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012334 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012335 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12336 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12337 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12338 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12339 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12340 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12341 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12342 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012343 /* Input mixer2 */
12344 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012345 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12346 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12347 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12348 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12349 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12350 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12351 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12352 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012353 /* Input mixer3 */
12354 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012355 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12356 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12357 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12358 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12359 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12360 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12361 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12362 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012363
Takashi Iwaice875f02008-01-28 18:17:43 +010012364 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12365
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012366 { }
12367};
12368
Kailang Yangcd7509a2007-01-26 18:33:17 +010012369static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12370 /*
12371 * Unmute ADC0-2 and set the default input to mic-in
12372 */
12373 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12374 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12375 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12376 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12377 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12378 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12379
Takashi Iwaicb53c622007-08-10 17:21:45 +020012380 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012381 * mixer widget
12382 * Note: PASD motherboards uses the Line In 2 as the input for front
12383 * panel mic (mic 2)
12384 */
12385 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012386 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12387 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12388 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12389 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12390 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12391 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12392 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12393 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012394 /*
12395 * Set up output mixers (0x0c - 0x0e)
12396 */
12397 /* set vol=0 to output mixers */
12398 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12399 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12400 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12401
12402 /* set up input amps for analog loopback */
12403 /* Amp Indices: DAC = 0, mixer = 1 */
12404 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12405 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12406 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12407 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12408 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12409 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12410
12411
12412 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12413 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12414 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12415 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12416 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12417 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12418 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12419
12420 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12421 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12422
12423 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12424 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12425
12426 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12427 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12428 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12429 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12430 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12431 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12432
12433 /* FIXME: use matrix-type input source selection */
12434 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12435 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12436 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12437 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12438 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12439 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12440 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12441 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12442 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12443 /* Input mixer2 */
12444 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12445 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12446 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12447 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12448 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12449 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12450 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12451 /* Input mixer3 */
12452 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12453 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12454 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12455 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12456 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12457 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12459
Takashi Iwaice875f02008-01-28 18:17:43 +010012460 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12461
Kailang Yangcd7509a2007-01-26 18:33:17 +010012462 { }
12463};
12464
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012465static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12466
12467 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12468 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12469 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12470
12471 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12472 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12473 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12474 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12475
12476 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12477 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12478 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12479 {}
12480};
12481
Takashi Iwai18675e42010-09-08 15:55:44 +020012482/*
12483 * Pin config fixes
12484 */
12485enum {
12486 PINFIX_FSC_H270,
12487};
12488
12489static const struct alc_fixup alc262_fixups[] = {
12490 [PINFIX_FSC_H270] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012491 .type = ALC_FIXUP_PINS,
12492 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai18675e42010-09-08 15:55:44 +020012493 { 0x14, 0x99130110 }, /* speaker */
12494 { 0x15, 0x0221142f }, /* front HP */
12495 { 0x1b, 0x0121141f }, /* rear HP */
12496 { }
12497 }
12498 },
Takashi Iwai18675e42010-09-08 15:55:44 +020012499};
12500
12501static struct snd_pci_quirk alc262_fixup_tbl[] = {
12502 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12503 {}
12504};
12505
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012506
Takashi Iwaicb53c622007-08-10 17:21:45 +020012507#ifdef CONFIG_SND_HDA_POWER_SAVE
12508#define alc262_loopbacks alc880_loopbacks
12509#endif
12510
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012511/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012512#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12513#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12514#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12515#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12516
12517/*
12518 * BIOS auto configuration
12519 */
12520static int alc262_parse_auto_config(struct hda_codec *codec)
12521{
12522 struct alc_spec *spec = codec->spec;
12523 int err;
12524 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12525
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012526 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12527 alc262_ignore);
12528 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012529 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012530 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012531 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012532 spec->multiout.max_channels = 2;
12533 spec->no_analog = 1;
12534 goto dig_only;
12535 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012536 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012537 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012538 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12539 if (err < 0)
12540 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012541 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012542 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012543 return err;
12544
12545 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12546
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012547 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012548 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012549
Takashi Iwai603c4012008-07-30 15:01:44 +020012550 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012551 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012552
Takashi Iwaid88897e2008-10-31 15:01:37 +010012553 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012554 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012555 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012556
Takashi Iwai776e1842007-08-29 15:07:11 +020012557 err = alc_auto_add_mic_boost(codec);
12558 if (err < 0)
12559 return err;
12560
Kailang Yang6227cdc2010-02-25 08:36:52 +010012561 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012562
Kailang Yangdf694da2005-12-05 19:42:22 +010012563 return 1;
12564}
12565
12566#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12567#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12568#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012569#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012570
12571
12572/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012573static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012574{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012575 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012576 alc262_auto_init_multi_out(codec);
12577 alc262_auto_init_hp_out(codec);
12578 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012579 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012580 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012581 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012582 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012583}
12584
12585/*
12586 * configuration and preset
12587 */
Takashi Iwaiea734962011-01-17 11:29:34 +010012588static const char * const alc262_models[ALC262_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012589 [ALC262_BASIC] = "basic",
12590 [ALC262_HIPPO] = "hippo",
12591 [ALC262_HIPPO_1] = "hippo_1",
12592 [ALC262_FUJITSU] = "fujitsu",
12593 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012594 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012595 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012596 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012597 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012598 [ALC262_BENQ_T31] = "benq-t31",
12599 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012600 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012601 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012602 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012603 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012604 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012605 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012606 [ALC262_AUTO] = "auto",
12607};
12608
12609static struct snd_pci_quirk alc262_cfg_tbl[] = {
12610 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012611 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012612 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12613 ALC262_HP_BPC),
12614 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12615 ALC262_HP_BPC),
Takashi Iwai5734a072011-01-19 17:07:12 +010012616 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1500, "HP z series",
12617 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012618 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12619 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012620 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012621 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012622 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012623 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012624 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012625 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012626 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012627 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012628 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12629 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12630 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012631 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12632 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012633 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012634 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012635 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012636 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012637 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012638 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012639 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012640 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012641#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012642 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12643 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012644#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012645 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012646 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012647 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012648 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012649 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012650 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012651 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12652 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012653 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012654 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012655 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012656 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012657 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012658 {}
12659};
12660
12661static struct alc_config_preset alc262_presets[] = {
12662 [ALC262_BASIC] = {
12663 .mixers = { alc262_base_mixer },
12664 .init_verbs = { alc262_init_verbs },
12665 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12666 .dac_nids = alc262_dac_nids,
12667 .hp_nid = 0x03,
12668 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12669 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012670 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012671 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012672 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012673 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012674 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012675 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12676 .dac_nids = alc262_dac_nids,
12677 .hp_nid = 0x03,
12678 .dig_out_nid = ALC262_DIGOUT_NID,
12679 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12680 .channel_mode = alc262_modes,
12681 .input_mux = &alc262_capture_source,
12682 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012683 .setup = alc262_hippo_setup,
12684 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012685 },
12686 [ALC262_HIPPO_1] = {
12687 .mixers = { alc262_hippo1_mixer },
12688 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12689 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12690 .dac_nids = alc262_dac_nids,
12691 .hp_nid = 0x02,
12692 .dig_out_nid = ALC262_DIGOUT_NID,
12693 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12694 .channel_mode = alc262_modes,
12695 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012696 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012697 .setup = alc262_hippo1_setup,
12698 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012699 },
Takashi Iwai834be882006-03-01 14:16:17 +010012700 [ALC262_FUJITSU] = {
12701 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012702 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12703 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012704 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12705 .dac_nids = alc262_dac_nids,
12706 .hp_nid = 0x03,
12707 .dig_out_nid = ALC262_DIGOUT_NID,
12708 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12709 .channel_mode = alc262_modes,
12710 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012711 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012712 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012713 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012714 [ALC262_HP_BPC] = {
12715 .mixers = { alc262_HP_BPC_mixer },
12716 .init_verbs = { alc262_HP_BPC_init_verbs },
12717 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12718 .dac_nids = alc262_dac_nids,
12719 .hp_nid = 0x03,
12720 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12721 .channel_mode = alc262_modes,
12722 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012723 .unsol_event = alc262_hp_bpc_unsol_event,
12724 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012725 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012726 [ALC262_HP_BPC_D7000_WF] = {
12727 .mixers = { alc262_HP_BPC_WildWest_mixer },
12728 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12729 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12730 .dac_nids = alc262_dac_nids,
12731 .hp_nid = 0x03,
12732 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12733 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012734 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012735 .unsol_event = alc262_hp_wildwest_unsol_event,
12736 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012737 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012738 [ALC262_HP_BPC_D7000_WL] = {
12739 .mixers = { alc262_HP_BPC_WildWest_mixer,
12740 alc262_HP_BPC_WildWest_option_mixer },
12741 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12742 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12743 .dac_nids = alc262_dac_nids,
12744 .hp_nid = 0x03,
12745 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12746 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012747 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012748 .unsol_event = alc262_hp_wildwest_unsol_event,
12749 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012750 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012751 [ALC262_HP_TC_T5735] = {
12752 .mixers = { alc262_hp_t5735_mixer },
12753 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12754 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12755 .dac_nids = alc262_dac_nids,
12756 .hp_nid = 0x03,
12757 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12758 .channel_mode = alc262_modes,
12759 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012760 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012761 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012762 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012763 },
12764 [ALC262_HP_RP5700] = {
12765 .mixers = { alc262_hp_rp5700_mixer },
12766 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12767 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12768 .dac_nids = alc262_dac_nids,
12769 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12770 .channel_mode = alc262_modes,
12771 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012772 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012773 [ALC262_BENQ_ED8] = {
12774 .mixers = { alc262_base_mixer },
12775 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12776 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12777 .dac_nids = alc262_dac_nids,
12778 .hp_nid = 0x03,
12779 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12780 .channel_mode = alc262_modes,
12781 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012782 },
Kailang Yang272a5272007-05-14 11:00:38 +020012783 [ALC262_SONY_ASSAMD] = {
12784 .mixers = { alc262_sony_mixer },
12785 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12786 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12787 .dac_nids = alc262_dac_nids,
12788 .hp_nid = 0x02,
12789 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12790 .channel_mode = alc262_modes,
12791 .input_mux = &alc262_capture_source,
12792 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012793 .setup = alc262_hippo_setup,
12794 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012795 },
12796 [ALC262_BENQ_T31] = {
12797 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012798 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12799 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012800 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12801 .dac_nids = alc262_dac_nids,
12802 .hp_nid = 0x03,
12803 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12804 .channel_mode = alc262_modes,
12805 .input_mux = &alc262_capture_source,
12806 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012807 .setup = alc262_hippo_setup,
12808 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012809 },
Tobin Davisf651b502007-10-26 12:40:47 +020012810 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012811 .mixers = { alc262_ultra_mixer },
12812 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012813 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012814 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12815 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012816 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12817 .channel_mode = alc262_modes,
12818 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012819 .adc_nids = alc262_adc_nids, /* ADC0 */
12820 .capsrc_nids = alc262_capsrc_nids,
12821 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012822 .unsol_event = alc262_ultra_unsol_event,
12823 .init_hook = alc262_ultra_automute,
12824 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012825 [ALC262_LENOVO_3000] = {
12826 .mixers = { alc262_lenovo_3000_mixer },
12827 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012828 alc262_lenovo_3000_unsol_verbs,
12829 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012830 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12831 .dac_nids = alc262_dac_nids,
12832 .hp_nid = 0x03,
12833 .dig_out_nid = ALC262_DIGOUT_NID,
12834 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12835 .channel_mode = alc262_modes,
12836 .input_mux = &alc262_fujitsu_capture_source,
12837 .unsol_event = alc262_lenovo_3000_unsol_event,
12838 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012839 [ALC262_NEC] = {
12840 .mixers = { alc262_nec_mixer },
12841 .init_verbs = { alc262_nec_verbs },
12842 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12843 .dac_nids = alc262_dac_nids,
12844 .hp_nid = 0x03,
12845 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12846 .channel_mode = alc262_modes,
12847 .input_mux = &alc262_capture_source,
12848 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012849 [ALC262_TOSHIBA_S06] = {
12850 .mixers = { alc262_toshiba_s06_mixer },
12851 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12852 alc262_eapd_verbs },
12853 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12854 .capsrc_nids = alc262_dmic_capsrc_nids,
12855 .dac_nids = alc262_dac_nids,
12856 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012857 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012858 .dig_out_nid = ALC262_DIGOUT_NID,
12859 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12860 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012861 .unsol_event = alc_sku_unsol_event,
12862 .setup = alc262_toshiba_s06_setup,
12863 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012864 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012865 [ALC262_TOSHIBA_RX1] = {
12866 .mixers = { alc262_toshiba_rx1_mixer },
12867 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12868 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12869 .dac_nids = alc262_dac_nids,
12870 .hp_nid = 0x03,
12871 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12872 .channel_mode = alc262_modes,
12873 .input_mux = &alc262_capture_source,
12874 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012875 .setup = alc262_hippo_setup,
12876 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012877 },
Tony Vroonba340e82009-02-02 19:01:30 +000012878 [ALC262_TYAN] = {
12879 .mixers = { alc262_tyan_mixer },
12880 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12881 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12882 .dac_nids = alc262_dac_nids,
12883 .hp_nid = 0x02,
12884 .dig_out_nid = ALC262_DIGOUT_NID,
12885 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12886 .channel_mode = alc262_modes,
12887 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012888 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012889 .setup = alc262_tyan_setup,
12890 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012891 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012892};
12893
12894static int patch_alc262(struct hda_codec *codec)
12895{
12896 struct alc_spec *spec;
12897 int board_config;
12898 int err;
12899
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012900 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012901 if (spec == NULL)
12902 return -ENOMEM;
12903
12904 codec->spec = spec;
12905#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012906 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12907 * under-run
12908 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012909 {
12910 int tmp;
12911 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12912 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12913 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12914 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12915 }
12916#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012917 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012918
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012919 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12920
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012921 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12922 alc262_models,
12923 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012924
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012925 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012926 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12927 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012928 board_config = ALC262_AUTO;
12929 }
12930
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012931 if (board_config == ALC262_AUTO) {
12932 alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups);
12933 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
12934 }
Takashi Iwai18675e42010-09-08 15:55:44 +020012935
Kailang Yangdf694da2005-12-05 19:42:22 +010012936 if (board_config == ALC262_AUTO) {
12937 /* automatic parse from the BIOS config */
12938 err = alc262_parse_auto_config(codec);
12939 if (err < 0) {
12940 alc_free(codec);
12941 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012942 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012943 printk(KERN_INFO
12944 "hda_codec: Cannot set up configuration "
12945 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012946 board_config = ALC262_BASIC;
12947 }
12948 }
12949
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012950 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012951 err = snd_hda_attach_beep_device(codec, 0x1);
12952 if (err < 0) {
12953 alc_free(codec);
12954 return err;
12955 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012956 }
12957
Kailang Yangdf694da2005-12-05 19:42:22 +010012958 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012959 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012960
Kailang Yangdf694da2005-12-05 19:42:22 +010012961 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12962 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012963
Kailang Yangdf694da2005-12-05 19:42:22 +010012964 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12965 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12966
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012967 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012968 int i;
12969 /* check whether the digital-mic has to be supported */
12970 for (i = 0; i < spec->input_mux->num_items; i++) {
12971 if (spec->input_mux->items[i].index >= 9)
12972 break;
12973 }
12974 if (i < spec->input_mux->num_items) {
12975 /* use only ADC0 */
12976 spec->adc_nids = alc262_dmic_adc_nids;
12977 spec->num_adc_nids = 1;
12978 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012979 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012980 /* all analog inputs */
12981 /* check whether NID 0x07 is valid */
12982 unsigned int wcap = get_wcaps(codec, 0x07);
12983
12984 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012985 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012986 if (wcap != AC_WID_AUD_IN) {
12987 spec->adc_nids = alc262_adc_nids_alt;
12988 spec->num_adc_nids =
12989 ARRAY_SIZE(alc262_adc_nids_alt);
12990 spec->capsrc_nids = alc262_capsrc_nids_alt;
12991 } else {
12992 spec->adc_nids = alc262_adc_nids;
12993 spec->num_adc_nids =
12994 ARRAY_SIZE(alc262_adc_nids);
12995 spec->capsrc_nids = alc262_capsrc_nids;
12996 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012997 }
12998 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012999 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013000 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020013001 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010013002 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010013003
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010013004 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai18675e42010-09-08 15:55:44 +020013005
Takashi Iwai2134ea42008-01-10 16:53:55 +010013006 spec->vmaster_nid = 0x0c;
13007
Kailang Yangdf694da2005-12-05 19:42:22 +010013008 codec->patch_ops = alc_patch_ops;
13009 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013010 spec->init_hook = alc262_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020013011
13012 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020013013#ifdef CONFIG_SND_HDA_POWER_SAVE
13014 if (!spec->loopback.amplist)
13015 spec->loopback.amplist = alc262_loopbacks;
13016#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020013017
Kailang Yangdf694da2005-12-05 19:42:22 +010013018 return 0;
13019}
13020
Kailang Yangdf694da2005-12-05 19:42:22 +010013021/*
Kailang Yanga361d842007-06-05 12:30:55 +020013022 * ALC268 channel source setting (2 channel)
13023 */
13024#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
13025#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020013026
Kailang Yanga361d842007-06-05 12:30:55 +020013027static hda_nid_t alc268_dac_nids[2] = {
13028 /* front, hp */
13029 0x02, 0x03
13030};
13031
13032static hda_nid_t alc268_adc_nids[2] = {
13033 /* ADC0-1 */
13034 0x08, 0x07
13035};
13036
13037static hda_nid_t alc268_adc_nids_alt[1] = {
13038 /* ADC0 */
13039 0x08
13040};
13041
Takashi Iwaie1406342008-02-11 18:32:32 +010013042static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
13043
Kailang Yanga361d842007-06-05 12:30:55 +020013044static struct snd_kcontrol_new alc268_base_mixer[] = {
13045 /* output mixer control */
13046 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13047 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13048 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13049 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013050 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13051 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13052 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020013053 { }
13054};
13055
Takashi Iwai42171c12009-05-08 14:11:43 +020013056static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
13057 /* output mixer control */
13058 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13059 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13060 ALC262_HIPPO_MASTER_SWITCH,
David Henningsson5f99f862011-01-04 15:24:24 +010013061 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13062 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13063 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020013064 { }
13065};
13066
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013067/* bind Beep switches of both NID 0x0f and 0x10 */
13068static struct hda_bind_ctls alc268_bind_beep_sw = {
13069 .ops = &snd_hda_bind_sw,
13070 .values = {
13071 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
13072 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
13073 0
13074 },
13075};
13076
13077static struct snd_kcontrol_new alc268_beep_mixer[] = {
13078 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
13079 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
13080 { }
13081};
13082
Kailang Yangd1a991a2007-08-15 16:21:59 +020013083static struct hda_verb alc268_eapd_verbs[] = {
13084 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13085 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13086 { }
13087};
13088
Takashi Iwaid2738092007-08-16 14:59:45 +020013089/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020013090static struct hda_verb alc268_toshiba_verbs[] = {
13091 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13092 { } /* end */
13093};
13094
13095/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020013096/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020013097static struct hda_bind_ctls alc268_acer_bind_master_vol = {
13098 .ops = &snd_hda_bind_vol,
13099 .values = {
13100 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
13101 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
13102 0
13103 },
13104};
13105
Takashi Iwai889c4392007-08-23 18:56:52 +020013106/* mute/unmute internal speaker according to the hp jack and mute state */
13107static void alc268_acer_automute(struct hda_codec *codec, int force)
13108{
13109 struct alc_spec *spec = codec->spec;
13110 unsigned int mute;
13111
13112 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080013113 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020013114 spec->sense_updated = 1;
13115 }
13116 if (spec->jack_present)
13117 mute = HDA_AMP_MUTE; /* mute internal speaker */
13118 else /* unmute internal speaker if necessary */
13119 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13120 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13121 HDA_AMP_MUTE, mute);
13122}
13123
13124
13125/* bind hp and internal speaker mute (with plug check) */
13126static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
13127 struct snd_ctl_elem_value *ucontrol)
13128{
13129 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
13130 long *valp = ucontrol->value.integer.value;
13131 int change;
13132
Takashi Iwai8de56b72009-07-24 16:51:47 +020013133 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020013134 if (change)
13135 alc268_acer_automute(codec, 0);
13136 return change;
13137}
Takashi Iwaid2738092007-08-16 14:59:45 +020013138
Kailang Yang8ef355d2008-08-26 13:10:22 +020013139static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
13140 /* output mixer control */
13141 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13142 {
13143 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13144 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013145 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013146 .info = snd_hda_mixer_amp_switch_info,
13147 .get = snd_hda_mixer_amp_switch_get,
13148 .put = alc268_acer_master_sw_put,
13149 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13150 },
13151 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
13152 { }
13153};
13154
Takashi Iwaid2738092007-08-16 14:59:45 +020013155static struct snd_kcontrol_new alc268_acer_mixer[] = {
13156 /* output mixer control */
13157 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13158 {
13159 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13160 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013161 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020013162 .info = snd_hda_mixer_amp_switch_info,
13163 .get = snd_hda_mixer_amp_switch_get,
13164 .put = alc268_acer_master_sw_put,
13165 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13166 },
David Henningsson5f99f862011-01-04 15:24:24 +010013167 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13168 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
13169 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020013170 { }
13171};
13172
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013173static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
13174 /* output mixer control */
13175 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13176 {
13177 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13178 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013179 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013180 .info = snd_hda_mixer_amp_switch_info,
13181 .get = snd_hda_mixer_amp_switch_get,
13182 .put = alc268_acer_master_sw_put,
13183 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13184 },
David Henningsson5f99f862011-01-04 15:24:24 +010013185 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13186 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013187 { }
13188};
13189
Kailang Yang8ef355d2008-08-26 13:10:22 +020013190static struct hda_verb alc268_acer_aspire_one_verbs[] = {
13191 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13192 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13193 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13194 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13195 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
13196 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
13197 { }
13198};
13199
Takashi Iwaid2738092007-08-16 14:59:45 +020013200static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013201 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
13202 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020013203 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13204 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013205 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13206 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020013207 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13208 { }
13209};
13210
13211/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020013212#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013213#define alc268_toshiba_setup alc262_hippo_setup
13214#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020013215
13216static void alc268_acer_unsol_event(struct hda_codec *codec,
13217 unsigned int res)
13218{
Takashi Iwai889c4392007-08-23 18:56:52 +020013219 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020013220 return;
13221 alc268_acer_automute(codec, 1);
13222}
13223
Takashi Iwai889c4392007-08-23 18:56:52 +020013224static void alc268_acer_init_hook(struct hda_codec *codec)
13225{
13226 alc268_acer_automute(codec, 1);
13227}
13228
Kailang Yang8ef355d2008-08-26 13:10:22 +020013229/* toggle speaker-output according to the hp-jack state */
13230static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
13231{
13232 unsigned int present;
13233 unsigned char bits;
13234
Wu Fengguang864f92b2009-11-18 12:38:02 +080013235 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013236 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013237 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013238 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013239 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013240 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013241}
13242
Kailang Yang8ef355d2008-08-26 13:10:22 +020013243static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
13244 unsigned int res)
13245{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013246 switch (res >> 26) {
13247 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020013248 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013249 break;
13250 case ALC880_MIC_EVENT:
13251 alc_mic_automute(codec);
13252 break;
13253 }
13254}
13255
13256static void alc268_acer_lc_setup(struct hda_codec *codec)
13257{
13258 struct alc_spec *spec = codec->spec;
13259 spec->ext_mic.pin = 0x18;
13260 spec->ext_mic.mux_idx = 0;
13261 spec->int_mic.pin = 0x12;
13262 spec->int_mic.mux_idx = 6;
13263 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013264}
13265
13266static void alc268_acer_lc_init_hook(struct hda_codec *codec)
13267{
13268 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013269 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013270}
13271
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013272static struct snd_kcontrol_new alc268_dell_mixer[] = {
13273 /* output mixer control */
13274 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13275 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13276 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13277 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013278 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13279 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013280 { }
13281};
13282
13283static struct hda_verb alc268_dell_verbs[] = {
13284 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13285 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13286 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013287 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013288 { }
13289};
13290
13291/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013292static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013293{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013294 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013295
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013296 spec->autocfg.hp_pins[0] = 0x15;
13297 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013298 spec->ext_mic.pin = 0x18;
13299 spec->ext_mic.mux_idx = 0;
13300 spec->int_mic.pin = 0x19;
13301 spec->int_mic.mux_idx = 1;
13302 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013303}
13304
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013305static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
13306 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13307 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13308 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13309 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13310 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13311 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013312 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13313 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013314 { }
13315};
13316
13317static struct hda_verb alc267_quanta_il1_verbs[] = {
13318 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13319 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13320 { }
13321};
13322
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013323static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013324{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013325 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013326 spec->autocfg.hp_pins[0] = 0x15;
13327 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013328 spec->ext_mic.pin = 0x18;
13329 spec->ext_mic.mux_idx = 0;
13330 spec->int_mic.pin = 0x19;
13331 spec->int_mic.mux_idx = 1;
13332 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013333}
13334
Kailang Yanga361d842007-06-05 12:30:55 +020013335/*
13336 * generic initialization of ADC, input mixers and output mixers
13337 */
13338static struct hda_verb alc268_base_init_verbs[] = {
13339 /* Unmute DAC0-1 and set vol = 0 */
13340 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013341 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013342
13343 /*
13344 * Set up output mixers (0x0c - 0x0e)
13345 */
13346 /* set vol=0 to output mixers */
13347 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013348 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13349
13350 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13351 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13352
13353 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13354 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13355 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13356 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13357 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13358 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13359 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13360 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13361
13362 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13363 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13364 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13365 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013366 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013367
13368 /* set PCBEEP vol = 0, mute connections */
13369 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13370 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13371 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013372
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013373 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013374
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013375 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13376 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13377 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13378 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013379
Kailang Yanga361d842007-06-05 12:30:55 +020013380 { }
13381};
13382
13383/*
13384 * generic initialization of ADC, input mixers and output mixers
13385 */
13386static struct hda_verb alc268_volume_init_verbs[] = {
13387 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013388 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13389 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013390
13391 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13392 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13393 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13394 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13395 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13396
Kailang Yanga361d842007-06-05 12:30:55 +020013397 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013398 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13399 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13400
13401 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013402 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013403
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013404 /* set PCBEEP vol = 0, mute connections */
13405 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13406 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13407 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013408
13409 { }
13410};
13411
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013412static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13413 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13414 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13415 { } /* end */
13416};
13417
Kailang Yanga361d842007-06-05 12:30:55 +020013418static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13419 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13420 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013421 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013422 { } /* end */
13423};
13424
13425static struct snd_kcontrol_new alc268_capture_mixer[] = {
13426 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13427 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13428 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13429 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013430 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013431 { } /* end */
13432};
13433
13434static struct hda_input_mux alc268_capture_source = {
13435 .num_items = 4,
13436 .items = {
13437 { "Mic", 0x0 },
13438 { "Front Mic", 0x1 },
13439 { "Line", 0x2 },
13440 { "CD", 0x3 },
13441 },
13442};
13443
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013444static struct hda_input_mux alc268_acer_capture_source = {
13445 .num_items = 3,
13446 .items = {
13447 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013448 { "Internal Mic", 0x1 },
13449 { "Line", 0x2 },
13450 },
13451};
13452
13453static struct hda_input_mux alc268_acer_dmic_capture_source = {
13454 .num_items = 3,
13455 .items = {
13456 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013457 { "Internal Mic", 0x6 },
13458 { "Line", 0x2 },
13459 },
13460};
13461
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013462#ifdef CONFIG_SND_DEBUG
13463static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013464 /* Volume widgets */
13465 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13466 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13467 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13468 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13469 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13470 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13471 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13472 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13473 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13474 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13475 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13476 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13477 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013478 /* The below appears problematic on some hardwares */
13479 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013480 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13481 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13482 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13483 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13484
13485 /* Modes for retasking pin widgets */
13486 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13487 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13488 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13489 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13490
13491 /* Controls for GPIO pins, assuming they are configured as outputs */
13492 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13493 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13494 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13495 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13496
13497 /* Switches to allow the digital SPDIF output pin to be enabled.
13498 * The ALC268 does not have an SPDIF input.
13499 */
13500 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13501
13502 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13503 * this output to turn on an external amplifier.
13504 */
13505 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13506 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13507
13508 { } /* end */
13509};
13510#endif
13511
Kailang Yanga361d842007-06-05 12:30:55 +020013512/* create input playback/capture controls for the given pin */
13513static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13514 const char *ctlname, int idx)
13515{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013516 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013517 int err;
13518
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013519 switch (nid) {
13520 case 0x14:
13521 case 0x16:
13522 dac = 0x02;
13523 break;
13524 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013525 case 0x1a: /* ALC259/269 only */
13526 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013527 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013528 dac = 0x03;
13529 break;
13530 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013531 snd_printd(KERN_WARNING "hda_codec: "
13532 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013533 return 0;
13534 }
13535 if (spec->multiout.dac_nids[0] != dac &&
13536 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013537 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013538 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013539 HDA_OUTPUT));
13540 if (err < 0)
13541 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013542 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13543 }
13544
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013545 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013546 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013547 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013548 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013549 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013550 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013551 if (err < 0)
13552 return err;
13553 return 0;
13554}
13555
13556/* add playback controls from the parsed DAC table */
13557static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13558 const struct auto_pin_cfg *cfg)
13559{
13560 hda_nid_t nid;
13561 int err;
13562
Kailang Yanga361d842007-06-05 12:30:55 +020013563 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013564
13565 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013566 if (nid) {
13567 const char *name;
13568 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13569 name = "Speaker";
13570 else
13571 name = "Front";
13572 err = alc268_new_analog_output(spec, nid, name, 0);
13573 if (err < 0)
13574 return err;
13575 }
Kailang Yanga361d842007-06-05 12:30:55 +020013576
13577 nid = cfg->speaker_pins[0];
13578 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013579 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013580 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13581 if (err < 0)
13582 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013583 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013584 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13585 if (err < 0)
13586 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013587 }
13588 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013589 if (nid) {
13590 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13591 if (err < 0)
13592 return err;
13593 }
Kailang Yanga361d842007-06-05 12:30:55 +020013594
13595 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13596 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013597 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013598 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013599 if (err < 0)
13600 return err;
13601 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013602 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013603}
13604
13605/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013606static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013607 const struct auto_pin_cfg *cfg)
13608{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013609 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013610}
13611
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013612static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13613 hda_nid_t nid, int pin_type)
13614{
13615 int idx;
13616
13617 alc_set_pin_output(codec, nid, pin_type);
13618 if (nid == 0x14 || nid == 0x16)
13619 idx = 0;
13620 else
13621 idx = 1;
13622 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13623}
13624
13625static void alc268_auto_init_multi_out(struct hda_codec *codec)
13626{
13627 struct alc_spec *spec = codec->spec;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013628 int i;
13629
13630 for (i = 0; i < spec->autocfg.line_outs; i++) {
13631 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013632 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13633 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13634 }
13635}
13636
13637static void alc268_auto_init_hp_out(struct hda_codec *codec)
13638{
13639 struct alc_spec *spec = codec->spec;
13640 hda_nid_t pin;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013641 int i;
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013642
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013643 for (i = 0; i < spec->autocfg.hp_outs; i++) {
13644 pin = spec->autocfg.hp_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013645 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013646 }
13647 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
13648 pin = spec->autocfg.speaker_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013649 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013650 }
13651 if (spec->autocfg.mono_out_pin)
13652 snd_hda_codec_write(codec, spec->autocfg.mono_out_pin, 0,
13653 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013654}
13655
Kailang Yanga361d842007-06-05 12:30:55 +020013656static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13657{
13658 struct alc_spec *spec = codec->spec;
13659 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13660 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13661 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13662 unsigned int dac_vol1, dac_vol2;
13663
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013664 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013665 snd_hda_codec_write(codec, speaker_nid, 0,
13666 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013667 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013668 snd_hda_codec_write(codec, 0x0f, 0,
13669 AC_VERB_SET_AMP_GAIN_MUTE,
13670 AMP_IN_UNMUTE(1));
13671 snd_hda_codec_write(codec, 0x10, 0,
13672 AC_VERB_SET_AMP_GAIN_MUTE,
13673 AMP_IN_UNMUTE(1));
13674 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013675 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013676 snd_hda_codec_write(codec, 0x0f, 0,
13677 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13678 snd_hda_codec_write(codec, 0x10, 0,
13679 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13680 }
13681
13682 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013683 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013684 dac_vol2 = AMP_OUT_ZERO;
13685 else if (line_nid == 0x15)
13686 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013687 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013688 dac_vol2 = AMP_OUT_ZERO;
13689 else if (hp_nid == 0x15)
13690 dac_vol1 = AMP_OUT_ZERO;
13691 if (line_nid != 0x16 || hp_nid != 0x16 ||
13692 spec->autocfg.line_out_pins[1] != 0x16 ||
13693 spec->autocfg.line_out_pins[2] != 0x16)
13694 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13695
13696 snd_hda_codec_write(codec, 0x02, 0,
13697 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13698 snd_hda_codec_write(codec, 0x03, 0,
13699 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13700}
13701
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013702/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013703#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13704#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013705#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013706#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13707
13708/*
13709 * BIOS auto configuration
13710 */
13711static int alc268_parse_auto_config(struct hda_codec *codec)
13712{
13713 struct alc_spec *spec = codec->spec;
13714 int err;
13715 static hda_nid_t alc268_ignore[] = { 0 };
13716
13717 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13718 alc268_ignore);
13719 if (err < 0)
13720 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013721 if (!spec->autocfg.line_outs) {
13722 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13723 spec->multiout.max_channels = 2;
13724 spec->no_analog = 1;
13725 goto dig_only;
13726 }
Kailang Yanga361d842007-06-05 12:30:55 +020013727 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013728 }
Kailang Yanga361d842007-06-05 12:30:55 +020013729 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13730 if (err < 0)
13731 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013732 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013733 if (err < 0)
13734 return err;
13735
13736 spec->multiout.max_channels = 2;
13737
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013738 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013739 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013740 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013741 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013742 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013743
Takashi Iwai892981f2009-03-02 08:04:35 +010013744 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013745 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013746
Takashi Iwaid88897e2008-10-31 15:01:37 +010013747 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013748 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013749 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013750
Takashi Iwai776e1842007-08-29 15:07:11 +020013751 err = alc_auto_add_mic_boost(codec);
13752 if (err < 0)
13753 return err;
13754
Kailang Yang6227cdc2010-02-25 08:36:52 +010013755 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013756
Kailang Yanga361d842007-06-05 12:30:55 +020013757 return 1;
13758}
13759
Kailang Yanga361d842007-06-05 12:30:55 +020013760#define alc268_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaiae0ebbf2011-03-10 14:11:59 +010013761#define alc268_auto_init_input_src alc882_auto_init_input_src
Kailang Yanga361d842007-06-05 12:30:55 +020013762
13763/* init callback for auto-configuration model -- overriding the default init */
13764static void alc268_auto_init(struct hda_codec *codec)
13765{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013766 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013767 alc268_auto_init_multi_out(codec);
13768 alc268_auto_init_hp_out(codec);
13769 alc268_auto_init_mono_speaker_out(codec);
13770 alc268_auto_init_analog_input(codec);
Takashi Iwaiae0ebbf2011-03-10 14:11:59 +010013771 alc268_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013772 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013773 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013774 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013775}
13776
13777/*
13778 * configuration and preset
13779 */
Takashi Iwaiea734962011-01-17 11:29:34 +010013780static const char * const alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013781 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013782 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013783 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013784 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013785 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013786 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013787 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013788 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013789#ifdef CONFIG_SND_DEBUG
13790 [ALC268_TEST] = "test",
13791#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013792 [ALC268_AUTO] = "auto",
13793};
13794
13795static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013796 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013797 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013798 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013799 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013800 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013801 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13802 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013803 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013804 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13805 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013806 /* almost compatible with toshiba but with optional digital outs;
13807 * auto-probing seems working fine
13808 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013809 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013810 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013811 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013812 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013813 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013814 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013815 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013816 {}
13817};
13818
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013819/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13820static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13821 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13822 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13823 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13824 ALC268_TOSHIBA),
13825 {}
13826};
13827
Kailang Yanga361d842007-06-05 12:30:55 +020013828static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013829 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013830 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13831 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013832 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13833 alc267_quanta_il1_verbs },
13834 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13835 .dac_nids = alc268_dac_nids,
13836 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13837 .adc_nids = alc268_adc_nids_alt,
13838 .hp_nid = 0x03,
13839 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13840 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013841 .unsol_event = alc_sku_unsol_event,
13842 .setup = alc267_quanta_il1_setup,
13843 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013844 },
Kailang Yanga361d842007-06-05 12:30:55 +020013845 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013846 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13847 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013848 .init_verbs = { alc268_base_init_verbs },
13849 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13850 .dac_nids = alc268_dac_nids,
13851 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13852 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013853 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013854 .hp_nid = 0x03,
13855 .dig_out_nid = ALC268_DIGOUT_NID,
13856 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13857 .channel_mode = alc268_modes,
13858 .input_mux = &alc268_capture_source,
13859 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013860 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013861 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013862 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013863 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13864 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013865 .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,
Takashi Iwaie1406342008-02-11 18:32:32 +010013869 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013870 .hp_nid = 0x03,
13871 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13872 .channel_mode = alc268_modes,
13873 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013874 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013875 .setup = alc268_toshiba_setup,
13876 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013877 },
13878 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013879 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013880 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013881 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13882 alc268_acer_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,
Takashi Iwaie1406342008-02-11 18:32:32 +010013887 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013888 .hp_nid = 0x02,
13889 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13890 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013891 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013892 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013893 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013894 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013895 [ALC268_ACER_DMIC] = {
13896 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13897 alc268_beep_mixer },
13898 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13899 alc268_acer_verbs },
13900 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13901 .dac_nids = alc268_dac_nids,
13902 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13903 .adc_nids = alc268_adc_nids_alt,
13904 .capsrc_nids = alc268_capsrc_nids,
13905 .hp_nid = 0x02,
13906 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13907 .channel_mode = alc268_modes,
13908 .input_mux = &alc268_acer_dmic_capture_source,
13909 .unsol_event = alc268_acer_unsol_event,
13910 .init_hook = alc268_acer_init_hook,
13911 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013912 [ALC268_ACER_ASPIRE_ONE] = {
13913 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013914 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013915 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013916 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13917 alc268_acer_aspire_one_verbs },
13918 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13919 .dac_nids = alc268_dac_nids,
13920 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13921 .adc_nids = alc268_adc_nids_alt,
13922 .capsrc_nids = alc268_capsrc_nids,
13923 .hp_nid = 0x03,
13924 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13925 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013926 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013927 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013928 .init_hook = alc268_acer_lc_init_hook,
13929 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013930 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013931 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13932 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013933 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13934 alc268_dell_verbs },
13935 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13936 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013937 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13938 .adc_nids = alc268_adc_nids_alt,
13939 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013940 .hp_nid = 0x02,
13941 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13942 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013943 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013944 .setup = alc268_dell_setup,
13945 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013946 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013947 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013948 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13949 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013950 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13951 alc268_toshiba_verbs },
13952 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13953 .dac_nids = alc268_dac_nids,
13954 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13955 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013956 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013957 .hp_nid = 0x03,
13958 .dig_out_nid = ALC268_DIGOUT_NID,
13959 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13960 .channel_mode = alc268_modes,
13961 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013962 .setup = alc268_toshiba_setup,
13963 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013964 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013965#ifdef CONFIG_SND_DEBUG
13966 [ALC268_TEST] = {
13967 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13968 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13969 alc268_volume_init_verbs },
13970 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13971 .dac_nids = alc268_dac_nids,
13972 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13973 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013974 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013975 .hp_nid = 0x03,
13976 .dig_out_nid = ALC268_DIGOUT_NID,
13977 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13978 .channel_mode = alc268_modes,
13979 .input_mux = &alc268_capture_source,
13980 },
13981#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013982};
13983
13984static int patch_alc268(struct hda_codec *codec)
13985{
13986 struct alc_spec *spec;
13987 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013988 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013989
Julia Lawallef86f582009-12-19 08:18:03 +010013990 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013991 if (spec == NULL)
13992 return -ENOMEM;
13993
13994 codec->spec = spec;
13995
13996 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13997 alc268_models,
13998 alc268_cfg_tbl);
13999
Takashi Iwai3abf2f32009-08-19 20:05:02 +020014000 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
14001 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010014002 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020014003
Kailang Yanga361d842007-06-05 12:30:55 +020014004 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014005 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14006 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020014007 board_config = ALC268_AUTO;
14008 }
14009
14010 if (board_config == ALC268_AUTO) {
14011 /* automatic parse from the BIOS config */
14012 err = alc268_parse_auto_config(codec);
14013 if (err < 0) {
14014 alc_free(codec);
14015 return err;
14016 } else if (!err) {
14017 printk(KERN_INFO
14018 "hda_codec: Cannot set up configuration "
14019 "from BIOS. Using base mode...\n");
14020 board_config = ALC268_3ST;
14021 }
14022 }
14023
14024 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014025 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020014026
Kailang Yanga361d842007-06-05 12:30:55 +020014027 spec->stream_analog_playback = &alc268_pcm_analog_playback;
14028 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010014029 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020014030
Kailang Yanga361d842007-06-05 12:30:55 +020014031 spec->stream_digital_playback = &alc268_pcm_digital_playback;
14032
Takashi Iwai22971e32009-02-10 11:56:44 +010014033 has_beep = 0;
14034 for (i = 0; i < spec->num_mixers; i++) {
14035 if (spec->mixers[i] == alc268_beep_mixer) {
14036 has_beep = 1;
14037 break;
14038 }
14039 }
14040
14041 if (has_beep) {
14042 err = snd_hda_attach_beep_device(codec, 0x1);
14043 if (err < 0) {
14044 alc_free(codec);
14045 return err;
14046 }
14047 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
14048 /* override the amp caps for beep generator */
14049 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014050 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
14051 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
14052 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
14053 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010014054 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014055
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014056 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014057 /* check whether NID 0x07 is valid */
14058 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010014059 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020014060
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014061 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014062 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020014063 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014064 if (spec->auto_mic ||
14065 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014066 spec->adc_nids = alc268_adc_nids_alt;
14067 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014068 if (spec->auto_mic)
14069 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014070 if (spec->auto_mic || spec->input_mux->num_items == 1)
14071 add_mixer(spec, alc268_capture_nosrc_mixer);
14072 else
14073 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014074 } else {
14075 spec->adc_nids = alc268_adc_nids;
14076 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010014077 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020014078 }
14079 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010014080
14081 spec->vmaster_nid = 0x02;
14082
Kailang Yanga361d842007-06-05 12:30:55 +020014083 codec->patch_ops = alc_patch_ops;
14084 if (board_config == ALC268_AUTO)
14085 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020014086
Kailang Yangbf1b0222010-10-21 08:49:56 +020014087 alc_init_jacks(codec);
14088
Kailang Yanga361d842007-06-05 12:30:55 +020014089 return 0;
14090}
14091
14092/*
Kailang Yangf6a92242007-12-13 16:52:54 +010014093 * ALC269 channel source setting (2 channel)
14094 */
14095#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
14096
14097#define alc269_dac_nids alc260_dac_nids
14098
14099static hda_nid_t alc269_adc_nids[1] = {
14100 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020014101 0x08,
14102};
14103
Takashi Iwaie01bf502008-08-21 16:25:07 +020014104static hda_nid_t alc269_capsrc_nids[1] = {
14105 0x23,
14106};
14107
Kailang Yang84898e82010-02-04 14:16:14 +010014108static hda_nid_t alc269vb_adc_nids[1] = {
14109 /* ADC1 */
14110 0x09,
14111};
14112
14113static hda_nid_t alc269vb_capsrc_nids[1] = {
14114 0x22,
14115};
14116
Takashi Iwai66946352010-03-29 17:21:45 +020014117static hda_nid_t alc269_adc_candidates[] = {
14118 0x08, 0x09, 0x07,
14119};
Takashi Iwaie01bf502008-08-21 16:25:07 +020014120
Kailang Yangf6a92242007-12-13 16:52:54 +010014121#define alc269_modes alc260_modes
14122#define alc269_capture_source alc880_lg_lw_capture_source
14123
14124static struct snd_kcontrol_new alc269_base_mixer[] = {
14125 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14126 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14127 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14128 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14129 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14130 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014131 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014132 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14133 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014134 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014135 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14136 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
14137 { } /* end */
14138};
14139
Kailang Yang60db6b52008-08-26 13:13:00 +020014140static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
14141 /* output mixer control */
14142 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14143 {
14144 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14145 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014146 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020014147 .info = snd_hda_mixer_amp_switch_info,
14148 .get = snd_hda_mixer_amp_switch_get,
14149 .put = alc268_acer_master_sw_put,
14150 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14151 },
14152 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14153 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014154 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014155 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14156 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014157 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014158 { }
14159};
14160
Tony Vroon64154832008-11-06 15:08:49 +000014161static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
14162 /* output mixer control */
14163 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14164 {
14165 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14166 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014167 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000014168 .info = snd_hda_mixer_amp_switch_info,
14169 .get = snd_hda_mixer_amp_switch_get,
14170 .put = alc268_acer_master_sw_put,
14171 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14172 },
14173 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14174 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014175 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014176 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14177 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014178 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014179 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
14180 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014181 HDA_CODEC_VOLUME("Dock Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014182 { }
14183};
14184
Kailang Yang84898e82010-02-04 14:16:14 +010014185static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020014186 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014187 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020014188 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014189 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020014190 { } /* end */
14191};
14192
Kailang Yang84898e82010-02-04 14:16:14 +010014193static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
14194 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14195 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14196 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14197 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14198 { } /* end */
14199};
14200
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014201static struct snd_kcontrol_new alc269_asus_mixer[] = {
14202 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14203 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
14204 { } /* end */
14205};
14206
Kailang Yangf6a92242007-12-13 16:52:54 +010014207/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010014208static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
14209 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14210 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014211 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14212 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014213 { } /* end */
14214};
14215
14216static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020014217 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14218 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014219 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010014220 { } /* end */
14221};
14222
Kailang Yang84898e82010-02-04 14:16:14 +010014223static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
14224 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14225 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014226 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14227 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014228 { } /* end */
14229};
14230
14231static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
14232 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14233 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014234 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014235 { } /* end */
14236};
14237
Takashi Iwai26f5df22008-11-03 17:39:46 +010014238/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010014239#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020014240
Kailang Yang60db6b52008-08-26 13:13:00 +020014241static struct hda_verb alc269_quanta_fl1_verbs[] = {
14242 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14243 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14244 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14245 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14246 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14247 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14248 { }
14249};
14250
Tony Vroon64154832008-11-06 15:08:49 +000014251static struct hda_verb alc269_lifebook_verbs[] = {
14252 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14253 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
14254 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14255 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14256 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14257 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14258 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14259 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14260 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14261 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14262 { }
14263};
14264
Kailang Yang60db6b52008-08-26 13:13:00 +020014265/* toggle speaker-output according to the hp-jack state */
14266static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
14267{
14268 unsigned int present;
14269 unsigned char bits;
14270
Wu Fengguang864f92b2009-11-18 12:38:02 +080014271 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014272 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014273 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014274 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014275 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014276 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014277
14278 snd_hda_codec_write(codec, 0x20, 0,
14279 AC_VERB_SET_COEF_INDEX, 0x0c);
14280 snd_hda_codec_write(codec, 0x20, 0,
14281 AC_VERB_SET_PROC_COEF, 0x680);
14282
14283 snd_hda_codec_write(codec, 0x20, 0,
14284 AC_VERB_SET_COEF_INDEX, 0x0c);
14285 snd_hda_codec_write(codec, 0x20, 0,
14286 AC_VERB_SET_PROC_COEF, 0x480);
14287}
14288
Tony Vroon64154832008-11-06 15:08:49 +000014289/* toggle speaker-output according to the hp-jacks state */
14290static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
14291{
14292 unsigned int present;
14293 unsigned char bits;
14294
14295 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014296 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000014297
14298 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014299 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000014300
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014301 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000014302 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014303 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014304 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014305 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014306
14307 snd_hda_codec_write(codec, 0x20, 0,
14308 AC_VERB_SET_COEF_INDEX, 0x0c);
14309 snd_hda_codec_write(codec, 0x20, 0,
14310 AC_VERB_SET_PROC_COEF, 0x680);
14311
14312 snd_hda_codec_write(codec, 0x20, 0,
14313 AC_VERB_SET_COEF_INDEX, 0x0c);
14314 snd_hda_codec_write(codec, 0x20, 0,
14315 AC_VERB_SET_PROC_COEF, 0x480);
14316}
14317
Tony Vroon64154832008-11-06 15:08:49 +000014318static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14319{
14320 unsigned int present_laptop;
14321 unsigned int present_dock;
14322
Wu Fengguang864f92b2009-11-18 12:38:02 +080014323 present_laptop = snd_hda_jack_detect(codec, 0x18);
14324 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014325
14326 /* Laptop mic port overrides dock mic port, design decision */
14327 if (present_dock)
14328 snd_hda_codec_write(codec, 0x23, 0,
14329 AC_VERB_SET_CONNECT_SEL, 0x3);
14330 if (present_laptop)
14331 snd_hda_codec_write(codec, 0x23, 0,
14332 AC_VERB_SET_CONNECT_SEL, 0x0);
14333 if (!present_dock && !present_laptop)
14334 snd_hda_codec_write(codec, 0x23, 0,
14335 AC_VERB_SET_CONNECT_SEL, 0x1);
14336}
14337
Kailang Yang60db6b52008-08-26 13:13:00 +020014338static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14339 unsigned int res)
14340{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014341 switch (res >> 26) {
14342 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014343 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014344 break;
14345 case ALC880_MIC_EVENT:
14346 alc_mic_automute(codec);
14347 break;
14348 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014349}
14350
Tony Vroon64154832008-11-06 15:08:49 +000014351static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14352 unsigned int res)
14353{
14354 if ((res >> 26) == ALC880_HP_EVENT)
14355 alc269_lifebook_speaker_automute(codec);
14356 if ((res >> 26) == ALC880_MIC_EVENT)
14357 alc269_lifebook_mic_autoswitch(codec);
14358}
14359
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014360static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14361{
14362 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014363 spec->autocfg.hp_pins[0] = 0x15;
14364 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014365 spec->ext_mic.pin = 0x18;
14366 spec->ext_mic.mux_idx = 0;
14367 spec->int_mic.pin = 0x19;
14368 spec->int_mic.mux_idx = 1;
14369 spec->auto_mic = 1;
14370}
14371
Kailang Yang60db6b52008-08-26 13:13:00 +020014372static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14373{
14374 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014375 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014376}
14377
Tony Vroon64154832008-11-06 15:08:49 +000014378static void alc269_lifebook_init_hook(struct hda_codec *codec)
14379{
14380 alc269_lifebook_speaker_automute(codec);
14381 alc269_lifebook_mic_autoswitch(codec);
14382}
14383
Kailang Yang84898e82010-02-04 14:16:14 +010014384static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014385 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14386 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14387 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14388 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14389 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14390 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14391 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14392 {}
14393};
14394
Kailang Yang84898e82010-02-04 14:16:14 +010014395static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014396 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14397 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14398 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14399 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14400 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14401 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14402 {}
14403};
14404
Kailang Yang84898e82010-02-04 14:16:14 +010014405static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14406 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14407 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14408 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14409 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14410 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14411 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14412 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14413 {}
14414};
14415
14416static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14417 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14418 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14419 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14420 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14421 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14422 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14423 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14424 {}
14425};
14426
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014427static struct hda_verb alc271_acer_dmic_verbs[] = {
14428 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14429 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14430 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14431 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14432 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14433 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14434 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14435 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14436 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14437 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14438 { }
14439};
14440
Kailang Yang60db6b52008-08-26 13:13:00 +020014441/* toggle speaker-output according to the hp-jack state */
14442static void alc269_speaker_automute(struct hda_codec *codec)
14443{
Kailang Yangebb83ee2009-12-17 12:23:00 +010014444 struct alc_spec *spec = codec->spec;
14445 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020014446 unsigned int present;
14447 unsigned char bits;
14448
Kailang Yangebb83ee2009-12-17 12:23:00 +010014449 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014450 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014451 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014452 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014453 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014454 HDA_AMP_MUTE, bits);
Takashi Iwaicd372fb2011-03-03 14:40:14 +010014455 snd_hda_input_jack_report(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020014456}
14457
Kailang Yang60db6b52008-08-26 13:13:00 +020014458/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010014459static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020014460 unsigned int res)
14461{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014462 switch (res >> 26) {
14463 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014464 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014465 break;
14466 case ALC880_MIC_EVENT:
14467 alc_mic_automute(codec);
14468 break;
14469 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014470}
14471
Kailang Yang226b1ec2010-04-09 11:01:20 +020014472static void alc269_laptop_amic_setup(struct hda_codec *codec)
14473{
14474 struct alc_spec *spec = codec->spec;
14475 spec->autocfg.hp_pins[0] = 0x15;
14476 spec->autocfg.speaker_pins[0] = 0x14;
14477 spec->ext_mic.pin = 0x18;
14478 spec->ext_mic.mux_idx = 0;
14479 spec->int_mic.pin = 0x19;
14480 spec->int_mic.mux_idx = 1;
14481 spec->auto_mic = 1;
14482}
14483
Kailang Yang84898e82010-02-04 14:16:14 +010014484static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014485{
14486 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014487 spec->autocfg.hp_pins[0] = 0x15;
14488 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014489 spec->ext_mic.pin = 0x18;
14490 spec->ext_mic.mux_idx = 0;
14491 spec->int_mic.pin = 0x12;
14492 spec->int_mic.mux_idx = 5;
14493 spec->auto_mic = 1;
14494}
14495
Kailang Yang226b1ec2010-04-09 11:01:20 +020014496static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014497{
14498 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014499 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014500 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014501 spec->ext_mic.pin = 0x18;
14502 spec->ext_mic.mux_idx = 0;
14503 spec->int_mic.pin = 0x19;
14504 spec->int_mic.mux_idx = 1;
14505 spec->auto_mic = 1;
14506}
14507
Kailang Yang226b1ec2010-04-09 11:01:20 +020014508static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14509{
14510 struct alc_spec *spec = codec->spec;
14511 spec->autocfg.hp_pins[0] = 0x21;
14512 spec->autocfg.speaker_pins[0] = 0x14;
14513 spec->ext_mic.pin = 0x18;
14514 spec->ext_mic.mux_idx = 0;
14515 spec->int_mic.pin = 0x12;
14516 spec->int_mic.mux_idx = 6;
14517 spec->auto_mic = 1;
14518}
14519
Kailang Yang84898e82010-02-04 14:16:14 +010014520static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020014521{
14522 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014523 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014524}
14525
Kailang Yangf6a92242007-12-13 16:52:54 +010014526/*
14527 * generic initialization of ADC, input mixers and output mixers
14528 */
14529static struct hda_verb alc269_init_verbs[] = {
14530 /*
14531 * Unmute ADC0 and set the default input to mic-in
14532 */
Kailang Yang84898e82010-02-04 14:16:14 +010014533 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014534
14535 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014536 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014537 */
14538 /* set vol=0 to output mixers */
14539 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14540 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14541
14542 /* set up input amps for analog loopback */
14543 /* Amp Indices: DAC = 0, mixer = 1 */
14544 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14545 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14546 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14547 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14548 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14549 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14550
14551 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14552 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14553 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14554 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14555 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14556 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14557 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14558
14559 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14560 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014561
Kailang Yang84898e82010-02-04 14:16:14 +010014562 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014563 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14564 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014565 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014566
14567 /* set EAPD */
14568 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014569 { }
14570};
14571
14572static struct hda_verb alc269vb_init_verbs[] = {
14573 /*
14574 * Unmute ADC0 and set the default input to mic-in
14575 */
14576 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14577
14578 /*
14579 * Set up output mixers (0x02 - 0x03)
14580 */
14581 /* set vol=0 to output mixers */
14582 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14583 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14584
14585 /* set up input amps for analog loopback */
14586 /* Amp Indices: DAC = 0, mixer = 1 */
14587 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14588 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14589 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14590 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14591 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14592 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14593
14594 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14595 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14596 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14597 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14598 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14599 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14600 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14601
14602 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14603 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14604
14605 /* FIXME: use Mux-type input source selection */
14606 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14607 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14608 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14609
14610 /* set EAPD */
14611 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014612 { }
14613};
14614
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014615#define alc269_auto_create_multi_out_ctls \
14616 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014617#define alc269_auto_create_input_ctls \
14618 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014619
14620#ifdef CONFIG_SND_HDA_POWER_SAVE
14621#define alc269_loopbacks alc880_loopbacks
14622#endif
14623
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014624/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014625#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14626#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14627#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14628#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14629
Takashi Iwaif03d3112009-03-05 14:18:16 +010014630static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14631 .substreams = 1,
14632 .channels_min = 2,
14633 .channels_max = 8,
14634 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14635 /* NID is set in alc_build_pcms */
14636 .ops = {
14637 .open = alc880_playback_pcm_open,
14638 .prepare = alc880_playback_pcm_prepare,
14639 .cleanup = alc880_playback_pcm_cleanup
14640 },
14641};
14642
14643static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14644 .substreams = 1,
14645 .channels_min = 2,
14646 .channels_max = 2,
14647 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14648 /* NID is set in alc_build_pcms */
14649};
14650
Takashi Iwaiad358792010-03-30 18:00:59 +020014651#ifdef CONFIG_SND_HDA_POWER_SAVE
14652static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14653{
14654 switch (codec->subsystem_id) {
14655 case 0x103c1586:
14656 return 1;
14657 }
14658 return 0;
14659}
14660
14661static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14662{
14663 /* update mute-LED according to the speaker mute state */
14664 if (nid == 0x01 || nid == 0x14) {
14665 int pinval;
14666 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14667 HDA_AMP_MUTE)
14668 pinval = 0x24;
14669 else
14670 pinval = 0x20;
14671 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a542010-03-30 18:03:44 +020014672 snd_hda_codec_update_cache(codec, 0x19, 0,
14673 AC_VERB_SET_PIN_WIDGET_CONTROL,
14674 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014675 }
14676 return alc_check_power_status(codec, nid);
14677}
14678#endif /* CONFIG_SND_HDA_POWER_SAVE */
14679
Takashi Iwai840b64c2010-07-13 22:49:01 +020014680static int alc275_setup_dual_adc(struct hda_codec *codec)
14681{
14682 struct alc_spec *spec = codec->spec;
14683
14684 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14685 return 0;
14686 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14687 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14688 if (spec->ext_mic.pin <= 0x12) {
14689 spec->private_adc_nids[0] = 0x08;
14690 spec->private_adc_nids[1] = 0x11;
14691 spec->private_capsrc_nids[0] = 0x23;
14692 spec->private_capsrc_nids[1] = 0x22;
14693 } else {
14694 spec->private_adc_nids[0] = 0x11;
14695 spec->private_adc_nids[1] = 0x08;
14696 spec->private_capsrc_nids[0] = 0x22;
14697 spec->private_capsrc_nids[1] = 0x23;
14698 }
14699 spec->adc_nids = spec->private_adc_nids;
14700 spec->capsrc_nids = spec->private_capsrc_nids;
14701 spec->num_adc_nids = 2;
14702 spec->dual_adc_switch = 1;
14703 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14704 spec->adc_nids[0], spec->adc_nids[1]);
14705 return 1;
14706 }
14707 return 0;
14708}
14709
Takashi Iwaid433a672010-09-20 15:11:54 +020014710/* different alc269-variants */
14711enum {
14712 ALC269_TYPE_NORMAL,
Kailang Yang48c88e82010-11-23 08:56:16 +010014713 ALC269_TYPE_ALC258,
Takashi Iwaid433a672010-09-20 15:11:54 +020014714 ALC269_TYPE_ALC259,
Kailang Yang48c88e82010-11-23 08:56:16 +010014715 ALC269_TYPE_ALC269VB,
14716 ALC269_TYPE_ALC270,
Takashi Iwaid433a672010-09-20 15:11:54 +020014717 ALC269_TYPE_ALC271X,
14718};
14719
Kailang Yangf6a92242007-12-13 16:52:54 +010014720/*
14721 * BIOS auto configuration
14722 */
14723static int alc269_parse_auto_config(struct hda_codec *codec)
14724{
14725 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014726 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014727 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14728
14729 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14730 alc269_ignore);
14731 if (err < 0)
14732 return err;
14733
14734 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14735 if (err < 0)
14736 return err;
Takashi Iwaif3550d12010-09-20 15:09:03 +020014737 if (spec->codec_variant == ALC269_TYPE_NORMAL)
14738 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
14739 else
14740 err = alc_auto_create_input_ctls(codec, &spec->autocfg, 0,
14741 0x22, 0);
Kailang Yangf6a92242007-12-13 16:52:54 +010014742 if (err < 0)
14743 return err;
14744
14745 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14746
Takashi Iwai757899a2010-07-30 10:48:14 +020014747 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014748
Takashi Iwai603c4012008-07-30 15:01:44 +020014749 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014750 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014751
Takashi Iwaid433a672010-09-20 15:11:54 +020014752 if (spec->codec_variant != ALC269_TYPE_NORMAL) {
Kailang Yang84898e82010-02-04 14:16:14 +010014753 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014754 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014755 } else {
14756 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014757 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014758 }
14759
Kailang Yangf6a92242007-12-13 16:52:54 +010014760 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014761 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014762
14763 if (!alc275_setup_dual_adc(codec))
14764 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14765 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014766
Kailang Yangf6a92242007-12-13 16:52:54 +010014767 err = alc_auto_add_mic_boost(codec);
14768 if (err < 0)
14769 return err;
14770
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014771 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014772 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014773
Kailang Yangf6a92242007-12-13 16:52:54 +010014774 return 1;
14775}
14776
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014777#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14778#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014779#define alc269_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaiae0ebbf2011-03-10 14:11:59 +010014780#define alc269_auto_init_input_src alc882_auto_init_input_src
Kailang Yangf6a92242007-12-13 16:52:54 +010014781
14782
14783/* init callback for auto-configuration model -- overriding the default init */
14784static void alc269_auto_init(struct hda_codec *codec)
14785{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014786 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014787 alc269_auto_init_multi_out(codec);
14788 alc269_auto_init_hp_out(codec);
14789 alc269_auto_init_analog_input(codec);
Takashi Iwaiae0ebbf2011-03-10 14:11:59 +010014790 if (!spec->dual_adc_switch)
14791 alc269_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014792 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014793 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014794 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014795}
14796
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014797#ifdef SND_HDA_NEEDS_RESUME
14798static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
14799{
14800 int val = alc_read_coef_idx(codec, 0x04);
14801 if (power_up)
14802 val |= 1 << 11;
14803 else
14804 val &= ~(1 << 11);
14805 alc_write_coef_idx(codec, 0x04, val);
14806}
14807
Kailang Yang977ddd62010-09-15 10:02:29 +020014808#ifdef CONFIG_SND_HDA_POWER_SAVE
14809static int alc269_suspend(struct hda_codec *codec, pm_message_t state)
14810{
14811 struct alc_spec *spec = codec->spec;
Kailang Yang977ddd62010-09-15 10:02:29 +020014812
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014813 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017)
14814 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014815 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014816 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014817 msleep(150);
14818 }
14819
14820 alc_shutup(codec);
14821 if (spec && spec->power_hook)
14822 spec->power_hook(codec);
14823 return 0;
14824}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014825#endif /* CONFIG_SND_HDA_POWER_SAVE */
14826
Kailang Yang977ddd62010-09-15 10:02:29 +020014827static int alc269_resume(struct hda_codec *codec)
14828{
Kailang Yang977ddd62010-09-15 10:02:29 +020014829 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014830 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014831 msleep(150);
14832 }
14833
14834 codec->patch_ops.init(codec);
14835
14836 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014837 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014838 msleep(200);
14839 }
14840
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014841 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018)
14842 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014843
14844 snd_hda_codec_resume_amp(codec);
14845 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +020014846 hda_call_check_power_status(codec, 0x01);
Kailang Yang977ddd62010-09-15 10:02:29 +020014847 return 0;
14848}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014849#endif /* SND_HDA_NEEDS_RESUME */
Kailang Yang977ddd62010-09-15 10:02:29 +020014850
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014851static void alc269_fixup_hweq(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014852 const struct alc_fixup *fix, int action)
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014853{
14854 int coef;
14855
Takashi Iwai58701122011-01-13 15:41:45 +010014856 if (action != ALC_FIXUP_ACT_INIT)
Takashi Iwai9fb1ef22011-01-13 14:40:43 +010014857 return;
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014858 coef = alc_read_coef_idx(codec, 0x1e);
14859 alc_write_coef_idx(codec, 0x1e, coef | 0x80);
14860}
14861
Takashi Iwaiff818c22010-04-12 08:59:25 +020014862enum {
14863 ALC269_FIXUP_SONY_VAIO,
Takashi Iwai74dc8902011-01-13 14:14:41 +010014864 ALC275_FIXUP_SONY_VAIO_GPIO2,
David Henningsson145a9022010-09-16 10:07:53 +020014865 ALC269_FIXUP_DELL_M101Z,
David Henningsson022c92b2010-12-17 20:43:04 +010014866 ALC269_FIXUP_SKU_IGNORE,
David Henningssonac612402010-12-15 09:18:18 +010014867 ALC269_FIXUP_ASUS_G73JW,
Kailang Yang357f9152011-01-12 08:12:52 +010014868 ALC269_FIXUP_LENOVO_EAPD,
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014869 ALC275_FIXUP_SONY_HWEQ,
Takashi Iwaiff818c22010-04-12 08:59:25 +020014870};
14871
Takashi Iwaiff818c22010-04-12 08:59:25 +020014872static const struct alc_fixup alc269_fixups[] = {
14873 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014874 .type = ALC_FIXUP_VERBS,
14875 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020014876 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14877 {}
14878 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014879 },
Takashi Iwai74dc8902011-01-13 14:14:41 +010014880 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014881 .type = ALC_FIXUP_VERBS,
14882 .v.verbs = (const struct hda_verb[]) {
Kailang Yang27855912010-12-21 09:09:53 +010014883 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
14884 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
14885 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
14886 { }
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014887 },
14888 .chained = true,
14889 .chain_id = ALC269_FIXUP_SONY_VAIO
Kailang Yang27855912010-12-21 09:09:53 +010014890 },
David Henningsson145a9022010-09-16 10:07:53 +020014891 [ALC269_FIXUP_DELL_M101Z] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014892 .type = ALC_FIXUP_VERBS,
14893 .v.verbs = (const struct hda_verb[]) {
David Henningsson145a9022010-09-16 10:07:53 +020014894 /* Enables internal speaker */
14895 {0x20, AC_VERB_SET_COEF_INDEX, 13},
14896 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
14897 {}
14898 }
14899 },
David Henningsson022c92b2010-12-17 20:43:04 +010014900 [ALC269_FIXUP_SKU_IGNORE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014901 .type = ALC_FIXUP_SKU,
14902 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonfe67b242010-12-15 08:01:46 +010014903 },
David Henningssonac612402010-12-15 09:18:18 +010014904 [ALC269_FIXUP_ASUS_G73JW] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014905 .type = ALC_FIXUP_PINS,
14906 .v.pins = (const struct alc_pincfg[]) {
David Henningssonac612402010-12-15 09:18:18 +010014907 { 0x17, 0x99130111 }, /* subwoofer */
14908 { }
14909 }
14910 },
Kailang Yang357f9152011-01-12 08:12:52 +010014911 [ALC269_FIXUP_LENOVO_EAPD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014912 .type = ALC_FIXUP_VERBS,
14913 .v.verbs = (const struct hda_verb[]) {
Kailang Yang357f9152011-01-12 08:12:52 +010014914 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
14915 {}
14916 }
14917 },
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014918 [ALC275_FIXUP_SONY_HWEQ] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014919 .type = ALC_FIXUP_FUNC,
14920 .v.func = alc269_fixup_hweq,
14921 .chained = true,
14922 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014923 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014924};
14925
14926static struct snd_pci_quirk alc269_fixup_tbl[] = {
Takashi Iwai74dc8902011-01-13 14:14:41 +010014927 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014928 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
14929 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
Takashi Iwai7039c742010-12-23 16:35:34 +010014930 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningsson145a9022010-09-16 10:07:53 +020014931 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
David Henningsson022c92b2010-12-17 20:43:04 +010014932 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
David Henningssonded9f522011-01-26 11:46:12 +010014933 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
14934 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
14935 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
14936 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
David Henningssonac612402010-12-15 09:18:18 +010014937 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
Kailang Yang357f9152011-01-12 08:12:52 +010014938 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014939 {}
14940};
14941
14942
Kailang Yangf6a92242007-12-13 16:52:54 +010014943/*
14944 * configuration and preset
14945 */
Takashi Iwaiea734962011-01-17 11:29:34 +010014946static const char * const alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014947 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014948 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014949 [ALC269_AMIC] = "laptop-amic",
14950 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014951 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014952 [ALC269_LIFEBOOK] = "lifebook",
14953 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014954};
14955
14956static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014957 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014958 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014959 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014960 ALC269_AMIC),
14961 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14962 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14963 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14964 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14965 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14966 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14967 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14968 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14969 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
Chih-Wei Huangc790ad32011-02-25 11:14:31 +080014970 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269VB_AMIC),
Kailang Yang84898e82010-02-04 14:16:14 +010014971 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14972 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14973 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14974 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14975 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14976 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14977 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14978 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14979 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14980 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14981 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14982 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14983 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14984 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14985 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14986 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14987 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14988 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14989 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14990 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14991 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14992 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14993 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14994 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14995 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14996 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014997 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014998 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014999 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010015000 ALC269_DMIC),
15001 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
15002 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020015003 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000015004 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010015005 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
15006 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
15007 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
15008 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
15009 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
15010 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010015011 {}
15012};
15013
15014static struct alc_config_preset alc269_presets[] = {
15015 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015016 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010015017 .init_verbs = { alc269_init_verbs },
15018 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15019 .dac_nids = alc269_dac_nids,
15020 .hp_nid = 0x03,
15021 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15022 .channel_mode = alc269_modes,
15023 .input_mux = &alc269_capture_source,
15024 },
Kailang Yang60db6b52008-08-26 13:13:00 +020015025 [ALC269_QUANTA_FL1] = {
15026 .mixers = { alc269_quanta_fl1_mixer },
15027 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
15028 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15029 .dac_nids = alc269_dac_nids,
15030 .hp_nid = 0x03,
15031 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15032 .channel_mode = alc269_modes,
15033 .input_mux = &alc269_capture_source,
15034 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015035 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020015036 .init_hook = alc269_quanta_fl1_init_hook,
15037 },
Kailang Yang84898e82010-02-04 14:16:14 +010015038 [ALC269_AMIC] = {
15039 .mixers = { alc269_laptop_mixer },
15040 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020015041 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015042 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015043 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15044 .dac_nids = alc269_dac_nids,
15045 .hp_nid = 0x03,
15046 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15047 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015048 .unsol_event = alc269_laptop_unsol_event,
15049 .setup = alc269_laptop_amic_setup,
15050 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015051 },
Kailang Yang84898e82010-02-04 14:16:14 +010015052 [ALC269_DMIC] = {
15053 .mixers = { alc269_laptop_mixer },
15054 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020015055 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015056 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015057 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15058 .dac_nids = alc269_dac_nids,
15059 .hp_nid = 0x03,
15060 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15061 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015062 .unsol_event = alc269_laptop_unsol_event,
15063 .setup = alc269_laptop_dmic_setup,
15064 .init_hook = alc269_laptop_inithook,
15065 },
15066 [ALC269VB_AMIC] = {
15067 .mixers = { alc269vb_laptop_mixer },
15068 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
15069 .init_verbs = { alc269vb_init_verbs,
15070 alc269vb_laptop_amic_init_verbs },
15071 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15072 .dac_nids = alc269_dac_nids,
15073 .hp_nid = 0x03,
15074 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15075 .channel_mode = alc269_modes,
15076 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020015077 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010015078 .init_hook = alc269_laptop_inithook,
15079 },
15080 [ALC269VB_DMIC] = {
15081 .mixers = { alc269vb_laptop_mixer },
15082 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15083 .init_verbs = { alc269vb_init_verbs,
15084 alc269vb_laptop_dmic_init_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 .unsol_event = alc269_laptop_unsol_event,
15091 .setup = alc269vb_laptop_dmic_setup,
15092 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015093 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015094 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015095 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010015096 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015097 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015098 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015099 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15100 .dac_nids = alc269_dac_nids,
15101 .hp_nid = 0x03,
15102 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15103 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015104 .unsol_event = alc269_laptop_unsol_event,
15105 .setup = alc269_laptop_dmic_setup,
15106 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015107 },
Tony Vroon64154832008-11-06 15:08:49 +000015108 [ALC269_LIFEBOOK] = {
15109 .mixers = { alc269_lifebook_mixer },
15110 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
15111 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15112 .dac_nids = alc269_dac_nids,
15113 .hp_nid = 0x03,
15114 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15115 .channel_mode = alc269_modes,
15116 .input_mux = &alc269_capture_source,
15117 .unsol_event = alc269_lifebook_unsol_event,
15118 .init_hook = alc269_lifebook_init_hook,
15119 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020015120 [ALC271_ACER] = {
15121 .mixers = { alc269_asus_mixer },
15122 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15123 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
15124 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15125 .dac_nids = alc269_dac_nids,
15126 .adc_nids = alc262_dmic_adc_nids,
15127 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
15128 .capsrc_nids = alc262_dmic_capsrc_nids,
15129 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15130 .channel_mode = alc269_modes,
15131 .input_mux = &alc269_capture_source,
15132 .dig_out_nid = ALC880_DIGOUT_NID,
15133 .unsol_event = alc_sku_unsol_event,
15134 .setup = alc269vb_laptop_dmic_setup,
15135 .init_hook = alc_inithook,
15136 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015137};
15138
Kailang Yang977ddd62010-09-15 10:02:29 +020015139static int alc269_fill_coef(struct hda_codec *codec)
15140{
15141 int val;
15142
15143 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
15144 alc_write_coef_idx(codec, 0xf, 0x960b);
15145 alc_write_coef_idx(codec, 0xe, 0x8817);
15146 }
15147
15148 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
15149 alc_write_coef_idx(codec, 0xf, 0x960b);
15150 alc_write_coef_idx(codec, 0xe, 0x8814);
15151 }
15152
15153 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
15154 val = alc_read_coef_idx(codec, 0x04);
15155 /* Power up output pin */
15156 alc_write_coef_idx(codec, 0x04, val | (1<<11));
15157 }
15158
15159 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
15160 val = alc_read_coef_idx(codec, 0xd);
15161 if ((val & 0x0c00) >> 10 != 0x1) {
15162 /* Capless ramp up clock control */
15163 alc_write_coef_idx(codec, 0xd, val | 1<<10);
15164 }
15165 val = alc_read_coef_idx(codec, 0x17);
15166 if ((val & 0x01c0) >> 6 != 0x4) {
15167 /* Class D power on reset */
15168 alc_write_coef_idx(codec, 0x17, val | 1<<7);
15169 }
15170 }
15171 return 0;
15172}
15173
Kailang Yangf6a92242007-12-13 16:52:54 +010015174static int patch_alc269(struct hda_codec *codec)
15175{
15176 struct alc_spec *spec;
Kailang Yang48c88e82010-11-23 08:56:16 +010015177 int board_config, coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010015178 int err;
15179
15180 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15181 if (spec == NULL)
15182 return -ENOMEM;
15183
15184 codec->spec = spec;
15185
Kailang Yangda00c242010-03-19 11:23:45 +010015186 alc_auto_parse_customize_define(codec);
15187
Kailang Yangc793bec2010-12-21 09:14:13 +010015188 if (codec->vendor_id == 0x10ec0269) {
15189 coef = alc_read_coef_idx(codec, 0);
15190 if ((coef & 0x00f0) == 0x0010) {
15191 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
15192 spec->cdefine.platform_type == 1) {
15193 alc_codec_rename(codec, "ALC271X");
15194 spec->codec_variant = ALC269_TYPE_ALC271X;
15195 } else if ((coef & 0xf000) == 0x1000) {
15196 spec->codec_variant = ALC269_TYPE_ALC270;
15197 } else if ((coef & 0xf000) == 0x2000) {
15198 alc_codec_rename(codec, "ALC259");
15199 spec->codec_variant = ALC269_TYPE_ALC259;
15200 } else if ((coef & 0xf000) == 0x3000) {
15201 alc_codec_rename(codec, "ALC258");
15202 spec->codec_variant = ALC269_TYPE_ALC258;
15203 } else {
15204 alc_codec_rename(codec, "ALC269VB");
15205 spec->codec_variant = ALC269_TYPE_ALC269VB;
15206 }
15207 } else
15208 alc_fix_pll_init(codec, 0x20, 0x04, 15);
15209 alc269_fill_coef(codec);
15210 }
Kailang Yang977ddd62010-09-15 10:02:29 +020015211
Kailang Yangf6a92242007-12-13 16:52:54 +010015212 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
15213 alc269_models,
15214 alc269_cfg_tbl);
15215
15216 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015217 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15218 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010015219 board_config = ALC269_AUTO;
15220 }
15221
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015222 if (board_config == ALC269_AUTO) {
15223 alc_pick_fixup(codec, NULL, alc269_fixup_tbl, alc269_fixups);
15224 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
15225 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020015226
Kailang Yangf6a92242007-12-13 16:52:54 +010015227 if (board_config == ALC269_AUTO) {
15228 /* automatic parse from the BIOS config */
15229 err = alc269_parse_auto_config(codec);
15230 if (err < 0) {
15231 alc_free(codec);
15232 return err;
15233 } else if (!err) {
15234 printk(KERN_INFO
15235 "hda_codec: Cannot set up configuration "
15236 "from BIOS. Using base mode...\n");
15237 board_config = ALC269_BASIC;
15238 }
15239 }
15240
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015241 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020015242 err = snd_hda_attach_beep_device(codec, 0x1);
15243 if (err < 0) {
15244 alc_free(codec);
15245 return err;
15246 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015247 }
15248
Kailang Yangf6a92242007-12-13 16:52:54 +010015249 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015250 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010015251
Kailang Yang84898e82010-02-04 14:16:14 +010015252 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010015253 /* Due to a hardware problem on Lenovo Ideadpad, we need to
15254 * fix the sample rate of analog I/O to 44.1kHz
15255 */
15256 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
15257 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020015258 } else if (spec->dual_adc_switch) {
15259 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15260 /* switch ADC dynamically */
15261 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010015262 } else {
15263 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15264 spec->stream_analog_capture = &alc269_pcm_analog_capture;
15265 }
Kailang Yangf6a92242007-12-13 16:52:54 +010015266 spec->stream_digital_playback = &alc269_pcm_digital_playback;
15267 spec->stream_digital_capture = &alc269_pcm_digital_capture;
15268
Takashi Iwai66946352010-03-29 17:21:45 +020015269 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
Kailang Yang1657cbd2010-11-23 08:53:32 +010015270 if (spec->codec_variant == ALC269_TYPE_NORMAL) {
Takashi Iwai66946352010-03-29 17:21:45 +020015271 spec->adc_nids = alc269_adc_nids;
15272 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
15273 spec->capsrc_nids = alc269_capsrc_nids;
15274 } else {
15275 spec->adc_nids = alc269vb_adc_nids;
15276 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
15277 spec->capsrc_nids = alc269vb_capsrc_nids;
15278 }
Kailang Yang84898e82010-02-04 14:16:14 +010015279 }
15280
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015281 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015282 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015283 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010015284 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010015285
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015286 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaiff818c22010-04-12 08:59:25 +020015287
Takashi Iwai100d5eb2009-08-10 11:55:51 +020015288 spec->vmaster_nid = 0x02;
15289
Kailang Yangf6a92242007-12-13 16:52:54 +010015290 codec->patch_ops = alc_patch_ops;
Kailang Yang977ddd62010-09-15 10:02:29 +020015291#ifdef CONFIG_SND_HDA_POWER_SAVE
15292 codec->patch_ops.suspend = alc269_suspend;
15293#endif
15294#ifdef SND_HDA_NEEDS_RESUME
15295 codec->patch_ops.resume = alc269_resume;
15296#endif
Kailang Yangf6a92242007-12-13 16:52:54 +010015297 if (board_config == ALC269_AUTO)
15298 spec->init_hook = alc269_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020015299
15300 alc_init_jacks(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010015301#ifdef CONFIG_SND_HDA_POWER_SAVE
15302 if (!spec->loopback.amplist)
15303 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020015304 if (alc269_mic2_for_mute_led(codec))
15305 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010015306#endif
15307
15308 return 0;
15309}
15310
15311/*
Kailang Yangdf694da2005-12-05 19:42:22 +010015312 * ALC861 channel source setting (2/6 channel selection for 3-stack)
15313 */
15314
15315/*
15316 * set the path ways for 2 channel output
15317 * need to set the codec line out and mic 1 pin widgets to inputs
15318 */
15319static struct hda_verb alc861_threestack_ch2_init[] = {
15320 /* set pin widget 1Ah (line in) for input */
15321 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015322 /* set pin widget 18h (mic1/2) for input, for mic also enable
15323 * the vref
15324 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015325 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15326
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015327 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15328#if 0
15329 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15330 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15331#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015332 { } /* end */
15333};
15334/*
15335 * 6ch mode
15336 * need to set the codec line out and mic 1 pin widgets to outputs
15337 */
15338static struct hda_verb alc861_threestack_ch6_init[] = {
15339 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15340 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15341 /* set pin widget 18h (mic1) for output (CLFE)*/
15342 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15343
15344 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015345 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015346
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015347 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15348#if 0
15349 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15350 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15351#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015352 { } /* end */
15353};
15354
15355static struct hda_channel_mode alc861_threestack_modes[2] = {
15356 { 2, alc861_threestack_ch2_init },
15357 { 6, alc861_threestack_ch6_init },
15358};
Takashi Iwai22309c32006-08-09 16:57:28 +020015359/* Set mic1 as input and unmute the mixer */
15360static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
15361 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15362 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15363 { } /* end */
15364};
15365/* Set mic1 as output and mute mixer */
15366static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
15367 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15368 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15369 { } /* end */
15370};
15371
15372static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
15373 { 2, alc861_uniwill_m31_ch2_init },
15374 { 4, alc861_uniwill_m31_ch4_init },
15375};
Kailang Yangdf694da2005-12-05 19:42:22 +010015376
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015377/* Set mic1 and line-in as input and unmute the mixer */
15378static struct hda_verb alc861_asus_ch2_init[] = {
15379 /* set pin widget 1Ah (line in) for input */
15380 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015381 /* set pin widget 18h (mic1/2) for input, for mic also enable
15382 * the vref
15383 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015384 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15385
15386 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15387#if 0
15388 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15389 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15390#endif
15391 { } /* end */
15392};
15393/* Set mic1 nad line-in as output and mute mixer */
15394static struct hda_verb alc861_asus_ch6_init[] = {
15395 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15396 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15397 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15398 /* set pin widget 18h (mic1) for output (CLFE)*/
15399 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15400 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15401 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
15402 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
15403
15404 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15405#if 0
15406 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15407 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15408#endif
15409 { } /* end */
15410};
15411
15412static struct hda_channel_mode alc861_asus_modes[2] = {
15413 { 2, alc861_asus_ch2_init },
15414 { 6, alc861_asus_ch6_init },
15415};
15416
Kailang Yangdf694da2005-12-05 19:42:22 +010015417/* patch-ALC861 */
15418
15419static struct snd_kcontrol_new alc861_base_mixer[] = {
15420 /* output mixer control */
15421 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15422 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15423 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15424 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15425 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15426
15427 /*Input mixer control */
15428 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15429 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15430 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15431 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15432 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15433 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15434 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15435 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15436 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15437 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015438
Kailang Yangdf694da2005-12-05 19:42:22 +010015439 { } /* end */
15440};
15441
15442static struct snd_kcontrol_new alc861_3ST_mixer[] = {
15443 /* output mixer control */
15444 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15445 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15446 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15447 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15448 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15449
15450 /* Input mixer control */
15451 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15452 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15453 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15454 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15455 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15456 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15457 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15458 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15459 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15460 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015461
Kailang Yangdf694da2005-12-05 19:42:22 +010015462 {
15463 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15464 .name = "Channel Mode",
15465 .info = alc_ch_mode_info,
15466 .get = alc_ch_mode_get,
15467 .put = alc_ch_mode_put,
15468 .private_value = ARRAY_SIZE(alc861_threestack_modes),
15469 },
15470 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015471};
15472
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015473static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015474 /* output mixer control */
15475 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15476 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15477 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015478
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015479 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015480};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015481
Takashi Iwai22309c32006-08-09 16:57:28 +020015482static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
15483 /* output mixer control */
15484 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15485 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15486 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15487 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15488 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15489
15490 /* Input mixer control */
15491 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15492 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15493 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15494 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15495 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15496 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15497 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15498 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15499 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15500 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015501
Takashi Iwai22309c32006-08-09 16:57:28 +020015502 {
15503 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15504 .name = "Channel Mode",
15505 .info = alc_ch_mode_info,
15506 .get = alc_ch_mode_get,
15507 .put = alc_ch_mode_put,
15508 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15509 },
15510 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015511};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015512
15513static struct snd_kcontrol_new alc861_asus_mixer[] = {
15514 /* output mixer control */
15515 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15516 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15517 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15518 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15519 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15520
15521 /* Input mixer control */
15522 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15523 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15524 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15525 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15526 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15527 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15528 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15529 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15530 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015531 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15532
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015533 {
15534 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15535 .name = "Channel Mode",
15536 .info = alc_ch_mode_info,
15537 .get = alc_ch_mode_get,
15538 .put = alc_ch_mode_put,
15539 .private_value = ARRAY_SIZE(alc861_asus_modes),
15540 },
15541 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015542};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015543
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015544/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015545static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015546 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15547 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015548 { }
15549};
15550
Kailang Yangdf694da2005-12-05 19:42:22 +010015551/*
15552 * generic initialization of ADC, input mixers and output mixers
15553 */
15554static struct hda_verb alc861_base_init_verbs[] = {
15555 /*
15556 * Unmute ADC0 and set the default input to mic-in
15557 */
15558 /* port-A for surround (rear panel) */
15559 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15560 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15561 /* port-B for mic-in (rear panel) with vref */
15562 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15563 /* port-C for line-in (rear panel) */
15564 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15565 /* port-D for Front */
15566 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15567 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15568 /* port-E for HP out (front panel) */
15569 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15570 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015571 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015572 /* port-F for mic-in (front panel) with vref */
15573 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15574 /* port-G for CLFE (rear panel) */
15575 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15576 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15577 /* port-H for side (rear panel) */
15578 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15579 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15580 /* CD-in */
15581 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15582 /* route front mic to ADC1*/
15583 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15584 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015585
Kailang Yangdf694da2005-12-05 19:42:22 +010015586 /* Unmute DAC0~3 & spdif out*/
15587 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15588 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15589 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15590 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15591 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015592
Kailang Yangdf694da2005-12-05 19:42:22 +010015593 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15594 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15595 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15596 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15597 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015598
Kailang Yangdf694da2005-12-05 19:42:22 +010015599 /* Unmute Stereo Mixer 15 */
15600 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15601 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15602 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015603 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015604
15605 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15606 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15607 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15608 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15609 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15610 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15611 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15612 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015613 /* hp used DAC 3 (Front) */
15614 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015615 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15616
15617 { }
15618};
15619
15620static struct hda_verb alc861_threestack_init_verbs[] = {
15621 /*
15622 * Unmute ADC0 and set the default input to mic-in
15623 */
15624 /* port-A for surround (rear panel) */
15625 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15626 /* port-B for mic-in (rear panel) with vref */
15627 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15628 /* port-C for line-in (rear panel) */
15629 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15630 /* port-D for Front */
15631 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15632 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15633 /* port-E for HP out (front panel) */
15634 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15635 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015636 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015637 /* port-F for mic-in (front panel) with vref */
15638 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15639 /* port-G for CLFE (rear panel) */
15640 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15641 /* port-H for side (rear panel) */
15642 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15643 /* CD-in */
15644 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15645 /* route front mic to ADC1*/
15646 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15647 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15648 /* Unmute DAC0~3 & spdif out*/
15649 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15650 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15651 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15652 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15653 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015654
Kailang Yangdf694da2005-12-05 19:42:22 +010015655 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15656 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15657 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15658 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15659 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015660
Kailang Yangdf694da2005-12-05 19:42:22 +010015661 /* Unmute Stereo Mixer 15 */
15662 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15663 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15664 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015665 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015666
15667 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15668 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15669 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15670 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15671 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15672 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15673 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15674 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015675 /* hp used DAC 3 (Front) */
15676 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015677 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15678 { }
15679};
Takashi Iwai22309c32006-08-09 16:57:28 +020015680
15681static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15682 /*
15683 * Unmute ADC0 and set the default input to mic-in
15684 */
15685 /* port-A for surround (rear panel) */
15686 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15687 /* port-B for mic-in (rear panel) with vref */
15688 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15689 /* port-C for line-in (rear panel) */
15690 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15691 /* port-D for Front */
15692 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15693 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15694 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015695 /* this has to be set to VREF80 */
15696 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015697 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015698 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015699 /* port-F for mic-in (front panel) with vref */
15700 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15701 /* port-G for CLFE (rear panel) */
15702 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15703 /* port-H for side (rear panel) */
15704 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15705 /* CD-in */
15706 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15707 /* route front mic to ADC1*/
15708 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15709 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15710 /* Unmute DAC0~3 & spdif out*/
15711 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15712 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15713 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15714 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15715 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015716
Takashi Iwai22309c32006-08-09 16:57:28 +020015717 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15718 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15719 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15720 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15721 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015722
Takashi Iwai22309c32006-08-09 16:57:28 +020015723 /* Unmute Stereo Mixer 15 */
15724 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15725 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15726 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015727 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015728
15729 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15730 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15731 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15732 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15733 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15734 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15735 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15736 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015737 /* hp used DAC 3 (Front) */
15738 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015739 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15740 { }
15741};
15742
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015743static struct hda_verb alc861_asus_init_verbs[] = {
15744 /*
15745 * Unmute ADC0 and set the default input to mic-in
15746 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015747 /* port-A for surround (rear panel)
15748 * according to codec#0 this is the HP jack
15749 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015750 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15751 /* route front PCM to HP */
15752 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15753 /* port-B for mic-in (rear panel) with vref */
15754 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15755 /* port-C for line-in (rear panel) */
15756 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15757 /* port-D for Front */
15758 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15759 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15760 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015761 /* this has to be set to VREF80 */
15762 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015763 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015764 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015765 /* port-F for mic-in (front panel) with vref */
15766 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15767 /* port-G for CLFE (rear panel) */
15768 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15769 /* port-H for side (rear panel) */
15770 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15771 /* CD-in */
15772 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15773 /* route front mic to ADC1*/
15774 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15775 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15776 /* Unmute DAC0~3 & spdif out*/
15777 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15778 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15779 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15780 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15781 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15782 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15783 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15784 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15785 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15786 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015787
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015788 /* Unmute Stereo Mixer 15 */
15789 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15790 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15791 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015792 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015793
15794 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15795 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15796 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15797 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15798 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15799 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15800 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15801 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015802 /* hp used DAC 3 (Front) */
15803 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015804 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15805 { }
15806};
15807
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015808/* additional init verbs for ASUS laptops */
15809static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15810 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15811 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15812 { }
15813};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015814
Kailang Yangdf694da2005-12-05 19:42:22 +010015815/*
15816 * generic initialization of ADC, input mixers and output mixers
15817 */
15818static struct hda_verb alc861_auto_init_verbs[] = {
15819 /*
15820 * Unmute ADC0 and set the default input to mic-in
15821 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015822 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015823 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015824
Kailang Yangdf694da2005-12-05 19:42:22 +010015825 /* Unmute DAC0~3 & spdif out*/
15826 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15827 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15828 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15829 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15830 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015831
Kailang Yangdf694da2005-12-05 19:42:22 +010015832 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15833 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15834 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15835 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15836 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015837
Kailang Yangdf694da2005-12-05 19:42:22 +010015838 /* Unmute Stereo Mixer 15 */
15839 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15840 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15841 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15842 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15843
Takashi Iwai1c209302009-07-22 15:17:45 +020015844 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15845 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15846 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15847 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15848 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15849 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15850 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15851 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015852
15853 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15854 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015855 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15856 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015857 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15858 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015859 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15860 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015861
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015862 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015863
15864 { }
15865};
15866
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015867static struct hda_verb alc861_toshiba_init_verbs[] = {
15868 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015869
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015870 { }
15871};
15872
15873/* toggle speaker-output according to the hp-jack state */
15874static void alc861_toshiba_automute(struct hda_codec *codec)
15875{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015876 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015877
Takashi Iwai47fd8302007-08-10 17:11:07 +020015878 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15879 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15880 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15881 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015882}
15883
15884static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15885 unsigned int res)
15886{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015887 if ((res >> 26) == ALC880_HP_EVENT)
15888 alc861_toshiba_automute(codec);
15889}
15890
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015891/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015892#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15893#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15894#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15895#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15896
15897
15898#define ALC861_DIGOUT_NID 0x07
15899
15900static struct hda_channel_mode alc861_8ch_modes[1] = {
15901 { 8, NULL }
15902};
15903
15904static hda_nid_t alc861_dac_nids[4] = {
15905 /* front, surround, clfe, side */
15906 0x03, 0x06, 0x05, 0x04
15907};
15908
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015909static hda_nid_t alc660_dac_nids[3] = {
15910 /* front, clfe, surround */
15911 0x03, 0x05, 0x06
15912};
15913
Kailang Yangdf694da2005-12-05 19:42:22 +010015914static hda_nid_t alc861_adc_nids[1] = {
15915 /* ADC0-2 */
15916 0x08,
15917};
15918
15919static struct hda_input_mux alc861_capture_source = {
15920 .num_items = 5,
15921 .items = {
15922 { "Mic", 0x0 },
15923 { "Front Mic", 0x3 },
15924 { "Line", 0x1 },
15925 { "CD", 0x4 },
15926 { "Mixer", 0x5 },
15927 },
15928};
15929
Takashi Iwai1c209302009-07-22 15:17:45 +020015930static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15931{
15932 struct alc_spec *spec = codec->spec;
15933 hda_nid_t mix, srcs[5];
15934 int i, j, num;
15935
15936 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15937 return 0;
15938 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15939 if (num < 0)
15940 return 0;
15941 for (i = 0; i < num; i++) {
15942 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015943 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015944 if (type != AC_WID_AUD_OUT)
15945 continue;
15946 for (j = 0; j < spec->multiout.num_dacs; j++)
15947 if (spec->multiout.dac_nids[j] == srcs[i])
15948 break;
15949 if (j >= spec->multiout.num_dacs)
15950 return srcs[i];
15951 }
15952 return 0;
15953}
15954
Kailang Yangdf694da2005-12-05 19:42:22 +010015955/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015956static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015957 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015958{
Takashi Iwai1c209302009-07-22 15:17:45 +020015959 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015960 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015961 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015962
15963 spec->multiout.dac_nids = spec->private_dac_nids;
15964 for (i = 0; i < cfg->line_outs; i++) {
15965 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015966 dac = alc861_look_for_dac(codec, nid);
15967 if (!dac)
15968 continue;
15969 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015970 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015971 return 0;
15972}
15973
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015974static int __alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15975 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015976{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015977 return __add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015978 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15979}
15980
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015981#define alc861_create_out_sw(codec, pfx, nid, chs) \
15982 __alc861_create_out_sw(codec, pfx, nid, 0, chs)
15983
Takashi Iwai1c209302009-07-22 15:17:45 +020015984/* add playback controls from the parsed DAC table */
15985static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15986 const struct auto_pin_cfg *cfg)
15987{
15988 struct alc_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +010015989 static const char * const chname[4] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015990 "Front", "Surround", NULL /*CLFE*/, "Side"
15991 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015992 const char *pfx = alc_get_line_out_pfx(cfg, true);
Kailang Yangdf694da2005-12-05 19:42:22 +010015993 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015994 int i, err;
15995
Kailang Yangdf694da2005-12-05 19:42:22 +010015996 for (i = 0; i < cfg->line_outs; i++) {
15997 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015998 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015999 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016000 if (!pfx && i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010016001 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020016002 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016003 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016004 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016005 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016006 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016007 return err;
16008 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016009 const char *name = pfx;
16010 if (!name)
16011 name = chname[i];
16012 err = __alc861_create_out_sw(codec, name, nid, i, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016013 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016014 return err;
16015 }
16016 }
16017 return 0;
16018}
16019
Takashi Iwai1c209302009-07-22 15:17:45 +020016020static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010016021{
Takashi Iwai1c209302009-07-22 15:17:45 +020016022 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016023 int err;
16024 hda_nid_t nid;
16025
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016026 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010016027 return 0;
16028
16029 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020016030 nid = alc861_look_for_dac(codec, pin);
16031 if (nid) {
16032 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
16033 if (err < 0)
16034 return err;
16035 spec->multiout.hp_nid = nid;
16036 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016037 }
16038 return 0;
16039}
16040
16041/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016042static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016043 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010016044{
Takashi Iwai05f5f472009-08-25 13:10:18 +020016045 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010016046}
16047
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016048static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
16049 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020016050 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010016051{
Takashi Iwai1c209302009-07-22 15:17:45 +020016052 hda_nid_t mix, srcs[5];
16053 int i, num;
16054
Jacek Luczak564c5be2008-05-03 18:41:23 +020016055 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
16056 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020016057 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020016058 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020016059 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
16060 return;
16061 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
16062 if (num < 0)
16063 return;
16064 for (i = 0; i < num; i++) {
16065 unsigned int mute;
16066 if (srcs[i] == dac || srcs[i] == 0x15)
16067 mute = AMP_IN_UNMUTE(i);
16068 else
16069 mute = AMP_IN_MUTE(i);
16070 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16071 mute);
16072 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016073}
16074
16075static void alc861_auto_init_multi_out(struct hda_codec *codec)
16076{
16077 struct alc_spec *spec = codec->spec;
16078 int i;
16079
16080 for (i = 0; i < spec->autocfg.line_outs; i++) {
16081 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016082 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016083 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016084 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016085 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016086 }
16087}
16088
16089static void alc861_auto_init_hp_out(struct hda_codec *codec)
16090{
16091 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016092
Takashi Iwai15870f02009-10-05 08:25:13 +020016093 if (spec->autocfg.hp_outs)
16094 alc861_auto_set_output_and_unmute(codec,
16095 spec->autocfg.hp_pins[0],
16096 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020016097 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020016098 if (spec->autocfg.speaker_outs)
16099 alc861_auto_set_output_and_unmute(codec,
16100 spec->autocfg.speaker_pins[0],
16101 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020016102 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016103}
16104
16105static void alc861_auto_init_analog_input(struct hda_codec *codec)
16106{
16107 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016108 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010016109 int i;
16110
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016111 for (i = 0; i < cfg->num_inputs; i++) {
16112 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010016113 if (nid >= 0x0c && nid <= 0x11)
Takashi Iwai30ea0982010-09-16 18:47:56 +020016114 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016115 }
16116}
16117
16118/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016119/* return 1 if successful, 0 if the proper config is not found,
16120 * or a negative error code
16121 */
Kailang Yangdf694da2005-12-05 19:42:22 +010016122static int alc861_parse_auto_config(struct hda_codec *codec)
16123{
16124 struct alc_spec *spec = codec->spec;
16125 int err;
16126 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
16127
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016128 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16129 alc861_ignore);
16130 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016131 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016132 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010016133 return 0; /* can't find valid BIOS pin config */
16134
Takashi Iwai1c209302009-07-22 15:17:45 +020016135 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016136 if (err < 0)
16137 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016138 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016139 if (err < 0)
16140 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016141 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016142 if (err < 0)
16143 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016144 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016145 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016146 return err;
16147
16148 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16149
Takashi Iwai757899a2010-07-30 10:48:14 +020016150 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016151
Takashi Iwai603c4012008-07-30 15:01:44 +020016152 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016153 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010016154
Takashi Iwaid88897e2008-10-31 15:01:37 +010016155 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010016156
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020016157 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016158 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010016159
16160 spec->adc_nids = alc861_adc_nids;
16161 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016162 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016163
Kailang Yang6227cdc2010-02-25 08:36:52 +010016164 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016165
Kailang Yangdf694da2005-12-05 19:42:22 +010016166 return 1;
16167}
16168
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016169/* additional initialization for auto-configuration model */
16170static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010016171{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016172 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016173 alc861_auto_init_multi_out(codec);
16174 alc861_auto_init_hp_out(codec);
16175 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020016176 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016177 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016178 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016179}
16180
Takashi Iwaicb53c622007-08-10 17:21:45 +020016181#ifdef CONFIG_SND_HDA_POWER_SAVE
16182static struct hda_amp_list alc861_loopbacks[] = {
16183 { 0x15, HDA_INPUT, 0 },
16184 { 0x15, HDA_INPUT, 1 },
16185 { 0x15, HDA_INPUT, 2 },
16186 { 0x15, HDA_INPUT, 3 },
16187 { } /* end */
16188};
16189#endif
16190
Kailang Yangdf694da2005-12-05 19:42:22 +010016191
16192/*
16193 * configuration and preset
16194 */
Takashi Iwaiea734962011-01-17 11:29:34 +010016195static const char * const alc861_models[ALC861_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016196 [ALC861_3ST] = "3stack",
16197 [ALC660_3ST] = "3stack-660",
16198 [ALC861_3ST_DIG] = "3stack-dig",
16199 [ALC861_6ST_DIG] = "6stack-dig",
16200 [ALC861_UNIWILL_M31] = "uniwill-m31",
16201 [ALC861_TOSHIBA] = "toshiba",
16202 [ALC861_ASUS] = "asus",
16203 [ALC861_ASUS_LAPTOP] = "asus-laptop",
16204 [ALC861_AUTO] = "auto",
16205};
16206
16207static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010016208 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016209 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16210 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16211 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016212 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020016213 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010016214 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020016215 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
16216 * Any other models that need this preset?
16217 */
16218 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020016219 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
16220 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016221 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
16222 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
16223 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
16224 /* FIXME: the below seems conflict */
16225 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
16226 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
16227 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010016228 {}
16229};
16230
16231static struct alc_config_preset alc861_presets[] = {
16232 [ALC861_3ST] = {
16233 .mixers = { alc861_3ST_mixer },
16234 .init_verbs = { alc861_threestack_init_verbs },
16235 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16236 .dac_nids = alc861_dac_nids,
16237 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16238 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016239 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016240 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16241 .adc_nids = alc861_adc_nids,
16242 .input_mux = &alc861_capture_source,
16243 },
16244 [ALC861_3ST_DIG] = {
16245 .mixers = { alc861_base_mixer },
16246 .init_verbs = { alc861_threestack_init_verbs },
16247 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16248 .dac_nids = alc861_dac_nids,
16249 .dig_out_nid = ALC861_DIGOUT_NID,
16250 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16251 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016252 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016253 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16254 .adc_nids = alc861_adc_nids,
16255 .input_mux = &alc861_capture_source,
16256 },
16257 [ALC861_6ST_DIG] = {
16258 .mixers = { alc861_base_mixer },
16259 .init_verbs = { alc861_base_init_verbs },
16260 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16261 .dac_nids = alc861_dac_nids,
16262 .dig_out_nid = ALC861_DIGOUT_NID,
16263 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
16264 .channel_mode = alc861_8ch_modes,
16265 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16266 .adc_nids = alc861_adc_nids,
16267 .input_mux = &alc861_capture_source,
16268 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016269 [ALC660_3ST] = {
16270 .mixers = { alc861_3ST_mixer },
16271 .init_verbs = { alc861_threestack_init_verbs },
16272 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
16273 .dac_nids = alc660_dac_nids,
16274 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16275 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016276 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016277 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16278 .adc_nids = alc861_adc_nids,
16279 .input_mux = &alc861_capture_source,
16280 },
Takashi Iwai22309c32006-08-09 16:57:28 +020016281 [ALC861_UNIWILL_M31] = {
16282 .mixers = { alc861_uniwill_m31_mixer },
16283 .init_verbs = { alc861_uniwill_m31_init_verbs },
16284 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16285 .dac_nids = alc861_dac_nids,
16286 .dig_out_nid = ALC861_DIGOUT_NID,
16287 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
16288 .channel_mode = alc861_uniwill_m31_modes,
16289 .need_dac_fix = 1,
16290 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16291 .adc_nids = alc861_adc_nids,
16292 .input_mux = &alc861_capture_source,
16293 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016294 [ALC861_TOSHIBA] = {
16295 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016296 .init_verbs = { alc861_base_init_verbs,
16297 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016298 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16299 .dac_nids = alc861_dac_nids,
16300 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16301 .channel_mode = alc883_3ST_2ch_modes,
16302 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16303 .adc_nids = alc861_adc_nids,
16304 .input_mux = &alc861_capture_source,
16305 .unsol_event = alc861_toshiba_unsol_event,
16306 .init_hook = alc861_toshiba_automute,
16307 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020016308 [ALC861_ASUS] = {
16309 .mixers = { alc861_asus_mixer },
16310 .init_verbs = { alc861_asus_init_verbs },
16311 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16312 .dac_nids = alc861_dac_nids,
16313 .dig_out_nid = ALC861_DIGOUT_NID,
16314 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
16315 .channel_mode = alc861_asus_modes,
16316 .need_dac_fix = 1,
16317 .hp_nid = 0x06,
16318 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16319 .adc_nids = alc861_adc_nids,
16320 .input_mux = &alc861_capture_source,
16321 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010016322 [ALC861_ASUS_LAPTOP] = {
16323 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
16324 .init_verbs = { alc861_asus_init_verbs,
16325 alc861_asus_laptop_init_verbs },
16326 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16327 .dac_nids = alc861_dac_nids,
16328 .dig_out_nid = ALC861_DIGOUT_NID,
16329 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16330 .channel_mode = alc883_3ST_2ch_modes,
16331 .need_dac_fix = 1,
16332 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16333 .adc_nids = alc861_adc_nids,
16334 .input_mux = &alc861_capture_source,
16335 },
16336};
Kailang Yangdf694da2005-12-05 19:42:22 +010016337
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016338/* Pin config fixes */
16339enum {
16340 PINFIX_FSC_AMILO_PI1505,
16341};
16342
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016343static const struct alc_fixup alc861_fixups[] = {
16344 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016345 .type = ALC_FIXUP_PINS,
16346 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020016347 { 0x0b, 0x0221101f }, /* HP */
16348 { 0x0f, 0x90170310 }, /* speaker */
16349 { }
16350 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016351 },
16352};
16353
16354static struct snd_pci_quirk alc861_fixup_tbl[] = {
16355 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
16356 {}
16357};
Kailang Yangdf694da2005-12-05 19:42:22 +010016358
16359static int patch_alc861(struct hda_codec *codec)
16360{
16361 struct alc_spec *spec;
16362 int board_config;
16363 int err;
16364
Robert P. J. Daydc041e02006-12-19 14:44:15 +010016365 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010016366 if (spec == NULL)
16367 return -ENOMEM;
16368
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016369 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016370
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016371 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
16372 alc861_models,
16373 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016374
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016375 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016376 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16377 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010016378 board_config = ALC861_AUTO;
16379 }
16380
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016381 if (board_config == ALC861_AUTO) {
16382 alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
16383 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
16384 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016385
Kailang Yangdf694da2005-12-05 19:42:22 +010016386 if (board_config == ALC861_AUTO) {
16387 /* automatic parse from the BIOS config */
16388 err = alc861_parse_auto_config(codec);
16389 if (err < 0) {
16390 alc_free(codec);
16391 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016392 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016393 printk(KERN_INFO
16394 "hda_codec: Cannot set up configuration "
16395 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010016396 board_config = ALC861_3ST_DIG;
16397 }
16398 }
16399
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016400 err = snd_hda_attach_beep_device(codec, 0x23);
16401 if (err < 0) {
16402 alc_free(codec);
16403 return err;
16404 }
16405
Kailang Yangdf694da2005-12-05 19:42:22 +010016406 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016407 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016408
Kailang Yangdf694da2005-12-05 19:42:22 +010016409 spec->stream_analog_playback = &alc861_pcm_analog_playback;
16410 spec->stream_analog_capture = &alc861_pcm_analog_capture;
16411
Kailang Yangdf694da2005-12-05 19:42:22 +010016412 spec->stream_digital_playback = &alc861_pcm_digital_playback;
16413 spec->stream_digital_capture = &alc861_pcm_digital_capture;
16414
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010016415 if (!spec->cap_mixer)
16416 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016417 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
16418
Takashi Iwai2134ea42008-01-10 16:53:55 +010016419 spec->vmaster_nid = 0x03;
16420
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016421 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016422
Kailang Yangdf694da2005-12-05 19:42:22 +010016423 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050016424 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016425 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016426#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050016427 spec->power_hook = alc_power_eapd;
16428#endif
16429 }
16430#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020016431 if (!spec->loopback.amplist)
16432 spec->loopback.amplist = alc861_loopbacks;
16433#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020016434
Kailang Yangdf694da2005-12-05 19:42:22 +010016435 return 0;
16436}
16437
16438/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016439 * ALC861-VD support
16440 *
16441 * Based on ALC882
16442 *
16443 * In addition, an independent DAC
16444 */
16445#define ALC861VD_DIGOUT_NID 0x06
16446
16447static hda_nid_t alc861vd_dac_nids[4] = {
16448 /* front, surr, clfe, side surr */
16449 0x02, 0x03, 0x04, 0x05
16450};
16451
16452/* dac_nids for ALC660vd are in a different order - according to
16453 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016454 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016455 * of ALC660vd codecs, but for now there is only 3stack mixer
16456 * - and it is the same as in 861vd.
16457 * adc_nids in ALC660vd are (is) the same as in 861vd
16458 */
16459static hda_nid_t alc660vd_dac_nids[3] = {
16460 /* front, rear, clfe, rear_surr */
16461 0x02, 0x04, 0x03
16462};
16463
16464static hda_nid_t alc861vd_adc_nids[1] = {
16465 /* ADC0 */
16466 0x09,
16467};
16468
Takashi Iwaie1406342008-02-11 18:32:32 +010016469static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
16470
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016471/* input MUX */
16472/* FIXME: should be a matrix-type input source selection */
16473static struct hda_input_mux alc861vd_capture_source = {
16474 .num_items = 4,
16475 .items = {
16476 { "Mic", 0x0 },
16477 { "Front Mic", 0x1 },
16478 { "Line", 0x2 },
16479 { "CD", 0x4 },
16480 },
16481};
16482
Kailang Yang272a5272007-05-14 11:00:38 +020016483static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016484 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016485 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +010016486 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010016487 { "Internal Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016488 },
16489};
16490
Kailang Yangd1a991a2007-08-15 16:21:59 +020016491static struct hda_input_mux alc861vd_hp_capture_source = {
16492 .num_items = 2,
16493 .items = {
16494 { "Front Mic", 0x0 },
16495 { "ATAPI Mic", 0x1 },
16496 },
16497};
16498
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016499/*
16500 * 2ch mode
16501 */
16502static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16503 { 2, NULL }
16504};
16505
16506/*
16507 * 6ch mode
16508 */
16509static struct hda_verb alc861vd_6stack_ch6_init[] = {
16510 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16511 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16512 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16513 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16514 { } /* end */
16515};
16516
16517/*
16518 * 8ch mode
16519 */
16520static struct hda_verb alc861vd_6stack_ch8_init[] = {
16521 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16522 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16523 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16524 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16525 { } /* end */
16526};
16527
16528static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16529 { 6, alc861vd_6stack_ch6_init },
16530 { 8, alc861vd_6stack_ch8_init },
16531};
16532
16533static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16534 {
16535 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16536 .name = "Channel Mode",
16537 .info = alc_ch_mode_info,
16538 .get = alc_ch_mode_get,
16539 .put = alc_ch_mode_put,
16540 },
16541 { } /* end */
16542};
16543
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016544/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16545 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16546 */
16547static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16548 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16549 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16550
16551 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16552 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16553
16554 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16555 HDA_OUTPUT),
16556 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16557 HDA_OUTPUT),
16558 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16559 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16560
16561 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16562 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16563
16564 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16565
David Henningsson5f99f862011-01-04 15:24:24 +010016566 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016567 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16568 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16569
David Henningsson5f99f862011-01-04 15:24:24 +010016570 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016571 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16572 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16573
16574 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16575 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16576
16577 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16578 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16579
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016580 { } /* end */
16581};
16582
16583static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16584 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16585 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16586
16587 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16588
David Henningsson5f99f862011-01-04 15:24:24 +010016589 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016590 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16591 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16592
David Henningsson5f99f862011-01-04 15:24:24 +010016593 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016594 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16595 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16596
16597 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16598 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16599
16600 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16601 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16602
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016603 { } /* end */
16604};
16605
Kailang Yangbdd148a2007-05-08 15:19:08 +020016606static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16607 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16608 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16609 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16610
16611 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16612
David Henningsson5f99f862011-01-04 15:24:24 +010016613 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016614 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16615 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16616
David Henningsson5f99f862011-01-04 15:24:24 +010016617 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016618 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16619 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16620
16621 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16622 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16623
16624 { } /* end */
16625};
16626
Tobin Davisb419f342008-03-07 11:57:51 +010016627/* Pin assignment: Speaker=0x14, HP = 0x15,
David Henningsson8607f7c2010-12-20 14:43:54 +010016628 * Mic=0x18, Internal Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016629 */
16630static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016631 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16632 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016633 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16634 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016635 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +010016636 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16637 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016638 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010016639 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16640 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016641 { } /* end */
16642};
16643
Kailang Yangd1a991a2007-08-15 16:21:59 +020016644/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16645 * Front Mic=0x18, ATAPI Mic = 0x19,
16646 */
16647static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16648 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16649 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16650 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16651 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16652 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16653 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16654 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16655 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016656
Kailang Yangd1a991a2007-08-15 16:21:59 +020016657 { } /* end */
16658};
16659
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016660/*
16661 * generic initialization of ADC, input mixers and output mixers
16662 */
16663static struct hda_verb alc861vd_volume_init_verbs[] = {
16664 /*
16665 * Unmute ADC0 and set the default input to mic-in
16666 */
16667 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16668 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16669
16670 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16671 * the analog-loopback mixer widget
16672 */
16673 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016674 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16675 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16676 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16677 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16678 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016679
16680 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016681 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16682 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16683 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016684 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016685
16686 /*
16687 * Set up output mixers (0x02 - 0x05)
16688 */
16689 /* set vol=0 to output mixers */
16690 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16691 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16692 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16693 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16694
16695 /* set up input amps for analog loopback */
16696 /* Amp Indices: DAC = 0, mixer = 1 */
16697 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16698 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16699 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16700 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16701 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16702 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16703 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16704 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16705
16706 { }
16707};
16708
16709/*
16710 * 3-stack pin configuration:
16711 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16712 */
16713static struct hda_verb alc861vd_3stack_init_verbs[] = {
16714 /*
16715 * Set pin mode and muting
16716 */
16717 /* set front pin widgets 0x14 for output */
16718 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16719 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16720 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16721
16722 /* Mic (rear) pin: input vref at 80% */
16723 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16724 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16725 /* Front Mic pin: input vref at 80% */
16726 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16727 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16728 /* Line In pin: input */
16729 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16730 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16731 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16732 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16733 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16734 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16735 /* CD pin widget for input */
16736 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16737
16738 { }
16739};
16740
16741/*
16742 * 6-stack pin configuration:
16743 */
16744static struct hda_verb alc861vd_6stack_init_verbs[] = {
16745 /*
16746 * Set pin mode and muting
16747 */
16748 /* set front pin widgets 0x14 for output */
16749 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16750 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16751 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16752
16753 /* Rear Pin: output 1 (0x0d) */
16754 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16755 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16756 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16757 /* CLFE Pin: output 2 (0x0e) */
16758 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16759 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16760 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16761 /* Side Pin: output 3 (0x0f) */
16762 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16763 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16764 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16765
16766 /* Mic (rear) pin: input vref at 80% */
16767 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16768 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16769 /* Front Mic pin: input vref at 80% */
16770 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16771 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16772 /* Line In pin: input */
16773 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16774 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16775 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16776 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16777 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16778 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16779 /* CD pin widget for input */
16780 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16781
16782 { }
16783};
16784
Kailang Yangbdd148a2007-05-08 15:19:08 +020016785static struct hda_verb alc861vd_eapd_verbs[] = {
16786 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16787 { }
16788};
16789
Kailang Yangf9423e72008-05-27 12:32:25 +020016790static struct hda_verb alc660vd_eapd_verbs[] = {
16791 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16792 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16793 { }
16794};
16795
Kailang Yangbdd148a2007-05-08 15:19:08 +020016796static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16797 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16798 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16799 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16800 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016801 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016802 {}
16803};
16804
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016805static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016806{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016807 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016808 spec->autocfg.hp_pins[0] = 0x1b;
16809 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016810}
16811
16812static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16813{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016814 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +010016815 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016816}
16817
16818static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16819 unsigned int res)
16820{
16821 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016822 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +010016823 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016824 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016825 default:
16826 alc_automute_amp_unsol_event(codec, res);
16827 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016828 }
16829}
16830
Kailang Yang272a5272007-05-14 11:00:38 +020016831static struct hda_verb alc861vd_dallas_verbs[] = {
16832 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16833 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16834 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16835 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16836
16837 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16838 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16839 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16840 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16841 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16842 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16843 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16844 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016845
Kailang Yang272a5272007-05-14 11:00:38 +020016846 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16847 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16848 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16849 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16850 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16851 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16852 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16853 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16854
16855 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16856 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16857 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16858 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16859 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16860 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16861 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16862 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16863
16864 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16865 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16866 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16867 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16868
16869 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016870 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016871 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16872
16873 { } /* end */
16874};
16875
16876/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016877static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016878{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016879 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016880
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016881 spec->autocfg.hp_pins[0] = 0x15;
16882 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016883}
16884
Takashi Iwaicb53c622007-08-10 17:21:45 +020016885#ifdef CONFIG_SND_HDA_POWER_SAVE
16886#define alc861vd_loopbacks alc880_loopbacks
16887#endif
16888
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016889/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016890#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16891#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16892#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16893#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16894
16895/*
16896 * configuration and preset
16897 */
Takashi Iwaiea734962011-01-17 11:29:34 +010016898static const char * const alc861vd_models[ALC861VD_MODEL_LAST] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016899 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016900 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016901 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016902 [ALC861VD_3ST] = "3stack",
16903 [ALC861VD_3ST_DIG] = "3stack-digout",
16904 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016905 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016906 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016907 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016908 [ALC861VD_AUTO] = "auto",
16909};
16910
16911static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016912 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16913 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016914 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016915 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016916 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016917 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016918 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016919 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016920 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016921 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016922 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016923 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016924 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016925 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016926 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016927 {}
16928};
16929
16930static struct alc_config_preset alc861vd_presets[] = {
16931 [ALC660VD_3ST] = {
16932 .mixers = { alc861vd_3st_mixer },
16933 .init_verbs = { alc861vd_volume_init_verbs,
16934 alc861vd_3stack_init_verbs },
16935 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16936 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016937 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16938 .channel_mode = alc861vd_3stack_2ch_modes,
16939 .input_mux = &alc861vd_capture_source,
16940 },
Mike Crash6963f842007-06-25 12:12:51 +020016941 [ALC660VD_3ST_DIG] = {
16942 .mixers = { alc861vd_3st_mixer },
16943 .init_verbs = { alc861vd_volume_init_verbs,
16944 alc861vd_3stack_init_verbs },
16945 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16946 .dac_nids = alc660vd_dac_nids,
16947 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016948 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16949 .channel_mode = alc861vd_3stack_2ch_modes,
16950 .input_mux = &alc861vd_capture_source,
16951 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016952 [ALC861VD_3ST] = {
16953 .mixers = { alc861vd_3st_mixer },
16954 .init_verbs = { alc861vd_volume_init_verbs,
16955 alc861vd_3stack_init_verbs },
16956 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16957 .dac_nids = alc861vd_dac_nids,
16958 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16959 .channel_mode = alc861vd_3stack_2ch_modes,
16960 .input_mux = &alc861vd_capture_source,
16961 },
16962 [ALC861VD_3ST_DIG] = {
16963 .mixers = { alc861vd_3st_mixer },
16964 .init_verbs = { alc861vd_volume_init_verbs,
16965 alc861vd_3stack_init_verbs },
16966 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16967 .dac_nids = alc861vd_dac_nids,
16968 .dig_out_nid = ALC861VD_DIGOUT_NID,
16969 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16970 .channel_mode = alc861vd_3stack_2ch_modes,
16971 .input_mux = &alc861vd_capture_source,
16972 },
16973 [ALC861VD_6ST_DIG] = {
16974 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16975 .init_verbs = { alc861vd_volume_init_verbs,
16976 alc861vd_6stack_init_verbs },
16977 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16978 .dac_nids = alc861vd_dac_nids,
16979 .dig_out_nid = ALC861VD_DIGOUT_NID,
16980 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16981 .channel_mode = alc861vd_6stack_modes,
16982 .input_mux = &alc861vd_capture_source,
16983 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016984 [ALC861VD_LENOVO] = {
16985 .mixers = { alc861vd_lenovo_mixer },
16986 .init_verbs = { alc861vd_volume_init_verbs,
16987 alc861vd_3stack_init_verbs,
16988 alc861vd_eapd_verbs,
16989 alc861vd_lenovo_unsol_verbs },
16990 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16991 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016992 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16993 .channel_mode = alc861vd_3stack_2ch_modes,
16994 .input_mux = &alc861vd_capture_source,
16995 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016996 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016997 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016998 },
Kailang Yang272a5272007-05-14 11:00:38 +020016999 [ALC861VD_DALLAS] = {
17000 .mixers = { alc861vd_dallas_mixer },
17001 .init_verbs = { alc861vd_dallas_verbs },
17002 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
17003 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020017004 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17005 .channel_mode = alc861vd_3stack_2ch_modes,
17006 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017007 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017008 .setup = alc861vd_dallas_setup,
17009 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017010 },
17011 [ALC861VD_HP] = {
17012 .mixers = { alc861vd_hp_mixer },
17013 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
17014 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
17015 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017016 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017017 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17018 .channel_mode = alc861vd_3stack_2ch_modes,
17019 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017020 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017021 .setup = alc861vd_dallas_setup,
17022 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020017023 },
Takashi Iwai13c94742008-11-05 08:06:08 +010017024 [ALC660VD_ASUS_V1S] = {
17025 .mixers = { alc861vd_lenovo_mixer },
17026 .init_verbs = { alc861vd_volume_init_verbs,
17027 alc861vd_3stack_init_verbs,
17028 alc861vd_eapd_verbs,
17029 alc861vd_lenovo_unsol_verbs },
17030 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
17031 .dac_nids = alc660vd_dac_nids,
17032 .dig_out_nid = ALC861VD_DIGOUT_NID,
17033 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17034 .channel_mode = alc861vd_3stack_2ch_modes,
17035 .input_mux = &alc861vd_capture_source,
17036 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017037 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017038 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010017039 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017040};
17041
17042/*
17043 * BIOS auto configuration
17044 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017045static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
17046 const struct auto_pin_cfg *cfg)
17047{
Herton Ronaldo Krzesinski71675942010-11-25 00:08:01 -020017048 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x22, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020017049}
17050
17051
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017052static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
17053 hda_nid_t nid, int pin_type, int dac_idx)
17054{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017055 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017056}
17057
17058static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
17059{
17060 struct alc_spec *spec = codec->spec;
17061 int i;
17062
17063 for (i = 0; i <= HDA_SIDE; i++) {
17064 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017065 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017066 if (nid)
17067 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017068 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017069 }
17070}
17071
17072
17073static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
17074{
17075 struct alc_spec *spec = codec->spec;
17076 hda_nid_t pin;
17077
17078 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017079 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017080 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017081 pin = spec->autocfg.speaker_pins[0];
17082 if (pin)
17083 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017084}
17085
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017086#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
17087
17088static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
17089{
17090 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017091 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017092 int i;
17093
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017094 for (i = 0; i < cfg->num_inputs; i++) {
17095 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017096 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020017097 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +010017098 if (nid != ALC861VD_PIN_CD_NID &&
17099 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017100 snd_hda_codec_write(codec, nid, 0,
17101 AC_VERB_SET_AMP_GAIN_MUTE,
17102 AMP_OUT_MUTE);
17103 }
17104 }
17105}
17106
Takashi Iwaif511b012008-08-15 16:46:42 +020017107#define alc861vd_auto_init_input_src alc882_auto_init_input_src
17108
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017109#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
17110#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
17111
17112/* add playback controls from the parsed DAC table */
Takashi Iwai569ed342011-01-19 10:14:46 +010017113/* Based on ALC880 version. But ALC861VD has separate,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017114 * different NIDs for mute/unmute switch and volume control */
17115static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
17116 const struct auto_pin_cfg *cfg)
17117{
Takashi Iwaiea734962011-01-17 11:29:34 +010017118 static const char * const chname[4] = {
17119 "Front", "Surround", "CLFE", "Side"
17120 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017121 const char *pfx = alc_get_line_out_pfx(cfg, true);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017122 hda_nid_t nid_v, nid_s;
17123 int i, err;
17124
17125 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017126 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017127 continue;
17128 nid_v = alc861vd_idx_to_mixer_vol(
17129 alc880_dac_to_idx(
17130 spec->multiout.dac_nids[i]));
17131 nid_s = alc861vd_idx_to_mixer_switch(
17132 alc880_dac_to_idx(
17133 spec->multiout.dac_nids[i]));
17134
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017135 if (!pfx && i == 2) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017136 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017137 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17138 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017139 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
17140 HDA_OUTPUT));
17141 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017142 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017143 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17144 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017145 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
17146 HDA_OUTPUT));
17147 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017148 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017149 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17150 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017151 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
17152 HDA_INPUT));
17153 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017154 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017155 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17156 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017157 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
17158 HDA_INPUT));
17159 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017160 return err;
17161 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017162 const char *name = pfx;
17163 if (!name)
17164 name = chname[i];
17165 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17166 name, i,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017167 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
17168 HDA_OUTPUT));
17169 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017170 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017171 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17172 name, i,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017173 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017174 HDA_INPUT));
17175 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017176 return err;
17177 }
17178 }
17179 return 0;
17180}
17181
17182/* add playback controls for speaker and HP outputs */
17183/* Based on ALC880 version. But ALC861VD has separate,
17184 * different NIDs for mute/unmute switch and volume control */
17185static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
17186 hda_nid_t pin, const char *pfx)
17187{
17188 hda_nid_t nid_v, nid_s;
17189 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017190
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017191 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017192 return 0;
17193
17194 if (alc880_is_fixed_pin(pin)) {
17195 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17196 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017197 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017198 spec->multiout.hp_nid = nid_v;
17199 else
17200 spec->multiout.extra_out_nid[0] = nid_v;
17201 /* control HP volume/switch on the output mixer amp */
17202 nid_v = alc861vd_idx_to_mixer_vol(
17203 alc880_fixed_pin_idx(pin));
17204 nid_s = alc861vd_idx_to_mixer_switch(
17205 alc880_fixed_pin_idx(pin));
17206
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017207 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017208 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
17209 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017210 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017211 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017212 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
17213 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017214 return err;
17215 } else if (alc880_is_multi_pin(pin)) {
17216 /* set manual connection */
17217 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017218 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017219 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17220 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017221 return err;
17222 }
17223 return 0;
17224}
17225
17226/* parse the BIOS configuration and set up the alc_spec
17227 * return 1 if successful, 0 if the proper config is not found,
17228 * or a negative error code
17229 * Based on ALC880 version - had to change it to override
17230 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
17231static int alc861vd_parse_auto_config(struct hda_codec *codec)
17232{
17233 struct alc_spec *spec = codec->spec;
17234 int err;
17235 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
17236
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017237 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17238 alc861vd_ignore);
17239 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017240 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017241 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017242 return 0; /* can't find valid BIOS pin config */
17243
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017244 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17245 if (err < 0)
17246 return err;
17247 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
17248 if (err < 0)
17249 return err;
17250 err = alc861vd_auto_create_extra_out(spec,
17251 spec->autocfg.speaker_pins[0],
17252 "Speaker");
17253 if (err < 0)
17254 return err;
17255 err = alc861vd_auto_create_extra_out(spec,
17256 spec->autocfg.hp_pins[0],
17257 "Headphone");
17258 if (err < 0)
17259 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017260 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017261 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017262 return err;
17263
17264 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17265
Takashi Iwai757899a2010-07-30 10:48:14 +020017266 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017267
Takashi Iwai603c4012008-07-30 15:01:44 +020017268 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017269 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017270
Takashi Iwaid88897e2008-10-31 15:01:37 +010017271 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017272
17273 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017274 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017275
Takashi Iwai776e1842007-08-29 15:07:11 +020017276 err = alc_auto_add_mic_boost(codec);
17277 if (err < 0)
17278 return err;
17279
Kailang Yang6227cdc2010-02-25 08:36:52 +010017280 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017281
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017282 return 1;
17283}
17284
17285/* additional initialization for auto-configuration model */
17286static void alc861vd_auto_init(struct hda_codec *codec)
17287{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017288 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017289 alc861vd_auto_init_multi_out(codec);
17290 alc861vd_auto_init_hp_out(codec);
17291 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017292 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020017293 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017294 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017295 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017296}
17297
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017298enum {
17299 ALC660VD_FIX_ASUS_GPIO1
17300};
17301
17302/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017303static const struct alc_fixup alc861vd_fixups[] = {
17304 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017305 .type = ALC_FIXUP_VERBS,
17306 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020017307 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
17308 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
17309 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
17310 { }
17311 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017312 },
17313};
17314
17315static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
17316 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
17317 {}
17318};
17319
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017320static int patch_alc861vd(struct hda_codec *codec)
17321{
17322 struct alc_spec *spec;
17323 int err, board_config;
17324
17325 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17326 if (spec == NULL)
17327 return -ENOMEM;
17328
17329 codec->spec = spec;
17330
17331 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
17332 alc861vd_models,
17333 alc861vd_cfg_tbl);
17334
17335 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017336 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17337 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017338 board_config = ALC861VD_AUTO;
17339 }
17340
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017341 if (board_config == ALC861VD_AUTO) {
17342 alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
17343 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
17344 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017345
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017346 if (board_config == ALC861VD_AUTO) {
17347 /* automatic parse from the BIOS config */
17348 err = alc861vd_parse_auto_config(codec);
17349 if (err < 0) {
17350 alc_free(codec);
17351 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017352 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017353 printk(KERN_INFO
17354 "hda_codec: Cannot set up configuration "
17355 "from BIOS. Using base mode...\n");
17356 board_config = ALC861VD_3ST;
17357 }
17358 }
17359
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017360 err = snd_hda_attach_beep_device(codec, 0x23);
17361 if (err < 0) {
17362 alc_free(codec);
17363 return err;
17364 }
17365
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017366 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017367 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017368
Kailang Yang2f893282008-05-27 12:14:47 +020017369 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020017370 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010017371 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020017372 }
17373
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017374 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
17375 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
17376
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017377 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
17378 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
17379
Takashi Iwaidd704692009-08-11 08:45:11 +020017380 if (!spec->adc_nids) {
17381 spec->adc_nids = alc861vd_adc_nids;
17382 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
17383 }
17384 if (!spec->capsrc_nids)
17385 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017386
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017387 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010017388 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017389
Takashi Iwai2134ea42008-01-10 16:53:55 +010017390 spec->vmaster_nid = 0x02;
17391
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017392 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017393
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017394 codec->patch_ops = alc_patch_ops;
17395
17396 if (board_config == ALC861VD_AUTO)
17397 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017398#ifdef CONFIG_SND_HDA_POWER_SAVE
17399 if (!spec->loopback.amplist)
17400 spec->loopback.amplist = alc861vd_loopbacks;
17401#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017402
17403 return 0;
17404}
17405
17406/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017407 * ALC662 support
17408 *
17409 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
17410 * configuration. Each pin widget can choose any input DACs and a mixer.
17411 * Each ADC is connected from a mixer of all inputs. This makes possible
17412 * 6-channel independent captures.
17413 *
17414 * In addition, an independent DAC for the multi-playback (not used in this
17415 * driver yet).
17416 */
17417#define ALC662_DIGOUT_NID 0x06
17418#define ALC662_DIGIN_NID 0x0a
17419
17420static hda_nid_t alc662_dac_nids[4] = {
17421 /* front, rear, clfe, rear_surr */
17422 0x02, 0x03, 0x04
17423};
17424
Kailang Yang622e84c2009-04-21 07:39:04 +020017425static hda_nid_t alc272_dac_nids[2] = {
17426 0x02, 0x03
17427};
17428
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017429static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017430 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017431 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017432};
Takashi Iwaie1406342008-02-11 18:32:32 +010017433
Kailang Yang622e84c2009-04-21 07:39:04 +020017434static hda_nid_t alc272_adc_nids[1] = {
17435 /* ADC1-2 */
17436 0x08,
17437};
17438
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017439static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020017440static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
17441
Takashi Iwaie1406342008-02-11 18:32:32 +010017442
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017443/* input MUX */
17444/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017445static struct hda_input_mux alc662_capture_source = {
17446 .num_items = 4,
17447 .items = {
17448 { "Mic", 0x0 },
17449 { "Front Mic", 0x1 },
17450 { "Line", 0x2 },
17451 { "CD", 0x4 },
17452 },
17453};
17454
17455static struct hda_input_mux alc662_lenovo_101e_capture_source = {
17456 .num_items = 2,
17457 .items = {
17458 { "Mic", 0x1 },
17459 { "Line", 0x2 },
17460 },
17461};
Kailang Yang291702f2007-10-16 14:28:03 +020017462
Kailang Yang6dda9f42008-05-27 12:05:31 +020017463static struct hda_input_mux alc663_capture_source = {
17464 .num_items = 3,
17465 .items = {
17466 { "Mic", 0x0 },
17467 { "Front Mic", 0x1 },
17468 { "Line", 0x2 },
17469 },
17470};
17471
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017472#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020017473static struct hda_input_mux alc272_nc10_capture_source = {
17474 .num_items = 16,
17475 .items = {
17476 { "Autoselect Mic", 0x0 },
17477 { "Internal Mic", 0x1 },
17478 { "In-0x02", 0x2 },
17479 { "In-0x03", 0x3 },
17480 { "In-0x04", 0x4 },
17481 { "In-0x05", 0x5 },
17482 { "In-0x06", 0x6 },
17483 { "In-0x07", 0x7 },
17484 { "In-0x08", 0x8 },
17485 { "In-0x09", 0x9 },
17486 { "In-0x0a", 0x0a },
17487 { "In-0x0b", 0x0b },
17488 { "In-0x0c", 0x0c },
17489 { "In-0x0d", 0x0d },
17490 { "In-0x0e", 0x0e },
17491 { "In-0x0f", 0x0f },
17492 },
17493};
17494#endif
17495
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017496/*
17497 * 2ch mode
17498 */
17499static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17500 { 2, NULL }
17501};
17502
17503/*
17504 * 2ch mode
17505 */
17506static struct hda_verb alc662_3ST_ch2_init[] = {
17507 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17508 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17509 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17510 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17511 { } /* end */
17512};
17513
17514/*
17515 * 6ch mode
17516 */
17517static struct hda_verb alc662_3ST_ch6_init[] = {
17518 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17519 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17520 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17521 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17522 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17523 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17524 { } /* end */
17525};
17526
17527static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17528 { 2, alc662_3ST_ch2_init },
17529 { 6, alc662_3ST_ch6_init },
17530};
17531
17532/*
17533 * 2ch mode
17534 */
17535static struct hda_verb alc662_sixstack_ch6_init[] = {
17536 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17537 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17538 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17539 { } /* end */
17540};
17541
17542/*
17543 * 6ch mode
17544 */
17545static struct hda_verb alc662_sixstack_ch8_init[] = {
17546 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17547 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17548 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17549 { } /* end */
17550};
17551
17552static struct hda_channel_mode alc662_5stack_modes[2] = {
17553 { 2, alc662_sixstack_ch6_init },
17554 { 6, alc662_sixstack_ch8_init },
17555};
17556
17557/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17558 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17559 */
17560
17561static struct snd_kcontrol_new alc662_base_mixer[] = {
17562 /* output mixer control */
17563 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017564 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017565 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017566 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017567 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17568 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017569 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17570 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017571 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17572
17573 /*Input mixer control */
17574 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17575 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17576 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17577 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17578 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17579 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17580 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17581 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017582 { } /* end */
17583};
17584
17585static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17586 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017587 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017588 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17589 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17590 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17591 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17592 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17593 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17594 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17595 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17596 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017597 { } /* end */
17598};
17599
17600static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17601 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017602 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017603 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017604 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017605 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17606 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017607 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17608 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017609 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17610 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17611 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17612 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17613 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17614 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17615 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17616 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17617 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017618 { } /* end */
17619};
17620
17621static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17622 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17623 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017624 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17625 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017626 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17627 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17628 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17629 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17630 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017631 { } /* end */
17632};
17633
Kailang Yang291702f2007-10-16 14:28:03 +020017634static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017635 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17636 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017637
David Henningsson5f99f862011-01-04 15:24:24 +010017638 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017639 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17640 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017641
David Henningsson5f99f862011-01-04 15:24:24 +010017642 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017643 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17644 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017645 { } /* end */
17646};
17647
Kailang Yang8c427222008-01-10 13:03:59 +010017648static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017649 ALC262_HIPPO_MASTER_SWITCH,
17650 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017651 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017652 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17653 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017654 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17655 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17656 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
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
Kailang Yangf1d4e282008-08-26 14:03:29 +020017662static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17663 .ops = &snd_hda_bind_vol,
17664 .values = {
17665 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17666 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17667 0
17668 },
17669};
17670
17671static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17672 .ops = &snd_hda_bind_sw,
17673 .values = {
17674 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17675 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17676 0
17677 },
17678};
17679
Kailang Yang6dda9f42008-05-27 12:05:31 +020017680static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017681 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17682 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17683 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17684 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17685 { } /* end */
17686};
17687
17688static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17689 .ops = &snd_hda_bind_sw,
17690 .values = {
17691 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17692 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17693 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17694 0
17695 },
17696};
17697
17698static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17699 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17700 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17701 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17702 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17703 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17704 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17705
17706 { } /* end */
17707};
17708
17709static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17710 .ops = &snd_hda_bind_sw,
17711 .values = {
17712 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17713 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17714 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17715 0
17716 },
17717};
17718
17719static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17720 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17721 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17722 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17723 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17724 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17725 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17726 { } /* end */
17727};
17728
17729static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017730 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17731 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017732 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17733 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17734 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17735 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17736 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17737 { } /* end */
17738};
17739
17740static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17741 .ops = &snd_hda_bind_vol,
17742 .values = {
17743 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17744 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17745 0
17746 },
17747};
17748
17749static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17750 .ops = &snd_hda_bind_sw,
17751 .values = {
17752 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17753 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17754 0
17755 },
17756};
17757
17758static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17759 HDA_BIND_VOL("Master Playback Volume",
17760 &alc663_asus_two_bind_master_vol),
17761 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17762 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017763 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17764 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17765 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017766 { } /* end */
17767};
17768
17769static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17770 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17771 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17772 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17773 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17774 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17775 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017776 { } /* end */
17777};
17778
17779static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17780 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17781 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17782 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17783 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17784 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17785
17786 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17787 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017788 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17789 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017790 { } /* end */
17791};
17792
17793static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17794 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17795 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17796 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17797
17798 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17799 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017800 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17801 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017802 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17803 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17804 { } /* end */
17805};
17806
Kailang Yangebb83ee2009-12-17 12:23:00 +010017807static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17808 .ops = &snd_hda_bind_sw,
17809 .values = {
17810 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17811 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17812 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17813 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17814 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17815 0
17816 },
17817};
17818
17819static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17820 .ops = &snd_hda_bind_sw,
17821 .values = {
17822 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17823 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17824 0
17825 },
17826};
17827
17828static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17829 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17830 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17831 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17832 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17833 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17834 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17835 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17836 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17837 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17838 { } /* end */
17839};
17840
17841static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17842 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17843 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17844 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17845 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17846 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17847 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17848 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17849 { } /* end */
17850};
17851
17852
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017853static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17854 {
17855 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17856 .name = "Channel Mode",
17857 .info = alc_ch_mode_info,
17858 .get = alc_ch_mode_get,
17859 .put = alc_ch_mode_put,
17860 },
17861 { } /* end */
17862};
17863
17864static struct hda_verb alc662_init_verbs[] = {
17865 /* ADC: mute amp left and right */
17866 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17867 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017868
Kailang Yangb60dd392007-09-20 12:50:29 +020017869 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17870 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17871 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17872 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17873 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17874 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017875
17876 /* Front Pin: output 0 (0x0c) */
17877 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17878 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17879
17880 /* Rear Pin: output 1 (0x0d) */
17881 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17882 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17883
17884 /* CLFE Pin: output 2 (0x0e) */
17885 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17886 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17887
17888 /* Mic (rear) pin: input vref at 80% */
17889 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17890 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17891 /* Front Mic pin: input vref at 80% */
17892 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17893 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17894 /* Line In pin: input */
17895 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17896 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17897 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17898 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17899 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17900 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17901 /* CD pin widget for input */
17902 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17903
17904 /* FIXME: use matrix-type input source selection */
17905 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17906 /* Input mixer */
17907 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017908 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017909
17910 /* always trun on EAPD */
17911 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17912 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17913
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017914 { }
17915};
17916
Kailang Yangcec27c82010-02-04 14:18:18 +010017917static struct hda_verb alc663_init_verbs[] = {
17918 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17919 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17920 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17921 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17922 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17923 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17924 { }
17925};
17926
17927static struct hda_verb alc272_init_verbs[] = {
17928 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17929 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17930 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17931 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17932 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17933 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17934 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17935 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17936 { }
17937};
17938
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017939static struct hda_verb alc662_sue_init_verbs[] = {
17940 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17941 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017942 {}
17943};
17944
17945static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17946 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17947 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17948 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017949};
17950
Kailang Yang8c427222008-01-10 13:03:59 +010017951/* Set Unsolicited Event*/
17952static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17953 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17954 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17955 {}
17956};
17957
Kailang Yang6dda9f42008-05-27 12:05:31 +020017958static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017959 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17960 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017961 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17962 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017963 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17964 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17965 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017966 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17967 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17968 {}
17969};
17970
Kailang Yangf1d4e282008-08-26 14:03:29 +020017971static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17972 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17973 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17974 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17975 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17976 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17977 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17978 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17979 {}
17980};
17981
17982static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17983 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17984 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17985 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17986 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* 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 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17991 {}
17992};
17993
17994static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17995 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17996 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17997 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17998 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17999 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18000 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18001 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18002 {}
18003};
18004
18005static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
18006 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18007 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18008 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18009 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
18010 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18011 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18012 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
18013 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18014 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18015 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18016 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18017 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18018 {}
18019};
18020
18021static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
18022 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18023 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18024 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18025 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18026 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18027 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18028 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18029 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18030 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18031 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18032 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18033 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18034 {}
18035};
18036
Kailang Yang6dda9f42008-05-27 12:05:31 +020018037static struct hda_verb alc663_g71v_init_verbs[] = {
18038 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18039 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
18040 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
18041
18042 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18043 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18044 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18045
18046 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
18047 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
18048 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
18049 {}
18050};
18051
18052static struct hda_verb alc663_g50v_init_verbs[] = {
18053 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18054 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18055 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18056
18057 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18058 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18059 {}
18060};
18061
Kailang Yangf1d4e282008-08-26 14:03:29 +020018062static struct hda_verb alc662_ecs_init_verbs[] = {
18063 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
18064 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18065 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18066 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18067 {}
18068};
18069
Kailang Yang622e84c2009-04-21 07:39:04 +020018070static struct hda_verb alc272_dell_zm1_init_verbs[] = {
18071 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18072 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18073 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18074 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18075 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18076 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18077 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18078 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18079 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18080 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18081 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18082 {}
18083};
18084
18085static struct hda_verb alc272_dell_init_verbs[] = {
18086 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18087 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18088 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18089 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18090 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18091 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18092 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18093 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18094 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18095 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18096 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18097 {}
18098};
18099
Kailang Yangebb83ee2009-12-17 12:23:00 +010018100static struct hda_verb alc663_mode7_init_verbs[] = {
18101 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18102 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18103 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18104 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18105 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18106 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18107 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
18108 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18109 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18110 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18111 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18112 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18113 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18114 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18115 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18116 {}
18117};
18118
18119static struct hda_verb alc663_mode8_init_verbs[] = {
18120 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18121 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18122 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18123 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
18124 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18125 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18126 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18127 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18128 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18129 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18130 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18131 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18132 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18133 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18134 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18135 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18136 {}
18137};
18138
Kailang Yangf1d4e282008-08-26 14:03:29 +020018139static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
18140 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
18141 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
18142 { } /* end */
18143};
18144
Kailang Yang622e84c2009-04-21 07:39:04 +020018145static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
18146 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
18147 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
18148 { } /* end */
18149};
18150
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018151static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
18152{
18153 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018154 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018155
Wu Fengguang864f92b2009-11-18 12:38:02 +080018156 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018157 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018158
Takashi Iwai47fd8302007-08-10 17:11:07 +020018159 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18160 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018161}
18162
18163static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
18164{
18165 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018166 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018167
Wu Fengguang864f92b2009-11-18 12:38:02 +080018168 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018169 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018170
Takashi Iwai47fd8302007-08-10 17:11:07 +020018171 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18172 HDA_AMP_MUTE, bits);
18173 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18174 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018175}
18176
18177static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
18178 unsigned int res)
18179{
18180 if ((res >> 26) == ALC880_HP_EVENT)
18181 alc662_lenovo_101e_all_automute(codec);
18182 if ((res >> 26) == ALC880_FRONT_EVENT)
18183 alc662_lenovo_101e_ispeaker_automute(codec);
18184}
18185
Kailang Yang291702f2007-10-16 14:28:03 +020018186/* unsolicited event for HP jack sensing */
18187static void alc662_eeepc_unsol_event(struct hda_codec *codec,
18188 unsigned int res)
18189{
Kailang Yang291702f2007-10-16 14:28:03 +020018190 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018191 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020018192 else
18193 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020018194}
18195
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018196static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020018197{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018198 struct alc_spec *spec = codec->spec;
18199
18200 alc262_hippo1_setup(codec);
18201 spec->ext_mic.pin = 0x18;
18202 spec->ext_mic.mux_idx = 0;
18203 spec->int_mic.pin = 0x19;
18204 spec->int_mic.mux_idx = 1;
18205 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020018206}
18207
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018208static void alc662_eeepc_inithook(struct hda_codec *codec)
18209{
18210 alc262_hippo_automute(codec);
18211 alc_mic_automute(codec);
18212}
18213
18214static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010018215{
Takashi Iwai42171c12009-05-08 14:11:43 +020018216 struct alc_spec *spec = codec->spec;
18217
18218 spec->autocfg.hp_pins[0] = 0x14;
18219 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010018220}
18221
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018222#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
18223
Kailang Yang6dda9f42008-05-27 12:05:31 +020018224static void alc663_m51va_speaker_automute(struct hda_codec *codec)
18225{
18226 unsigned int present;
18227 unsigned char bits;
18228
Wu Fengguang864f92b2009-11-18 12:38:02 +080018229 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018230 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018231 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018232 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018233 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018234 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018235}
18236
18237static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
18238{
18239 unsigned int present;
18240 unsigned char bits;
18241
Wu Fengguang864f92b2009-11-18 12:38:02 +080018242 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018243 bits = present ? HDA_AMP_MUTE : 0;
18244 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018245 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018246 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018247 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018248 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018249 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018250 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018251 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018252}
18253
18254static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
18255{
18256 unsigned int present;
18257 unsigned char bits;
18258
Wu Fengguang864f92b2009-11-18 12:38:02 +080018259 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018260 bits = present ? HDA_AMP_MUTE : 0;
18261 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018262 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018263 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018264 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018265 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018266 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018267 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018268 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018269}
18270
18271static void alc662_f5z_speaker_automute(struct hda_codec *codec)
18272{
18273 unsigned int present;
18274 unsigned char bits;
18275
Wu Fengguang864f92b2009-11-18 12:38:02 +080018276 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018277 bits = present ? 0 : PIN_OUT;
18278 snd_hda_codec_write(codec, 0x14, 0,
18279 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
18280}
18281
18282static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
18283{
18284 unsigned int present1, present2;
18285
Wu Fengguang864f92b2009-11-18 12:38:02 +080018286 present1 = snd_hda_jack_detect(codec, 0x21);
18287 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018288
18289 if (present1 || present2) {
18290 snd_hda_codec_write_cache(codec, 0x14, 0,
18291 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18292 } else {
18293 snd_hda_codec_write_cache(codec, 0x14, 0,
18294 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18295 }
18296}
18297
18298static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
18299{
18300 unsigned int present1, present2;
18301
Wu Fengguang864f92b2009-11-18 12:38:02 +080018302 present1 = snd_hda_jack_detect(codec, 0x1b);
18303 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018304
18305 if (present1 || present2) {
18306 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018307 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018308 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018309 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018310 } else {
18311 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018312 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018313 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018314 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018315 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020018316}
18317
Kailang Yangebb83ee2009-12-17 12:23:00 +010018318static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
18319{
18320 unsigned int present1, present2;
18321
18322 present1 = snd_hda_codec_read(codec, 0x1b, 0,
18323 AC_VERB_GET_PIN_SENSE, 0)
18324 & AC_PINSENSE_PRESENCE;
18325 present2 = snd_hda_codec_read(codec, 0x21, 0,
18326 AC_VERB_GET_PIN_SENSE, 0)
18327 & AC_PINSENSE_PRESENCE;
18328
18329 if (present1 || present2) {
18330 snd_hda_codec_write_cache(codec, 0x14, 0,
18331 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18332 snd_hda_codec_write_cache(codec, 0x17, 0,
18333 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18334 } else {
18335 snd_hda_codec_write_cache(codec, 0x14, 0,
18336 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18337 snd_hda_codec_write_cache(codec, 0x17, 0,
18338 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18339 }
18340}
18341
18342static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
18343{
18344 unsigned int present1, present2;
18345
18346 present1 = snd_hda_codec_read(codec, 0x21, 0,
18347 AC_VERB_GET_PIN_SENSE, 0)
18348 & AC_PINSENSE_PRESENCE;
18349 present2 = snd_hda_codec_read(codec, 0x15, 0,
18350 AC_VERB_GET_PIN_SENSE, 0)
18351 & AC_PINSENSE_PRESENCE;
18352
18353 if (present1 || present2) {
18354 snd_hda_codec_write_cache(codec, 0x14, 0,
18355 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18356 snd_hda_codec_write_cache(codec, 0x17, 0,
18357 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18358 } else {
18359 snd_hda_codec_write_cache(codec, 0x14, 0,
18360 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18361 snd_hda_codec_write_cache(codec, 0x17, 0,
18362 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18363 }
18364}
18365
Kailang Yang6dda9f42008-05-27 12:05:31 +020018366static void alc663_m51va_unsol_event(struct hda_codec *codec,
18367 unsigned int res)
18368{
18369 switch (res >> 26) {
18370 case ALC880_HP_EVENT:
18371 alc663_m51va_speaker_automute(codec);
18372 break;
18373 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018374 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018375 break;
18376 }
18377}
18378
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018379static void alc663_m51va_setup(struct hda_codec *codec)
18380{
18381 struct alc_spec *spec = codec->spec;
18382 spec->ext_mic.pin = 0x18;
18383 spec->ext_mic.mux_idx = 0;
18384 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018385 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018386 spec->auto_mic = 1;
18387}
18388
Kailang Yang6dda9f42008-05-27 12:05:31 +020018389static void alc663_m51va_inithook(struct hda_codec *codec)
18390{
18391 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018392 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018393}
18394
Kailang Yangf1d4e282008-08-26 14:03:29 +020018395/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018396#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010018397
18398static void alc663_mode1_setup(struct hda_codec *codec)
18399{
18400 struct alc_spec *spec = codec->spec;
18401 spec->ext_mic.pin = 0x18;
18402 spec->ext_mic.mux_idx = 0;
18403 spec->int_mic.pin = 0x19;
18404 spec->int_mic.mux_idx = 1;
18405 spec->auto_mic = 1;
18406}
18407
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018408#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020018409
Kailang Yangf1d4e282008-08-26 14:03:29 +020018410/* ***************** Mode2 ******************************/
18411static void alc662_mode2_unsol_event(struct hda_codec *codec,
18412 unsigned int res)
18413{
18414 switch (res >> 26) {
18415 case ALC880_HP_EVENT:
18416 alc662_f5z_speaker_automute(codec);
18417 break;
18418 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018419 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018420 break;
18421 }
18422}
18423
Kailang Yangebb83ee2009-12-17 12:23:00 +010018424#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018425
Kailang Yangf1d4e282008-08-26 14:03:29 +020018426static void alc662_mode2_inithook(struct hda_codec *codec)
18427{
18428 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018429 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018430}
18431/* ***************** Mode3 ******************************/
18432static void alc663_mode3_unsol_event(struct hda_codec *codec,
18433 unsigned int res)
18434{
18435 switch (res >> 26) {
18436 case ALC880_HP_EVENT:
18437 alc663_two_hp_m1_speaker_automute(codec);
18438 break;
18439 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018440 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018441 break;
18442 }
18443}
18444
Kailang Yangebb83ee2009-12-17 12:23:00 +010018445#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018446
Kailang Yangf1d4e282008-08-26 14:03:29 +020018447static void alc663_mode3_inithook(struct hda_codec *codec)
18448{
18449 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018450 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018451}
18452/* ***************** Mode4 ******************************/
18453static void alc663_mode4_unsol_event(struct hda_codec *codec,
18454 unsigned int res)
18455{
18456 switch (res >> 26) {
18457 case ALC880_HP_EVENT:
18458 alc663_21jd_two_speaker_automute(codec);
18459 break;
18460 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018461 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018462 break;
18463 }
18464}
18465
Kailang Yangebb83ee2009-12-17 12:23:00 +010018466#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018467
Kailang Yangf1d4e282008-08-26 14:03:29 +020018468static void alc663_mode4_inithook(struct hda_codec *codec)
18469{
18470 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018471 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018472}
18473/* ***************** Mode5 ******************************/
18474static void alc663_mode5_unsol_event(struct hda_codec *codec,
18475 unsigned int res)
18476{
18477 switch (res >> 26) {
18478 case ALC880_HP_EVENT:
18479 alc663_15jd_two_speaker_automute(codec);
18480 break;
18481 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018482 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018483 break;
18484 }
18485}
18486
Kailang Yangebb83ee2009-12-17 12:23:00 +010018487#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018488
Kailang Yangf1d4e282008-08-26 14:03:29 +020018489static void alc663_mode5_inithook(struct hda_codec *codec)
18490{
18491 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018492 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018493}
18494/* ***************** Mode6 ******************************/
18495static void alc663_mode6_unsol_event(struct hda_codec *codec,
18496 unsigned int res)
18497{
18498 switch (res >> 26) {
18499 case ALC880_HP_EVENT:
18500 alc663_two_hp_m2_speaker_automute(codec);
18501 break;
18502 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018503 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018504 break;
18505 }
18506}
18507
Kailang Yangebb83ee2009-12-17 12:23:00 +010018508#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018509
Kailang Yangf1d4e282008-08-26 14:03:29 +020018510static void alc663_mode6_inithook(struct hda_codec *codec)
18511{
18512 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018513 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018514}
18515
Kailang Yangebb83ee2009-12-17 12:23:00 +010018516/* ***************** Mode7 ******************************/
18517static void alc663_mode7_unsol_event(struct hda_codec *codec,
18518 unsigned int res)
18519{
18520 switch (res >> 26) {
18521 case ALC880_HP_EVENT:
18522 alc663_two_hp_m7_speaker_automute(codec);
18523 break;
18524 case ALC880_MIC_EVENT:
18525 alc_mic_automute(codec);
18526 break;
18527 }
18528}
18529
18530#define alc663_mode7_setup alc663_mode1_setup
18531
18532static void alc663_mode7_inithook(struct hda_codec *codec)
18533{
18534 alc663_two_hp_m7_speaker_automute(codec);
18535 alc_mic_automute(codec);
18536}
18537
18538/* ***************** Mode8 ******************************/
18539static void alc663_mode8_unsol_event(struct hda_codec *codec,
18540 unsigned int res)
18541{
18542 switch (res >> 26) {
18543 case ALC880_HP_EVENT:
18544 alc663_two_hp_m8_speaker_automute(codec);
18545 break;
18546 case ALC880_MIC_EVENT:
18547 alc_mic_automute(codec);
18548 break;
18549 }
18550}
18551
18552#define alc663_mode8_setup alc663_m51va_setup
18553
18554static void alc663_mode8_inithook(struct hda_codec *codec)
18555{
18556 alc663_two_hp_m8_speaker_automute(codec);
18557 alc_mic_automute(codec);
18558}
18559
Kailang Yang6dda9f42008-05-27 12:05:31 +020018560static void alc663_g71v_hp_automute(struct hda_codec *codec)
18561{
18562 unsigned int present;
18563 unsigned char bits;
18564
Wu Fengguang864f92b2009-11-18 12:38:02 +080018565 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018566 bits = present ? HDA_AMP_MUTE : 0;
18567 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18568 HDA_AMP_MUTE, bits);
18569 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18570 HDA_AMP_MUTE, bits);
18571}
18572
18573static void alc663_g71v_front_automute(struct hda_codec *codec)
18574{
18575 unsigned int present;
18576 unsigned char bits;
18577
Wu Fengguang864f92b2009-11-18 12:38:02 +080018578 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018579 bits = present ? HDA_AMP_MUTE : 0;
18580 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18581 HDA_AMP_MUTE, bits);
18582}
18583
18584static void alc663_g71v_unsol_event(struct hda_codec *codec,
18585 unsigned int res)
18586{
18587 switch (res >> 26) {
18588 case ALC880_HP_EVENT:
18589 alc663_g71v_hp_automute(codec);
18590 break;
18591 case ALC880_FRONT_EVENT:
18592 alc663_g71v_front_automute(codec);
18593 break;
18594 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018595 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018596 break;
18597 }
18598}
18599
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018600#define alc663_g71v_setup alc663_m51va_setup
18601
Kailang Yang6dda9f42008-05-27 12:05:31 +020018602static void alc663_g71v_inithook(struct hda_codec *codec)
18603{
18604 alc663_g71v_front_automute(codec);
18605 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018606 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018607}
18608
18609static void alc663_g50v_unsol_event(struct hda_codec *codec,
18610 unsigned int res)
18611{
18612 switch (res >> 26) {
18613 case ALC880_HP_EVENT:
18614 alc663_m51va_speaker_automute(codec);
18615 break;
18616 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018617 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018618 break;
18619 }
18620}
18621
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018622#define alc663_g50v_setup alc663_m51va_setup
18623
Kailang Yang6dda9f42008-05-27 12:05:31 +020018624static void alc663_g50v_inithook(struct hda_codec *codec)
18625{
18626 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018627 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018628}
18629
Kailang Yangf1d4e282008-08-26 14:03:29 +020018630static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18631 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018632 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018633
David Henningsson5f99f862011-01-04 15:24:24 +010018634 HDA_CODEC_VOLUME("Mic/LineIn Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018635 HDA_CODEC_VOLUME("Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18636 HDA_CODEC_MUTE("Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018637
David Henningsson5f99f862011-01-04 15:24:24 +010018638 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018639 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18640 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018641 { } /* end */
18642};
18643
Chris Pockelé9541ba12009-05-12 08:08:53 +020018644static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18645 /* Master Playback automatically created from Speaker and Headphone */
18646 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18647 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18648 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18649 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18650
David Henningsson8607f7c2010-12-20 14:43:54 +010018651 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18652 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018653 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018654
David Henningsson28c4edb2010-12-20 14:24:29 +010018655 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18656 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018657 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018658 { } /* end */
18659};
18660
Takashi Iwaicb53c622007-08-10 17:21:45 +020018661#ifdef CONFIG_SND_HDA_POWER_SAVE
18662#define alc662_loopbacks alc880_loopbacks
18663#endif
18664
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018665
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018666/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018667#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18668#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18669#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18670#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18671
18672/*
18673 * configuration and preset
18674 */
Takashi Iwaiea734962011-01-17 11:29:34 +010018675static const char * const alc662_models[ALC662_MODEL_LAST] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018676 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18677 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18678 [ALC662_3ST_6ch] = "3stack-6ch",
18679 [ALC662_5ST_DIG] = "6stack-dig",
18680 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018681 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018682 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018683 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018684 [ALC663_ASUS_M51VA] = "m51va",
18685 [ALC663_ASUS_G71V] = "g71v",
18686 [ALC663_ASUS_H13] = "h13",
18687 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018688 [ALC663_ASUS_MODE1] = "asus-mode1",
18689 [ALC662_ASUS_MODE2] = "asus-mode2",
18690 [ALC663_ASUS_MODE3] = "asus-mode3",
18691 [ALC663_ASUS_MODE4] = "asus-mode4",
18692 [ALC663_ASUS_MODE5] = "asus-mode5",
18693 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018694 [ALC663_ASUS_MODE7] = "asus-mode7",
18695 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018696 [ALC272_DELL] = "dell",
18697 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018698 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018699 [ALC662_AUTO] = "auto",
18700};
18701
18702static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018703 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018704 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18705 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018706 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18707 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018708 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018709 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18710 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18711 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18712 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018713 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18714 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018715 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018716 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18717 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18718 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18719 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18720 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018721 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018722 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18723 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018724 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18725 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18726 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18727 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018728 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018729 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18730 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18731 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018732 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18733 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18734 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18735 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018736 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018737 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18738 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018739 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018740 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18741 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18742 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018743 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018744 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018745 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18746 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018747 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18748 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18749 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018750 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018751 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18752 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018753 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018754 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018755 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018756 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18757 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18758 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018759 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018760 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18761 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018762 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018763 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018764 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018765 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018766 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18767 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018768 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018769 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018770 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18771 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018772 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018773 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018774 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018775 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018776 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018777 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018778 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18779 ALC663_ASUS_H13),
Anisse Astier965b76d2011-02-10 13:14:44 +010018780 SND_PCI_QUIRK(0x1991, 0x5628, "Ordissimo EVE", ALC662_LENOVO_101E),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018781 {}
18782};
18783
18784static struct alc_config_preset alc662_presets[] = {
18785 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018786 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018787 .init_verbs = { alc662_init_verbs },
18788 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18789 .dac_nids = alc662_dac_nids,
18790 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018791 .dig_in_nid = ALC662_DIGIN_NID,
18792 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18793 .channel_mode = alc662_3ST_2ch_modes,
18794 .input_mux = &alc662_capture_source,
18795 },
18796 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018797 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018798 .init_verbs = { alc662_init_verbs },
18799 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18800 .dac_nids = alc662_dac_nids,
18801 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018802 .dig_in_nid = ALC662_DIGIN_NID,
18803 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18804 .channel_mode = alc662_3ST_6ch_modes,
18805 .need_dac_fix = 1,
18806 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018807 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018808 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018809 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018810 .init_verbs = { alc662_init_verbs },
18811 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18812 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018813 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18814 .channel_mode = alc662_3ST_6ch_modes,
18815 .need_dac_fix = 1,
18816 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018817 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018818 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018819 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018820 .init_verbs = { alc662_init_verbs },
18821 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18822 .dac_nids = alc662_dac_nids,
18823 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018824 .dig_in_nid = ALC662_DIGIN_NID,
18825 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18826 .channel_mode = alc662_5stack_modes,
18827 .input_mux = &alc662_capture_source,
18828 },
18829 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018830 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018831 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18832 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18833 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018834 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18835 .channel_mode = alc662_3ST_2ch_modes,
18836 .input_mux = &alc662_lenovo_101e_capture_source,
18837 .unsol_event = alc662_lenovo_101e_unsol_event,
18838 .init_hook = alc662_lenovo_101e_all_automute,
18839 },
Kailang Yang291702f2007-10-16 14:28:03 +020018840 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018841 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018842 .init_verbs = { alc662_init_verbs,
18843 alc662_eeepc_sue_init_verbs },
18844 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18845 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018846 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18847 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018848 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018849 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018850 .init_hook = alc662_eeepc_inithook,
18851 },
Kailang Yang8c427222008-01-10 13:03:59 +010018852 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018853 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018854 alc662_chmode_mixer },
18855 .init_verbs = { alc662_init_verbs,
18856 alc662_eeepc_ep20_sue_init_verbs },
18857 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18858 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018859 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18860 .channel_mode = alc662_3ST_6ch_modes,
18861 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018862 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018863 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018864 .init_hook = alc662_eeepc_ep20_inithook,
18865 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018866 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018867 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018868 .init_verbs = { alc662_init_verbs,
18869 alc662_ecs_init_verbs },
18870 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18871 .dac_nids = alc662_dac_nids,
18872 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18873 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018874 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018875 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018876 .init_hook = alc662_eeepc_inithook,
18877 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018878 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018879 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018880 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18881 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18882 .dac_nids = alc662_dac_nids,
18883 .dig_out_nid = ALC662_DIGOUT_NID,
18884 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18885 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018886 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018887 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018888 .init_hook = alc663_m51va_inithook,
18889 },
18890 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018891 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018892 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18893 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18894 .dac_nids = alc662_dac_nids,
18895 .dig_out_nid = ALC662_DIGOUT_NID,
18896 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18897 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018898 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018899 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018900 .init_hook = alc663_g71v_inithook,
18901 },
18902 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018903 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018904 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18905 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18906 .dac_nids = alc662_dac_nids,
18907 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18908 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018909 .unsol_event = alc663_m51va_unsol_event,
18910 .init_hook = alc663_m51va_inithook,
18911 },
18912 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018913 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018914 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18915 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18916 .dac_nids = alc662_dac_nids,
18917 .dig_out_nid = ALC662_DIGOUT_NID,
18918 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18919 .channel_mode = alc662_3ST_6ch_modes,
18920 .input_mux = &alc663_capture_source,
18921 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018922 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018923 .init_hook = alc663_g50v_inithook,
18924 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018925 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018926 .mixers = { alc663_m51va_mixer },
18927 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018928 .init_verbs = { alc662_init_verbs,
18929 alc663_21jd_amic_init_verbs },
18930 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18931 .hp_nid = 0x03,
18932 .dac_nids = alc662_dac_nids,
18933 .dig_out_nid = ALC662_DIGOUT_NID,
18934 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18935 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018936 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018937 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018938 .init_hook = alc663_mode1_inithook,
18939 },
18940 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018941 .mixers = { alc662_1bjd_mixer },
18942 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018943 .init_verbs = { alc662_init_verbs,
18944 alc662_1bjd_amic_init_verbs },
18945 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18946 .dac_nids = alc662_dac_nids,
18947 .dig_out_nid = ALC662_DIGOUT_NID,
18948 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18949 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018950 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018951 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018952 .init_hook = alc662_mode2_inithook,
18953 },
18954 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018955 .mixers = { alc663_two_hp_m1_mixer },
18956 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018957 .init_verbs = { alc662_init_verbs,
18958 alc663_two_hp_amic_m1_init_verbs },
18959 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18960 .hp_nid = 0x03,
18961 .dac_nids = alc662_dac_nids,
18962 .dig_out_nid = ALC662_DIGOUT_NID,
18963 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18964 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018965 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018966 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018967 .init_hook = alc663_mode3_inithook,
18968 },
18969 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018970 .mixers = { alc663_asus_21jd_clfe_mixer },
18971 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018972 .init_verbs = { alc662_init_verbs,
18973 alc663_21jd_amic_init_verbs},
18974 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18975 .hp_nid = 0x03,
18976 .dac_nids = alc662_dac_nids,
18977 .dig_out_nid = ALC662_DIGOUT_NID,
18978 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18979 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018980 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018981 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018982 .init_hook = alc663_mode4_inithook,
18983 },
18984 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018985 .mixers = { alc663_asus_15jd_clfe_mixer },
18986 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018987 .init_verbs = { alc662_init_verbs,
18988 alc663_15jd_amic_init_verbs },
18989 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18990 .hp_nid = 0x03,
18991 .dac_nids = alc662_dac_nids,
18992 .dig_out_nid = ALC662_DIGOUT_NID,
18993 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18994 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018995 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018996 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018997 .init_hook = alc663_mode5_inithook,
18998 },
18999 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019000 .mixers = { alc663_two_hp_m2_mixer },
19001 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019002 .init_verbs = { alc662_init_verbs,
19003 alc663_two_hp_amic_m2_init_verbs },
19004 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
19005 .hp_nid = 0x03,
19006 .dac_nids = alc662_dac_nids,
19007 .dig_out_nid = ALC662_DIGOUT_NID,
19008 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19009 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019010 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019011 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019012 .init_hook = alc663_mode6_inithook,
19013 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019014 [ALC663_ASUS_MODE7] = {
19015 .mixers = { alc663_mode7_mixer },
19016 .cap_mixer = alc662_auto_capture_mixer,
19017 .init_verbs = { alc662_init_verbs,
19018 alc663_mode7_init_verbs },
19019 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
19020 .hp_nid = 0x03,
19021 .dac_nids = alc662_dac_nids,
19022 .dig_out_nid = ALC662_DIGOUT_NID,
19023 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19024 .channel_mode = alc662_3ST_2ch_modes,
19025 .unsol_event = alc663_mode7_unsol_event,
19026 .setup = alc663_mode7_setup,
19027 .init_hook = alc663_mode7_inithook,
19028 },
19029 [ALC663_ASUS_MODE8] = {
19030 .mixers = { alc663_mode8_mixer },
19031 .cap_mixer = alc662_auto_capture_mixer,
19032 .init_verbs = { alc662_init_verbs,
19033 alc663_mode8_init_verbs },
19034 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
19035 .hp_nid = 0x03,
19036 .dac_nids = alc662_dac_nids,
19037 .dig_out_nid = ALC662_DIGOUT_NID,
19038 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19039 .channel_mode = alc662_3ST_2ch_modes,
19040 .unsol_event = alc663_mode8_unsol_event,
19041 .setup = alc663_mode8_setup,
19042 .init_hook = alc663_mode8_inithook,
19043 },
Kailang Yang622e84c2009-04-21 07:39:04 +020019044 [ALC272_DELL] = {
19045 .mixers = { alc663_m51va_mixer },
19046 .cap_mixer = alc272_auto_capture_mixer,
19047 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
19048 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19049 .dac_nids = alc662_dac_nids,
19050 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19051 .adc_nids = alc272_adc_nids,
19052 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
19053 .capsrc_nids = alc272_capsrc_nids,
19054 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020019055 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019056 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020019057 .init_hook = alc663_m51va_inithook,
19058 },
19059 [ALC272_DELL_ZM1] = {
19060 .mixers = { alc663_m51va_mixer },
19061 .cap_mixer = alc662_auto_capture_mixer,
19062 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
19063 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19064 .dac_nids = alc662_dac_nids,
19065 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19066 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019067 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020019068 .capsrc_nids = alc662_capsrc_nids,
19069 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020019070 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019071 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020019072 .init_hook = alc663_m51va_inithook,
19073 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020019074 [ALC272_SAMSUNG_NC10] = {
19075 .mixers = { alc272_nc10_mixer },
19076 .init_verbs = { alc662_init_verbs,
19077 alc663_21jd_amic_init_verbs },
19078 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19079 .dac_nids = alc272_dac_nids,
19080 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19081 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019082 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020019083 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019084 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020019085 .init_hook = alc663_mode4_inithook,
19086 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019087};
19088
19089
19090/*
19091 * BIOS auto configuration
19092 */
19093
Takashi Iwai7085ec12009-10-02 09:03:58 +020019094/* convert from MIX nid to DAC */
19095static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
19096{
19097 if (nid == 0x0f)
19098 return 0x02;
19099 else if (nid >= 0x0c && nid <= 0x0e)
19100 return nid - 0x0c + 0x02;
David Henningssoncc1c4522010-11-24 14:17:47 +010019101 else if (nid == 0x26) /* ALC887-VD has this DAC too */
19102 return 0x25;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019103 else
19104 return 0;
19105}
19106
19107/* get MIX nid connected to the given pin targeted to DAC */
19108static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
19109 hda_nid_t dac)
19110{
David Henningssoncc1c4522010-11-24 14:17:47 +010019111 hda_nid_t mix[5];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019112 int i, num;
19113
19114 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
19115 for (i = 0; i < num; i++) {
19116 if (alc662_mix_to_dac(mix[i]) == dac)
19117 return mix[i];
19118 }
19119 return 0;
19120}
19121
19122/* look for an empty DAC slot */
19123static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
19124{
19125 struct alc_spec *spec = codec->spec;
19126 hda_nid_t srcs[5];
19127 int i, j, num;
19128
19129 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
19130 if (num < 0)
19131 return 0;
19132 for (i = 0; i < num; i++) {
19133 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
19134 if (!nid)
19135 continue;
19136 for (j = 0; j < spec->multiout.num_dacs; j++)
19137 if (spec->multiout.dac_nids[j] == nid)
19138 break;
19139 if (j >= spec->multiout.num_dacs)
19140 return nid;
19141 }
19142 return 0;
19143}
19144
19145/* fill in the dac_nids table from the parsed pin configuration */
19146static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
19147 const struct auto_pin_cfg *cfg)
19148{
19149 struct alc_spec *spec = codec->spec;
19150 int i;
19151 hda_nid_t dac;
19152
19153 spec->multiout.dac_nids = spec->private_dac_nids;
19154 for (i = 0; i < cfg->line_outs; i++) {
19155 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
19156 if (!dac)
19157 continue;
19158 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19159 }
19160 return 0;
19161}
19162
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019163static inline int __alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
19164 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019165{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019166 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019167 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
19168}
19169
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019170static inline int __alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
19171 hda_nid_t nid, int idx, unsigned int chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019172{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019173 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019174 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
19175}
19176
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019177#define alc662_add_vol_ctl(spec, pfx, nid, chs) \
19178 __alc662_add_vol_ctl(spec, pfx, nid, 0, chs)
19179#define alc662_add_sw_ctl(spec, pfx, nid, chs) \
19180 __alc662_add_sw_ctl(spec, pfx, nid, 0, chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019181#define alc662_add_stereo_vol(spec, pfx, nid) \
19182 alc662_add_vol_ctl(spec, pfx, nid, 3)
19183#define alc662_add_stereo_sw(spec, pfx, nid) \
19184 alc662_add_sw_ctl(spec, pfx, nid, 3)
19185
19186/* add playback controls from the parsed DAC table */
19187static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
19188 const struct auto_pin_cfg *cfg)
19189{
19190 struct alc_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +010019191 static const char * const chname[4] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019192 "Front", "Surround", NULL /*CLFE*/, "Side"
19193 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019194 const char *pfx = alc_get_line_out_pfx(cfg, true);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019195 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019196 int i, err;
19197
19198 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019199 nid = spec->multiout.dac_nids[i];
19200 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019201 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019202 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
19203 if (!mix)
19204 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019205 if (!pfx && i == 2) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019206 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019207 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019208 if (err < 0)
19209 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019210 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019211 if (err < 0)
19212 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019213 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019214 if (err < 0)
19215 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019216 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019217 if (err < 0)
19218 return err;
19219 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019220 const char *name = pfx;
19221 if (!name)
19222 name = chname[i];
19223 err = __alc662_add_vol_ctl(spec, name, nid, i, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019224 if (err < 0)
19225 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019226 err = __alc662_add_sw_ctl(spec, name, mix, i, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019227 if (err < 0)
19228 return err;
19229 }
19230 }
19231 return 0;
19232}
19233
19234/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019235/* return DAC nid if any new DAC is assigned */
19236static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019237 const char *pfx)
19238{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019239 struct alc_spec *spec = codec->spec;
19240 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019241 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019242
19243 if (!pin)
19244 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019245 nid = alc662_look_for_dac(codec, pin);
19246 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019247 /* the corresponding DAC is already occupied */
19248 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
19249 return 0; /* no way */
19250 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019251 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019252 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19253 }
19254
19255 mix = alc662_dac_to_mix(codec, pin, nid);
19256 if (!mix)
19257 return 0;
19258 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
19259 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020019260 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019261 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
19262 if (err < 0)
19263 return err;
19264 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019265}
19266
19267/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020019268#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020019269 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019270
19271static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
19272 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019273 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019274{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019275 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020019276 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019277
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019278 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019279 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019280 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
19281 if (num <= 1)
19282 return;
19283 for (i = 0; i < num; i++) {
19284 if (alc662_mix_to_dac(srcs[i]) != dac)
19285 continue;
19286 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
19287 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019288 }
19289}
19290
19291static void alc662_auto_init_multi_out(struct hda_codec *codec)
19292{
19293 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019294 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019295 int i;
19296
19297 for (i = 0; i <= HDA_SIDE; i++) {
19298 hda_nid_t nid = spec->autocfg.line_out_pins[i];
19299 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020019300 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019301 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019302 }
19303}
19304
19305static void alc662_auto_init_hp_out(struct hda_codec *codec)
19306{
19307 struct alc_spec *spec = codec->spec;
19308 hda_nid_t pin;
19309
19310 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019311 if (pin)
19312 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
19313 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019314 pin = spec->autocfg.speaker_pins[0];
19315 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019316 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
19317 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019318}
19319
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019320#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
19321
19322static void alc662_auto_init_analog_input(struct hda_codec *codec)
19323{
19324 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019325 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019326 int i;
19327
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019328 for (i = 0; i < cfg->num_inputs; i++) {
19329 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019330 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020019331 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010019332 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010019333 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019334 snd_hda_codec_write(codec, nid, 0,
19335 AC_VERB_SET_AMP_GAIN_MUTE,
19336 AMP_OUT_MUTE);
19337 }
19338 }
19339}
19340
Takashi Iwaif511b012008-08-15 16:46:42 +020019341#define alc662_auto_init_input_src alc882_auto_init_input_src
19342
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019343static int alc662_parse_auto_config(struct hda_codec *codec)
19344{
19345 struct alc_spec *spec = codec->spec;
19346 int err;
19347 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
19348
19349 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19350 alc662_ignore);
19351 if (err < 0)
19352 return err;
19353 if (!spec->autocfg.line_outs)
19354 return 0; /* can't find valid BIOS pin config */
19355
Takashi Iwai7085ec12009-10-02 09:03:58 +020019356 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019357 if (err < 0)
19358 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019359 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019360 if (err < 0)
19361 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019362 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019363 spec->autocfg.speaker_pins[0],
19364 "Speaker");
19365 if (err < 0)
19366 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019367 if (err)
19368 spec->multiout.extra_out_nid[0] = err;
19369 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019370 "Headphone");
19371 if (err < 0)
19372 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019373 if (err)
19374 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019375 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019376 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019377 return err;
19378
19379 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
19380
Takashi Iwai757899a2010-07-30 10:48:14 +020019381 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019382
Takashi Iwai603c4012008-07-30 15:01:44 +020019383 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010019384 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019385
19386 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020019387 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020019388
Kailang Yangcec27c82010-02-04 14:18:18 +010019389 add_verb(spec, alc662_init_verbs);
19390 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019391 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Kailang Yangcec27c82010-02-04 14:18:18 +010019392 add_verb(spec, alc663_init_verbs);
19393
19394 if (codec->vendor_id == 0x10ec0272)
19395 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020019396
19397 err = alc_auto_add_mic_boost(codec);
19398 if (err < 0)
19399 return err;
19400
Kailang Yang6227cdc2010-02-25 08:36:52 +010019401 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
19402 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
19403 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
19404 else
19405 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020019406
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019407 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019408}
19409
19410/* additional initialization for auto-configuration model */
19411static void alc662_auto_init(struct hda_codec *codec)
19412{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019413 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019414 alc662_auto_init_multi_out(codec);
19415 alc662_auto_init_hp_out(codec);
19416 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020019417 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019418 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019419 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020019420 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019421}
19422
Todd Broch6be79482010-12-07 16:51:05 -080019423static void alc272_fixup_mario(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019424 const struct alc_fixup *fix, int action)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010019425{
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019426 if (action != ALC_FIXUP_ACT_PROBE)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010019427 return;
Todd Broch6be79482010-12-07 16:51:05 -080019428 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
19429 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
19430 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
19431 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
19432 (0 << AC_AMPCAP_MUTE_SHIFT)))
19433 printk(KERN_WARNING
19434 "hda_codec: failed to override amp caps for NID 0x2\n");
19435}
19436
David Henningsson6cb3b702010-09-09 08:51:44 +020019437enum {
Daniel T Chen2df03512010-10-10 22:39:28 -040019438 ALC662_FIXUP_ASPIRE,
David Henningsson6cb3b702010-09-09 08:51:44 +020019439 ALC662_FIXUP_IDEAPAD,
Todd Broch6be79482010-12-07 16:51:05 -080019440 ALC272_FIXUP_MARIO,
Anisse Astierd2ebd472011-01-20 12:36:21 +010019441 ALC662_FIXUP_CZC_P10T,
David Henningsson6cb3b702010-09-09 08:51:44 +020019442};
19443
19444static const struct alc_fixup alc662_fixups[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019445 [ALC662_FIXUP_ASPIRE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019446 .type = ALC_FIXUP_PINS,
19447 .v.pins = (const struct alc_pincfg[]) {
Daniel T Chen2df03512010-10-10 22:39:28 -040019448 { 0x15, 0x99130112 }, /* subwoofer */
19449 { }
19450 }
19451 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019452 [ALC662_FIXUP_IDEAPAD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019453 .type = ALC_FIXUP_PINS,
19454 .v.pins = (const struct alc_pincfg[]) {
David Henningsson6cb3b702010-09-09 08:51:44 +020019455 { 0x17, 0x99130112 }, /* subwoofer */
19456 { }
19457 }
19458 },
Todd Broch6be79482010-12-07 16:51:05 -080019459 [ALC272_FIXUP_MARIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019460 .type = ALC_FIXUP_FUNC,
19461 .v.func = alc272_fixup_mario,
Anisse Astierd2ebd472011-01-20 12:36:21 +010019462 },
19463 [ALC662_FIXUP_CZC_P10T] = {
19464 .type = ALC_FIXUP_VERBS,
19465 .v.verbs = (const struct hda_verb[]) {
19466 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
19467 {}
19468 }
19469 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019470};
19471
19472static struct snd_pci_quirk alc662_fixup_tbl[] = {
David Henningssona6c47a82011-02-10 15:39:19 +010019473 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
Daniel T Chen2df03512010-10-10 22:39:28 -040019474 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
Daniel T Chena0e90ac2010-11-20 10:20:35 -050019475 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
Valentine Sinitsynd4118582010-10-01 22:24:08 +060019476 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
David Henningsson6cb3b702010-09-09 08:51:44 +020019477 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
Anisse Astierd2ebd472011-01-20 12:36:21 +010019478 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
David Henningsson6cb3b702010-09-09 08:51:44 +020019479 {}
19480};
19481
Todd Broch6be79482010-12-07 16:51:05 -080019482static const struct alc_model_fixup alc662_fixup_models[] = {
19483 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
19484 {}
19485};
David Henningsson6cb3b702010-09-09 08:51:44 +020019486
19487
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019488static int patch_alc662(struct hda_codec *codec)
19489{
19490 struct alc_spec *spec;
19491 int err, board_config;
Kailang Yang693194f2010-10-21 08:51:48 +020019492 int coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019493
19494 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19495 if (!spec)
19496 return -ENOMEM;
19497
19498 codec->spec = spec;
19499
Kailang Yangda00c242010-03-19 11:23:45 +010019500 alc_auto_parse_customize_define(codec);
19501
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020019502 alc_fix_pll_init(codec, 0x20, 0x04, 15);
19503
Kailang Yang693194f2010-10-21 08:51:48 +020019504 coef = alc_read_coef_idx(codec, 0);
19505 if (coef == 0x8020 || coef == 0x8011)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019506 alc_codec_rename(codec, "ALC661");
Kailang Yang693194f2010-10-21 08:51:48 +020019507 else if (coef & (1 << 14) &&
19508 codec->bus->pci->subsystem_vendor == 0x1025 &&
19509 spec->cdefine.platform_type == 1)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019510 alc_codec_rename(codec, "ALC272X");
Kailang Yang693194f2010-10-21 08:51:48 +020019511 else if (coef == 0x4011)
19512 alc_codec_rename(codec, "ALC656");
Kailang Yang274693f2009-12-03 10:07:50 +010019513
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019514 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19515 alc662_models,
19516 alc662_cfg_tbl);
19517 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019518 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19519 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019520 board_config = ALC662_AUTO;
19521 }
19522
19523 if (board_config == ALC662_AUTO) {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019524 alc_pick_fixup(codec, alc662_fixup_models,
19525 alc662_fixup_tbl, alc662_fixups);
19526 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019527 /* automatic parse from the BIOS config */
19528 err = alc662_parse_auto_config(codec);
19529 if (err < 0) {
19530 alc_free(codec);
19531 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019532 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019533 printk(KERN_INFO
19534 "hda_codec: Cannot set up configuration "
19535 "from BIOS. Using base mode...\n");
19536 board_config = ALC662_3ST_2ch_DIG;
19537 }
19538 }
19539
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019540 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019541 err = snd_hda_attach_beep_device(codec, 0x1);
19542 if (err < 0) {
19543 alc_free(codec);
19544 return err;
19545 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019546 }
19547
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019548 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019549 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019550
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019551 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19552 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19553
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019554 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19555 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19556
Takashi Iwaidd704692009-08-11 08:45:11 +020019557 if (!spec->adc_nids) {
19558 spec->adc_nids = alc662_adc_nids;
19559 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19560 }
19561 if (!spec->capsrc_nids)
19562 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019563
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019564 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019565 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019566
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019567 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019568 switch (codec->vendor_id) {
19569 case 0x10ec0662:
19570 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19571 break;
19572 case 0x10ec0272:
19573 case 0x10ec0663:
19574 case 0x10ec0665:
19575 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19576 break;
19577 case 0x10ec0273:
19578 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19579 break;
19580 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019581 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019582 spec->vmaster_nid = 0x02;
19583
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019584 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
19585
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019586 codec->patch_ops = alc_patch_ops;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019587 if (board_config == ALC662_AUTO)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019588 spec->init_hook = alc662_auto_init;
David Henningsson6cb3b702010-09-09 08:51:44 +020019589
Kailang Yangbf1b0222010-10-21 08:49:56 +020019590 alc_init_jacks(codec);
19591
Takashi Iwaicb53c622007-08-10 17:21:45 +020019592#ifdef CONFIG_SND_HDA_POWER_SAVE
19593 if (!spec->loopback.amplist)
19594 spec->loopback.amplist = alc662_loopbacks;
19595#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019596
19597 return 0;
19598}
19599
Kailang Yang274693f2009-12-03 10:07:50 +010019600static int patch_alc888(struct hda_codec *codec)
19601{
19602 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19603 kfree(codec->chip_name);
Kailang Yang01e0f132010-11-22 10:59:36 +010019604 if (codec->vendor_id == 0x10ec0887)
19605 codec->chip_name = kstrdup("ALC887-VD", GFP_KERNEL);
19606 else
19607 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019608 if (!codec->chip_name) {
19609 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019610 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019611 }
19612 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019613 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019614 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019615}
19616
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019617/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019618 * ALC680 support
19619 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019620#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019621#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19622#define alc680_modes alc260_modes
19623
19624static hda_nid_t alc680_dac_nids[3] = {
19625 /* Lout1, Lout2, hp */
19626 0x02, 0x03, 0x04
19627};
19628
19629static hda_nid_t alc680_adc_nids[3] = {
19630 /* ADC0-2 */
19631 /* DMIC, MIC, Line-in*/
19632 0x07, 0x08, 0x09
19633};
19634
Kailang Yangc69aefa2010-08-17 10:39:22 +020019635/*
19636 * Analog capture ADC cgange
19637 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019638static void alc680_rec_autoswitch(struct hda_codec *codec)
19639{
19640 struct alc_spec *spec = codec->spec;
19641 struct auto_pin_cfg *cfg = &spec->autocfg;
19642 int pin_found = 0;
19643 int type_found = AUTO_PIN_LAST;
19644 hda_nid_t nid;
19645 int i;
19646
19647 for (i = 0; i < cfg->num_inputs; i++) {
19648 nid = cfg->inputs[i].pin;
19649 if (!(snd_hda_query_pin_caps(codec, nid) &
19650 AC_PINCAP_PRES_DETECT))
19651 continue;
19652 if (snd_hda_jack_detect(codec, nid)) {
19653 if (cfg->inputs[i].type < type_found) {
19654 type_found = cfg->inputs[i].type;
19655 pin_found = nid;
19656 }
19657 }
19658 }
19659
19660 nid = 0x07;
19661 if (pin_found)
19662 snd_hda_get_connections(codec, pin_found, &nid, 1);
19663
19664 if (nid != spec->cur_adc)
19665 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19666 spec->cur_adc = nid;
19667 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19668 spec->cur_adc_format);
19669}
19670
Kailang Yangc69aefa2010-08-17 10:39:22 +020019671static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19672 struct hda_codec *codec,
19673 unsigned int stream_tag,
19674 unsigned int format,
19675 struct snd_pcm_substream *substream)
19676{
19677 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019678
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019679 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019680 spec->cur_adc_stream_tag = stream_tag;
19681 spec->cur_adc_format = format;
19682
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019683 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019684 return 0;
19685}
19686
19687static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19688 struct hda_codec *codec,
19689 struct snd_pcm_substream *substream)
19690{
19691 snd_hda_codec_cleanup_stream(codec, 0x07);
19692 snd_hda_codec_cleanup_stream(codec, 0x08);
19693 snd_hda_codec_cleanup_stream(codec, 0x09);
19694 return 0;
19695}
19696
19697static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19698 .substreams = 1, /* can be overridden */
19699 .channels_min = 2,
19700 .channels_max = 2,
19701 /* NID is set in alc_build_pcms */
19702 .ops = {
19703 .prepare = alc680_capture_pcm_prepare,
19704 .cleanup = alc680_capture_pcm_cleanup
19705 },
19706};
19707
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019708static struct snd_kcontrol_new alc680_base_mixer[] = {
19709 /* output mixer control */
19710 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19711 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19712 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19713 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010019714 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x12, 0, HDA_INPUT),
19715 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
19716 HDA_CODEC_VOLUME("Line In Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019717 { }
19718};
19719
Kailang Yangc69aefa2010-08-17 10:39:22 +020019720static struct hda_bind_ctls alc680_bind_cap_vol = {
19721 .ops = &snd_hda_bind_vol,
19722 .values = {
19723 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19724 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19725 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19726 0
19727 },
19728};
19729
19730static struct hda_bind_ctls alc680_bind_cap_switch = {
19731 .ops = &snd_hda_bind_sw,
19732 .values = {
19733 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19734 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19735 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19736 0
19737 },
19738};
19739
19740static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19741 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19742 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019743 { } /* end */
19744};
19745
19746/*
19747 * generic initialization of ADC, input mixers and output mixers
19748 */
19749static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019750 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19751 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19752 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019753
Kailang Yangc69aefa2010-08-17 10:39:22 +020019754 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19755 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19756 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19757 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19758 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19759 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019760
19761 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19762 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19763 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19764 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19765 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019766
19767 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19768 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019769 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019770
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019771 { }
19772};
19773
Kailang Yangc69aefa2010-08-17 10:39:22 +020019774/* toggle speaker-output according to the hp-jack state */
19775static void alc680_base_setup(struct hda_codec *codec)
19776{
19777 struct alc_spec *spec = codec->spec;
19778
19779 spec->autocfg.hp_pins[0] = 0x16;
19780 spec->autocfg.speaker_pins[0] = 0x14;
19781 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019782 spec->autocfg.num_inputs = 2;
19783 spec->autocfg.inputs[0].pin = 0x18;
19784 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19785 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019786 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019787}
19788
19789static void alc680_unsol_event(struct hda_codec *codec,
19790 unsigned int res)
19791{
19792 if ((res >> 26) == ALC880_HP_EVENT)
19793 alc_automute_amp(codec);
19794 if ((res >> 26) == ALC880_MIC_EVENT)
19795 alc680_rec_autoswitch(codec);
19796}
19797
19798static void alc680_inithook(struct hda_codec *codec)
19799{
19800 alc_automute_amp(codec);
19801 alc680_rec_autoswitch(codec);
19802}
19803
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019804/* create input playback/capture controls for the given pin */
19805static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19806 const char *ctlname, int idx)
19807{
19808 hda_nid_t dac;
19809 int err;
19810
19811 switch (nid) {
19812 case 0x14:
19813 dac = 0x02;
19814 break;
19815 case 0x15:
19816 dac = 0x03;
19817 break;
19818 case 0x16:
19819 dac = 0x04;
19820 break;
19821 default:
19822 return 0;
19823 }
19824 if (spec->multiout.dac_nids[0] != dac &&
19825 spec->multiout.dac_nids[1] != dac) {
19826 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19827 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19828 HDA_OUTPUT));
19829 if (err < 0)
19830 return err;
19831
19832 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19833 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19834
19835 if (err < 0)
19836 return err;
19837 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19838 }
19839
19840 return 0;
19841}
19842
19843/* add playback controls from the parsed DAC table */
19844static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19845 const struct auto_pin_cfg *cfg)
19846{
19847 hda_nid_t nid;
19848 int err;
19849
19850 spec->multiout.dac_nids = spec->private_dac_nids;
19851
19852 nid = cfg->line_out_pins[0];
19853 if (nid) {
19854 const char *name;
19855 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19856 name = "Speaker";
19857 else
19858 name = "Front";
19859 err = alc680_new_analog_output(spec, nid, name, 0);
19860 if (err < 0)
19861 return err;
19862 }
19863
19864 nid = cfg->speaker_pins[0];
19865 if (nid) {
19866 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19867 if (err < 0)
19868 return err;
19869 }
19870 nid = cfg->hp_pins[0];
19871 if (nid) {
19872 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19873 if (err < 0)
19874 return err;
19875 }
19876
19877 return 0;
19878}
19879
19880static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19881 hda_nid_t nid, int pin_type)
19882{
19883 alc_set_pin_output(codec, nid, pin_type);
19884}
19885
19886static void alc680_auto_init_multi_out(struct hda_codec *codec)
19887{
19888 struct alc_spec *spec = codec->spec;
19889 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19890 if (nid) {
19891 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19892 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19893 }
19894}
19895
19896static void alc680_auto_init_hp_out(struct hda_codec *codec)
19897{
19898 struct alc_spec *spec = codec->spec;
19899 hda_nid_t pin;
19900
19901 pin = spec->autocfg.hp_pins[0];
19902 if (pin)
19903 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19904 pin = spec->autocfg.speaker_pins[0];
19905 if (pin)
19906 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19907}
19908
19909/* pcm configuration: identical with ALC880 */
19910#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19911#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19912#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19913#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019914#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019915
19916/*
19917 * BIOS auto configuration
19918 */
19919static int alc680_parse_auto_config(struct hda_codec *codec)
19920{
19921 struct alc_spec *spec = codec->spec;
19922 int err;
19923 static hda_nid_t alc680_ignore[] = { 0 };
19924
19925 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19926 alc680_ignore);
19927 if (err < 0)
19928 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019929
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019930 if (!spec->autocfg.line_outs) {
19931 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19932 spec->multiout.max_channels = 2;
19933 spec->no_analog = 1;
19934 goto dig_only;
19935 }
19936 return 0; /* can't find valid BIOS pin config */
19937 }
19938 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19939 if (err < 0)
19940 return err;
19941
19942 spec->multiout.max_channels = 2;
19943
19944 dig_only:
19945 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019946 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019947 if (spec->kctls.list)
19948 add_mixer(spec, spec->kctls.list);
19949
19950 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019951
19952 err = alc_auto_add_mic_boost(codec);
19953 if (err < 0)
19954 return err;
19955
19956 return 1;
19957}
19958
19959#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19960
19961/* init callback for auto-configuration model -- overriding the default init */
19962static void alc680_auto_init(struct hda_codec *codec)
19963{
19964 struct alc_spec *spec = codec->spec;
19965 alc680_auto_init_multi_out(codec);
19966 alc680_auto_init_hp_out(codec);
19967 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019968 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019969 if (spec->unsol_event)
19970 alc_inithook(codec);
19971}
19972
19973/*
19974 * configuration and preset
19975 */
Takashi Iwaiea734962011-01-17 11:29:34 +010019976static const char * const alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019977 [ALC680_BASE] = "base",
19978 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019979};
19980
19981static struct snd_pci_quirk alc680_cfg_tbl[] = {
19982 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19983 {}
19984};
19985
19986static struct alc_config_preset alc680_presets[] = {
19987 [ALC680_BASE] = {
19988 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019989 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019990 .init_verbs = { alc680_init_verbs },
19991 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19992 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019993 .dig_out_nid = ALC680_DIGOUT_NID,
19994 .num_channel_mode = ARRAY_SIZE(alc680_modes),
19995 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020019996 .unsol_event = alc680_unsol_event,
19997 .setup = alc680_base_setup,
19998 .init_hook = alc680_inithook,
19999
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020000 },
20001};
20002
20003static int patch_alc680(struct hda_codec *codec)
20004{
20005 struct alc_spec *spec;
20006 int board_config;
20007 int err;
20008
20009 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
20010 if (spec == NULL)
20011 return -ENOMEM;
20012
20013 codec->spec = spec;
20014
20015 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
20016 alc680_models,
20017 alc680_cfg_tbl);
20018
20019 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
20020 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
20021 codec->chip_name);
20022 board_config = ALC680_AUTO;
20023 }
20024
20025 if (board_config == ALC680_AUTO) {
20026 /* automatic parse from the BIOS config */
20027 err = alc680_parse_auto_config(codec);
20028 if (err < 0) {
20029 alc_free(codec);
20030 return err;
20031 } else if (!err) {
20032 printk(KERN_INFO
20033 "hda_codec: Cannot set up configuration "
20034 "from BIOS. Using base mode...\n");
20035 board_config = ALC680_BASE;
20036 }
20037 }
20038
20039 if (board_config != ALC680_AUTO)
20040 setup_preset(codec, &alc680_presets[board_config]);
20041
20042 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020020043 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020044 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020020045 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020046
20047 if (!spec->adc_nids) {
20048 spec->adc_nids = alc680_adc_nids;
20049 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
20050 }
20051
20052 if (!spec->cap_mixer)
20053 set_capture_mixer(codec);
20054
20055 spec->vmaster_nid = 0x02;
20056
20057 codec->patch_ops = alc_patch_ops;
20058 if (board_config == ALC680_AUTO)
20059 spec->init_hook = alc680_auto_init;
20060
20061 return 0;
20062}
20063
20064/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070020065 * patch entries
20066 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010020067static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070020068 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020069 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020070 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020020071 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020072 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020073 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020020074 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020075 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020076 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020077 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020078 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
20079 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
20080 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020081 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020082 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020083 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
20084 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020020085 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010020086 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010020087 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020088 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020089 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020090 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020091 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020020092 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020093 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020020094 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020095 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020096 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yang01e0f132010-11-22 10:59:36 +010020097 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc888 },
Kailang Yang44426082008-10-15 11:18:05 +020020098 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020099 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020100 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020101 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020102 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020103 {} /* terminator */
20104};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010020105
20106MODULE_ALIAS("snd-hda-codec-id:10ec*");
20107
20108MODULE_LICENSE("GPL");
20109MODULE_DESCRIPTION("Realtek HD-audio codec");
20110
20111static struct hda_codec_preset_list realtek_list = {
20112 .preset = snd_hda_preset_realtek,
20113 .owner = THIS_MODULE,
20114};
20115
20116static int __init patch_realtek_init(void)
20117{
20118 return snd_hda_add_codec_preset(&realtek_list);
20119}
20120
20121static void __exit patch_realtek_exit(void)
20122{
20123 snd_hda_delete_codec_preset(&realtek_list);
20124}
20125
20126module_init(patch_realtek_init)
20127module_exit(patch_realtek_exit)