blob: d403ee825ef606ed93c883594796dcd0aa50eb8d [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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Avdoninbab282b2006-08-22 13:31:58 +0200227 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200228 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800229 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100230 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200231 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200232 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200233 ALC883_MEDION,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +0200234 ALC883_MEDION_WIM2160,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100235 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200236 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200237 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200238 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200239 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200240 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200241 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100242 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100243 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430244 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100245 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100246 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800247 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200248 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200249 ALC889A_INTEL,
250 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200251 ALC888_ASUS_M90V,
252 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200253 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100254 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200255 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200256 ALC882_AUTO,
257 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200258};
259
Takashi Iwaid4a86d82010-06-23 17:51:26 +0200260/* ALC680 models */
261enum {
262 ALC680_BASE,
263 ALC680_AUTO,
264 ALC680_MODEL_LAST,
265};
266
Kailang Yangdf694da2005-12-05 19:42:22 +0100267/* for GPIO Poll */
268#define GPIO_MASK 0x03
269
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200270/* extra amp-initialization sequence types */
271enum {
272 ALC_INIT_NONE,
273 ALC_INIT_DEFAULT,
274 ALC_INIT_GPIO1,
275 ALC_INIT_GPIO2,
276 ALC_INIT_GPIO3,
277};
278
Takashi Iwai6c819492009-08-10 18:47:44 +0200279struct alc_mic_route {
280 hda_nid_t pin;
281 unsigned char mux_idx;
282 unsigned char amix_idx;
283};
284
285#define MUX_IDX_UNDEF ((unsigned char)-1)
286
Kailang Yangda00c242010-03-19 11:23:45 +0100287struct alc_customize_define {
288 unsigned int sku_cfg;
289 unsigned char port_connectivity;
290 unsigned char check_sum;
291 unsigned char customization;
292 unsigned char external_amp;
293 unsigned int enable_pcbeep:1;
294 unsigned int platform_type:1;
295 unsigned int swap:1;
296 unsigned int override:1;
David Henningsson90622912010-10-14 14:50:18 +0200297 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
Kailang Yangda00c242010-03-19 11:23:45 +0100298};
299
Takashi Iwaib5bfbc62011-01-13 14:22:32 +0100300struct alc_fixup;
301
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302struct alc_spec {
303 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100304 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100306 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100307 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200309 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200310 * don't forget NULL
311 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200312 */
313 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200315 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 struct hda_pcm_stream *stream_analog_playback;
317 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100318 struct hda_pcm_stream *stream_analog_alt_playback;
319 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200321 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 struct hda_pcm_stream *stream_digital_playback;
323 struct hda_pcm_stream *stream_digital_capture;
324
325 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200326 struct hda_multi_out multiout; /* playback set-up
327 * max_channels, dacs must be set
328 * dig_out_nid and hp_nid are optional
329 */
Takashi Iwai63300792008-01-24 15:31:36 +0100330 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100331 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100332 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333
334 /* capture */
335 unsigned int num_adc_nids;
336 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100337 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200338 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339
Takashi Iwai840b64c2010-07-13 22:49:01 +0200340 /* capture setup for dynamic dual-adc switch */
341 unsigned int cur_adc_idx;
342 hda_nid_t cur_adc;
343 unsigned int cur_adc_stream_tag;
344 unsigned int cur_adc_format;
345
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200347 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 const struct hda_input_mux *input_mux;
349 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200350 struct alc_mic_route ext_mic;
351 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352
353 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100354 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200356 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200357 int const_channel_count;
358 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359
360 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100361 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200362
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200363 /* dynamic controls, init_verbs and input_mux */
364 struct auto_pin_cfg autocfg;
Kailang Yangda00c242010-03-19 11:23:45 +0100365 struct alc_customize_define cdefine;
Takashi Iwai603c4012008-07-30 15:01:44 +0200366 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200367 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200368 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200369 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
370 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100371
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100372 /* hooks */
373 void (*init_hook)(struct hda_codec *codec);
374 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100375#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -0500376 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100377#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100378
Takashi Iwai834be882006-03-01 14:16:17 +0100379 /* for pin sensing */
380 unsigned int sense_updated: 1;
381 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100382 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200383 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200384
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100385 /* other flags */
386 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai840b64c2010-07-13 22:49:01 +0200387 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200388 int init_amp;
Takashi Iwaid433a672010-09-20 15:11:54 +0200389 int codec_variant; /* flag for other variants */
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100390
Takashi Iwai2134ea42008-01-10 16:53:55 +0100391 /* for virtual master */
392 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200393#ifdef CONFIG_SND_HDA_POWER_SAVE
394 struct hda_loopback_check loopback;
395#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200396
397 /* for PLL fix */
398 hda_nid_t pll_nid;
399 unsigned int pll_coef_idx, pll_coef_bit;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +0100400
401 /* fix-up list */
402 int fixup_id;
403 const struct alc_fixup *fixup_list;
404 const char *fixup_name;
Kailang Yangdf694da2005-12-05 19:42:22 +0100405};
406
407/*
408 * configuration template - to be copied to the spec instance
409 */
410struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200411 struct snd_kcontrol_new *mixers[5]; /* should be identical size
412 * with spec
413 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100414 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100415 const struct hda_verb *init_verbs[5];
416 unsigned int num_dacs;
417 hda_nid_t *dac_nids;
418 hda_nid_t dig_out_nid; /* optional */
419 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800420 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100421 unsigned int num_adc_nids;
422 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100423 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100424 hda_nid_t dig_in_nid;
425 unsigned int num_channel_mode;
426 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200427 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200428 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200429 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100430 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100431 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200432 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100433 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200434#ifdef CONFIG_SND_HDA_POWER_SAVE
435 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500436 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200437#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438};
439
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440
441/*
442 * input MUX handling
443 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200444static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
445 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446{
447 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
448 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200449 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
450 if (mux_idx >= spec->num_mux_defs)
451 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100452 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
453 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200454 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455}
456
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200457static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
458 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459{
460 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
461 struct alc_spec *spec = codec->spec;
462 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
463
464 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
465 return 0;
466}
467
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200468static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
469 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470{
471 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
472 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100473 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100475 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100476 hda_nid_t nid = spec->capsrc_nids ?
477 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200478 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479
Takashi Iwaicd896c32008-11-18 12:36:33 +0100480 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
481 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100482 if (!imux->num_items && mux_idx > 0)
483 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100484
Takashi Iwaia22d5432009-07-27 12:54:26 +0200485 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200486 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100487 /* Matrix-mixer style (e.g. ALC882) */
488 unsigned int *cur_val = &spec->cur_mux[adc_idx];
489 unsigned int i, idx;
490
491 idx = ucontrol->value.enumerated.item[0];
492 if (idx >= imux->num_items)
493 idx = imux->num_items - 1;
494 if (*cur_val == idx)
495 return 0;
496 for (i = 0; i < imux->num_items; i++) {
497 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
498 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
499 imux->items[i].index,
500 HDA_AMP_MUTE, v);
501 }
502 *cur_val = idx;
503 return 1;
504 } else {
505 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100506 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100507 &spec->cur_mux[adc_idx]);
508 }
509}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200510
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511/*
512 * channel mode setting
513 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200514static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
515 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516{
517 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
518 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100519 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
520 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521}
522
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200523static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
524 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525{
526 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
527 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100528 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200529 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200530 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531}
532
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200533static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
534 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535{
536 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
537 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200538 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
539 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200540 &spec->ext_channel_count);
541 if (err >= 0 && !spec->const_channel_count) {
542 spec->multiout.max_channels = spec->ext_channel_count;
543 if (spec->need_dac_fix)
544 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
545 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200546 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547}
548
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100550 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200551 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100552 * being part of a format specifier. Maximum allowed length of a value is
553 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100554 *
555 * Note: some retasking pin complexes seem to ignore requests for input
556 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
557 * are requested. Therefore order this list so that this behaviour will not
558 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200559 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
560 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200561 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100562static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100563 "Mic 50pc bias", "Mic 80pc bias",
564 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100565};
566static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100567 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100568};
569/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200570 * in the pin being assumed to be exclusively an input or an output pin. In
571 * addition, "input" pins may or may not process the mic bias option
572 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
573 * accept requests for bias as of chip versions up to March 2006) and/or
574 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100575 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200576#define ALC_PIN_DIR_IN 0x00
577#define ALC_PIN_DIR_OUT 0x01
578#define ALC_PIN_DIR_INOUT 0x02
579#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
580#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100581
Kailang Yangea1fb292008-08-26 12:58:38 +0200582/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100583 * For each direction the minimum and maximum values are given.
584 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200585static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100586 { 0, 2 }, /* ALC_PIN_DIR_IN */
587 { 3, 4 }, /* ALC_PIN_DIR_OUT */
588 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200589 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
590 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100591};
592#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
593#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
594#define alc_pin_mode_n_items(_dir) \
595 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
596
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200597static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
598 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200599{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100600 unsigned int item_num = uinfo->value.enumerated.item;
601 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
602
603 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200604 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100605 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
606
607 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
608 item_num = alc_pin_mode_min(dir);
609 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200610 return 0;
611}
612
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200613static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
614 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200615{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100616 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200617 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
618 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100619 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200620 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200621 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
622 AC_VERB_GET_PIN_WIDGET_CONTROL,
623 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200624
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100625 /* Find enumerated value for current pinctl setting */
626 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200627 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100628 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200629 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100630 return 0;
631}
632
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200633static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
634 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100635{
636 signed int change;
637 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
638 hda_nid_t nid = kcontrol->private_value & 0xffff;
639 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
640 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200641 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
642 AC_VERB_GET_PIN_WIDGET_CONTROL,
643 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100644
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200645 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100646 val = alc_pin_mode_min(dir);
647
648 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100649 if (change) {
650 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200651 snd_hda_codec_write_cache(codec, nid, 0,
652 AC_VERB_SET_PIN_WIDGET_CONTROL,
653 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100654
Kailang Yangea1fb292008-08-26 12:58:38 +0200655 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100656 * for the requested pin mode. Enum values of 2 or less are
657 * input modes.
658 *
659 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200660 * reduces noise slightly (particularly on input) so we'll
661 * do it. However, having both input and output buffers
662 * enabled simultaneously doesn't seem to be problematic if
663 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100664 */
665 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200666 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
667 HDA_AMP_MUTE, HDA_AMP_MUTE);
668 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
669 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100670 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200671 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
672 HDA_AMP_MUTE, HDA_AMP_MUTE);
673 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
674 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100675 }
676 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200677 return change;
678}
679
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100680#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200681 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100682 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100683 .info = alc_pin_mode_info, \
684 .get = alc_pin_mode_get, \
685 .put = alc_pin_mode_put, \
686 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100687
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100688/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
689 * together using a mask with more than one bit set. This control is
690 * currently used only by the ALC260 test model. At this stage they are not
691 * needed for any "production" models.
692 */
693#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200694#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200695
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200696static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
697 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100698{
699 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
700 hda_nid_t nid = kcontrol->private_value & 0xffff;
701 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
702 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200703 unsigned int val = snd_hda_codec_read(codec, nid, 0,
704 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100705
706 *valp = (val & mask) != 0;
707 return 0;
708}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200709static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
710 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100711{
712 signed int change;
713 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
714 hda_nid_t nid = kcontrol->private_value & 0xffff;
715 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
716 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200717 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
718 AC_VERB_GET_GPIO_DATA,
719 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100720
721 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200722 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
723 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100724 gpio_data &= ~mask;
725 else
726 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200727 snd_hda_codec_write_cache(codec, nid, 0,
728 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100729
730 return change;
731}
732#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
733 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100734 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100735 .info = alc_gpio_data_info, \
736 .get = alc_gpio_data_get, \
737 .put = alc_gpio_data_put, \
738 .private_value = nid | (mask<<16) }
739#endif /* CONFIG_SND_DEBUG */
740
Jonathan Woithe92621f12006-02-28 11:47:47 +0100741/* A switch control to allow the enabling of the digital IO pins on the
742 * ALC260. This is incredibly simplistic; the intention of this control is
743 * to provide something in the test model allowing digital outputs to be
744 * identified if present. If models are found which can utilise these
745 * outputs a more complete mixer control can be devised for those models if
746 * necessary.
747 */
748#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200749#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200750
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200751static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
752 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100753{
754 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
755 hda_nid_t nid = kcontrol->private_value & 0xffff;
756 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
757 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200758 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100759 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100760
761 *valp = (val & mask) != 0;
762 return 0;
763}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200764static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
765 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100766{
767 signed int change;
768 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
769 hda_nid_t nid = kcontrol->private_value & 0xffff;
770 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
771 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200772 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100773 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200774 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100775
776 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200777 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100778 if (val==0)
779 ctrl_data &= ~mask;
780 else
781 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200782 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
783 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100784
785 return change;
786}
787#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
788 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100789 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100790 .info = alc_spdif_ctrl_info, \
791 .get = alc_spdif_ctrl_get, \
792 .put = alc_spdif_ctrl_put, \
793 .private_value = nid | (mask<<16) }
794#endif /* CONFIG_SND_DEBUG */
795
Jonathan Woithef8225f62008-01-08 12:16:54 +0100796/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
797 * Again, this is only used in the ALC26x test models to help identify when
798 * the EAPD line must be asserted for features to work.
799 */
800#ifdef CONFIG_SND_DEBUG
801#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
802
803static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
804 struct snd_ctl_elem_value *ucontrol)
805{
806 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
807 hda_nid_t nid = kcontrol->private_value & 0xffff;
808 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
809 long *valp = ucontrol->value.integer.value;
810 unsigned int val = snd_hda_codec_read(codec, nid, 0,
811 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
812
813 *valp = (val & mask) != 0;
814 return 0;
815}
816
817static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
818 struct snd_ctl_elem_value *ucontrol)
819{
820 int change;
821 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
822 hda_nid_t nid = kcontrol->private_value & 0xffff;
823 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
824 long val = *ucontrol->value.integer.value;
825 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
826 AC_VERB_GET_EAPD_BTLENABLE,
827 0x00);
828
829 /* Set/unset the masked control bit(s) as needed */
830 change = (!val ? 0 : mask) != (ctrl_data & mask);
831 if (!val)
832 ctrl_data &= ~mask;
833 else
834 ctrl_data |= mask;
835 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
836 ctrl_data);
837
838 return change;
839}
840
841#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
842 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100843 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100844 .info = alc_eapd_ctrl_info, \
845 .get = alc_eapd_ctrl_get, \
846 .put = alc_eapd_ctrl_put, \
847 .private_value = nid | (mask<<16) }
848#endif /* CONFIG_SND_DEBUG */
849
Kailang Yangdf694da2005-12-05 19:42:22 +0100850/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100851 * set up the input pin config (depending on the given auto-pin type)
852 */
853static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
854 int auto_pin_type)
855{
856 unsigned int val = PIN_IN;
857
Takashi Iwai86e29592010-09-09 14:50:17 +0200858 if (auto_pin_type == AUTO_PIN_MIC) {
Takashi Iwai23f0c042009-02-26 13:03:58 +0100859 unsigned int pincap;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200860 unsigned int oldval;
861 oldval = snd_hda_codec_read(codec, nid, 0,
862 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Takashi Iwai1327a322009-03-23 13:07:47 +0100863 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100864 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200865 /* if the default pin setup is vref50, we give it priority */
866 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
Takashi Iwai23f0c042009-02-26 13:03:58 +0100867 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200868 else if (pincap & AC_PINCAP_VREF_50)
869 val = PIN_VREF50;
870 else if (pincap & AC_PINCAP_VREF_100)
871 val = PIN_VREF100;
872 else if (pincap & AC_PINCAP_VREF_GRD)
873 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100874 }
875 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
876}
877
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200878static void alc_fixup_autocfg_pin_nums(struct hda_codec *codec)
879{
880 struct alc_spec *spec = codec->spec;
881 struct auto_pin_cfg *cfg = &spec->autocfg;
882
883 if (!cfg->line_outs) {
884 while (cfg->line_outs < AUTO_CFG_MAX_OUTS &&
885 cfg->line_out_pins[cfg->line_outs])
886 cfg->line_outs++;
887 }
888 if (!cfg->speaker_outs) {
889 while (cfg->speaker_outs < AUTO_CFG_MAX_OUTS &&
890 cfg->speaker_pins[cfg->speaker_outs])
891 cfg->speaker_outs++;
892 }
893 if (!cfg->hp_outs) {
894 while (cfg->hp_outs < AUTO_CFG_MAX_OUTS &&
895 cfg->hp_pins[cfg->hp_outs])
896 cfg->hp_outs++;
897 }
898}
899
Takashi Iwai23f0c042009-02-26 13:03:58 +0100900/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100901 */
902static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
903{
904 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
905 return;
906 spec->mixers[spec->num_mixers++] = mix;
907}
908
909static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
910{
911 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
912 return;
913 spec->init_verbs[spec->num_init_verbs++] = verb;
914}
915
916/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100917 * set up from the preset table
918 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200919static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200920 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100921{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200922 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100923 int i;
924
925 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100926 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100927 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200928 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
929 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100930 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200931
Kailang Yangdf694da2005-12-05 19:42:22 +0100932 spec->channel_mode = preset->channel_mode;
933 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200934 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200935 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100936
Hector Martin3b315d72009-06-02 10:54:19 +0200937 if (preset->const_channel_count)
938 spec->multiout.max_channels = preset->const_channel_count;
939 else
940 spec->multiout.max_channels = spec->channel_mode[0].channels;
941 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100942
943 spec->multiout.num_dacs = preset->num_dacs;
944 spec->multiout.dac_nids = preset->dac_nids;
945 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800946 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100947 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200948
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200949 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200950 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200951 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100952 spec->input_mux = preset->input_mux;
953
954 spec->num_adc_nids = preset->num_adc_nids;
955 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100956 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100957 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100958
959 spec->unsol_event = preset->unsol_event;
960 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200961#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100962 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200963 spec->loopback.amplist = preset->loopbacks;
964#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200965
966 if (preset->setup)
967 preset->setup(codec);
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200968
969 alc_fixup_autocfg_pin_nums(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100970}
971
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200972/* Enable GPIO mask and set output */
973static struct hda_verb alc_gpio1_init_verbs[] = {
974 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
975 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
976 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
977 { }
978};
979
980static struct hda_verb alc_gpio2_init_verbs[] = {
981 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
982 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
983 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
984 { }
985};
986
Kailang Yangbdd148a2007-05-08 15:19:08 +0200987static struct hda_verb alc_gpio3_init_verbs[] = {
988 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
989 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
990 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
991 { }
992};
993
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200994/*
995 * Fix hardware PLL issue
996 * On some codecs, the analog PLL gating control must be off while
997 * the default value is 1.
998 */
999static void alc_fix_pll(struct hda_codec *codec)
1000{
1001 struct alc_spec *spec = codec->spec;
1002 unsigned int val;
1003
1004 if (!spec->pll_nid)
1005 return;
1006 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1007 spec->pll_coef_idx);
1008 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
1009 AC_VERB_GET_PROC_COEF, 0);
1010 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1011 spec->pll_coef_idx);
1012 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
1013 val & ~(1 << spec->pll_coef_bit));
1014}
1015
1016static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
1017 unsigned int coef_idx, unsigned int coef_bit)
1018{
1019 struct alc_spec *spec = codec->spec;
1020 spec->pll_nid = nid;
1021 spec->pll_coef_idx = coef_idx;
1022 spec->pll_coef_bit = coef_bit;
1023 alc_fix_pll(codec);
1024}
1025
Kailang Yang9ad0e492010-09-14 23:22:00 +02001026static int alc_init_jacks(struct hda_codec *codec)
1027{
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001028#ifdef CONFIG_SND_HDA_INPUT_JACK
Kailang Yang9ad0e492010-09-14 23:22:00 +02001029 struct alc_spec *spec = codec->spec;
1030 int err;
1031 unsigned int hp_nid = spec->autocfg.hp_pins[0];
1032 unsigned int mic_nid = spec->ext_mic.pin;
1033
Takashi Iwai265a0242010-09-21 11:26:21 +02001034 if (hp_nid) {
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001035 err = snd_hda_input_jack_add(codec, hp_nid,
1036 SND_JACK_HEADPHONE, NULL);
Takashi Iwai265a0242010-09-21 11:26:21 +02001037 if (err < 0)
1038 return err;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001039 snd_hda_input_jack_report(codec, hp_nid);
Takashi Iwai265a0242010-09-21 11:26:21 +02001040 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001041
Takashi Iwai265a0242010-09-21 11:26:21 +02001042 if (mic_nid) {
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001043 err = snd_hda_input_jack_add(codec, mic_nid,
1044 SND_JACK_MICROPHONE, NULL);
Takashi Iwai265a0242010-09-21 11:26:21 +02001045 if (err < 0)
1046 return err;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001047 snd_hda_input_jack_report(codec, mic_nid);
Takashi Iwai265a0242010-09-21 11:26:21 +02001048 }
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001049#endif /* CONFIG_SND_HDA_INPUT_JACK */
Kailang Yang9ad0e492010-09-14 23:22:00 +02001050 return 0;
1051}
Kailang Yang9ad0e492010-09-14 23:22:00 +02001052
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001053static void alc_automute_speaker(struct hda_codec *codec, int pinctl)
Kailang Yangc9b58002007-10-16 14:30:01 +02001054{
1055 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001056 unsigned int mute;
1057 hda_nid_t nid;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001058 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +02001059
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001060 spec->jack_present = 0;
1061 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1062 nid = spec->autocfg.hp_pins[i];
1063 if (!nid)
1064 break;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001065 snd_hda_input_jack_report(codec, nid);
David Henningssonf0ce2792011-02-28 15:58:07 +01001066 spec->jack_present |= snd_hda_jack_detect(codec, nid);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001067 }
1068
1069 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1070 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001071 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1072 nid = spec->autocfg.speaker_pins[i];
1073 if (!nid)
1074 break;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001075 if (pinctl) {
1076 snd_hda_codec_write(codec, nid, 0,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001077 AC_VERB_SET_PIN_WIDGET_CONTROL,
1078 spec->jack_present ? 0 : PIN_OUT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001079 } else {
1080 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1081 HDA_AMP_MUTE, mute);
1082 }
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001083 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001084}
1085
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001086static void alc_automute_pin(struct hda_codec *codec)
1087{
1088 alc_automute_speaker(codec, 1);
1089}
1090
Takashi Iwai6c819492009-08-10 18:47:44 +02001091static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1092 hda_nid_t nid)
1093{
1094 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1095 int i, nums;
1096
1097 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1098 for (i = 0; i < nums; i++)
1099 if (conn[i] == nid)
1100 return i;
1101 return -1;
1102}
1103
Takashi Iwai840b64c2010-07-13 22:49:01 +02001104/* switch the current ADC according to the jack state */
1105static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1106{
1107 struct alc_spec *spec = codec->spec;
1108 unsigned int present;
1109 hda_nid_t new_adc;
1110
1111 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1112 if (present)
1113 spec->cur_adc_idx = 1;
1114 else
1115 spec->cur_adc_idx = 0;
1116 new_adc = spec->adc_nids[spec->cur_adc_idx];
1117 if (spec->cur_adc && spec->cur_adc != new_adc) {
1118 /* stream is running, let's swap the current ADC */
Takashi Iwaif0cea792010-08-13 11:56:53 +02001119 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
Takashi Iwai840b64c2010-07-13 22:49:01 +02001120 spec->cur_adc = new_adc;
1121 snd_hda_codec_setup_stream(codec, new_adc,
1122 spec->cur_adc_stream_tag, 0,
1123 spec->cur_adc_format);
1124 }
1125}
1126
Kailang Yang7fb0d782008-10-15 11:12:35 +02001127static void alc_mic_automute(struct hda_codec *codec)
1128{
1129 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001130 struct alc_mic_route *dead, *alive;
1131 unsigned int present, type;
1132 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001133
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001134 if (!spec->auto_mic)
1135 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001136 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1137 return;
1138 if (snd_BUG_ON(!spec->adc_nids))
1139 return;
1140
Takashi Iwai840b64c2010-07-13 22:49:01 +02001141 if (spec->dual_adc_switch) {
1142 alc_dual_mic_adc_auto_switch(codec);
1143 return;
1144 }
1145
Takashi Iwai6c819492009-08-10 18:47:44 +02001146 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1147
Wu Fengguang864f92b2009-11-18 12:38:02 +08001148 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001149 if (present) {
1150 alive = &spec->ext_mic;
1151 dead = &spec->int_mic;
1152 } else {
1153 alive = &spec->int_mic;
1154 dead = &spec->ext_mic;
1155 }
1156
Takashi Iwai6c819492009-08-10 18:47:44 +02001157 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1158 if (type == AC_WID_AUD_MIX) {
1159 /* Matrix-mixer style (e.g. ALC882) */
1160 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1161 alive->mux_idx,
1162 HDA_AMP_MUTE, 0);
1163 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1164 dead->mux_idx,
1165 HDA_AMP_MUTE, HDA_AMP_MUTE);
1166 } else {
1167 /* MUX style (e.g. ALC880) */
1168 snd_hda_codec_write_cache(codec, cap_nid, 0,
1169 AC_VERB_SET_CONNECT_SEL,
1170 alive->mux_idx);
1171 }
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001172 snd_hda_input_jack_report(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001173
1174 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001175}
1176
Kailang Yangc9b58002007-10-16 14:30:01 +02001177/* unsolicited event for HP jack sensing */
1178static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1179{
1180 if (codec->vendor_id == 0x10ec0880)
1181 res >>= 28;
1182 else
1183 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001184 switch (res) {
1185 case ALC880_HP_EVENT:
1186 alc_automute_pin(codec);
1187 break;
1188 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001189 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001190 break;
1191 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001192}
1193
1194static void alc_inithook(struct hda_codec *codec)
1195{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001196 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001197 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001198}
1199
Kailang Yangf9423e72008-05-27 12:32:25 +02001200/* additional initialization for ALC888 variants */
1201static void alc888_coef_init(struct hda_codec *codec)
1202{
1203 unsigned int tmp;
1204
1205 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1206 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1207 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001208 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001209 /* alc888S-VC */
1210 snd_hda_codec_read(codec, 0x20, 0,
1211 AC_VERB_SET_PROC_COEF, 0x830);
1212 else
1213 /* alc888-VB */
1214 snd_hda_codec_read(codec, 0x20, 0,
1215 AC_VERB_SET_PROC_COEF, 0x3030);
1216}
1217
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001218static void alc889_coef_init(struct hda_codec *codec)
1219{
1220 unsigned int tmp;
1221
1222 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1223 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1224 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1225 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1226}
1227
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001228/* turn on/off EAPD control (only if available) */
1229static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1230{
1231 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1232 return;
1233 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1234 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1235 on ? 2 : 0);
1236}
1237
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001238static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001239{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001240 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001241
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001242 switch (type) {
1243 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001244 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1245 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001246 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001247 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1248 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001249 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001250 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1251 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001252 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001253 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001254 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001255 set_eapd(codec, 0x0f, 1);
1256 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001257 break;
1258 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001259 case 0x10ec0267:
1260 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001261 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001262 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001263 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001264 case 0x10ec0660:
1265 case 0x10ec0662:
1266 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001267 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001268 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001269 set_eapd(codec, 0x14, 1);
1270 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001271 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001272 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001273 switch (codec->vendor_id) {
1274 case 0x10ec0260:
1275 snd_hda_codec_write(codec, 0x1a, 0,
1276 AC_VERB_SET_COEF_INDEX, 7);
1277 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1278 AC_VERB_GET_PROC_COEF, 0);
1279 snd_hda_codec_write(codec, 0x1a, 0,
1280 AC_VERB_SET_COEF_INDEX, 7);
1281 snd_hda_codec_write(codec, 0x1a, 0,
1282 AC_VERB_SET_PROC_COEF,
1283 tmp | 0x2010);
1284 break;
1285 case 0x10ec0262:
1286 case 0x10ec0880:
1287 case 0x10ec0882:
1288 case 0x10ec0883:
1289 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001290 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001291 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001292 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001293 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001294 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001295 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001296 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001297#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001298 case 0x10ec0267:
1299 case 0x10ec0268:
1300 snd_hda_codec_write(codec, 0x20, 0,
1301 AC_VERB_SET_COEF_INDEX, 7);
1302 tmp = snd_hda_codec_read(codec, 0x20, 0,
1303 AC_VERB_GET_PROC_COEF, 0);
1304 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001305 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001306 snd_hda_codec_write(codec, 0x20, 0,
1307 AC_VERB_SET_PROC_COEF,
1308 tmp | 0x3000);
1309 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001310#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001311 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001312 break;
1313 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001314}
Kailang Yangea1fb292008-08-26 12:58:38 +02001315
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001316static void alc_init_auto_hp(struct hda_codec *codec)
1317{
1318 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001319 struct auto_pin_cfg *cfg = &spec->autocfg;
1320 int i;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001321
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001322 if (!cfg->hp_pins[0]) {
1323 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001324 return;
1325 }
1326
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001327 if (!cfg->speaker_pins[0]) {
1328 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
1329 return;
1330 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1331 sizeof(cfg->speaker_pins));
1332 cfg->speaker_outs = cfg->line_outs;
1333 }
1334
1335 if (!cfg->hp_pins[0]) {
1336 memcpy(cfg->hp_pins, cfg->line_out_pins,
1337 sizeof(cfg->hp_pins));
1338 cfg->hp_outs = cfg->line_outs;
1339 }
1340
1341 for (i = 0; i < cfg->hp_outs; i++) {
1342 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1343 cfg->hp_pins[i]);
1344 snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0,
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001345 AC_VERB_SET_UNSOLICITED_ENABLE,
1346 AC_USRSP_EN | ALC880_HP_EVENT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001347 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001348 spec->unsol_event = alc_sku_unsol_event;
1349}
1350
Takashi Iwai6c819492009-08-10 18:47:44 +02001351static void alc_init_auto_mic(struct hda_codec *codec)
1352{
1353 struct alc_spec *spec = codec->spec;
1354 struct auto_pin_cfg *cfg = &spec->autocfg;
1355 hda_nid_t fixed, ext;
1356 int i;
1357
1358 /* there must be only two mic inputs exclusively */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001359 for (i = 0; i < cfg->num_inputs; i++)
Takashi Iwai86e29592010-09-09 14:50:17 +02001360 if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
Takashi Iwai6c819492009-08-10 18:47:44 +02001361 return;
1362
1363 fixed = ext = 0;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001364 for (i = 0; i < cfg->num_inputs; i++) {
1365 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai6c819492009-08-10 18:47:44 +02001366 unsigned int defcfg;
Takashi Iwai6c819492009-08-10 18:47:44 +02001367 defcfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001368 switch (snd_hda_get_input_pin_attr(defcfg)) {
1369 case INPUT_PIN_ATTR_INT:
Takashi Iwai6c819492009-08-10 18:47:44 +02001370 if (fixed)
1371 return; /* already occupied */
1372 fixed = nid;
1373 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001374 case INPUT_PIN_ATTR_UNUSED:
1375 return; /* invalid entry */
1376 default:
Takashi Iwai6c819492009-08-10 18:47:44 +02001377 if (ext)
1378 return; /* already occupied */
1379 ext = nid;
1380 break;
Takashi Iwai6c819492009-08-10 18:47:44 +02001381 }
1382 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001383 if (!ext || !fixed)
1384 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001385 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1386 return; /* no unsol support */
1387 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1388 ext, fixed);
1389 spec->ext_mic.pin = ext;
1390 spec->int_mic.pin = fixed;
1391 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1392 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1393 spec->auto_mic = 1;
1394 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1395 AC_VERB_SET_UNSOLICITED_ENABLE,
1396 AC_USRSP_EN | ALC880_MIC_EVENT);
1397 spec->unsol_event = alc_sku_unsol_event;
1398}
1399
David Henningsson90622912010-10-14 14:50:18 +02001400/* Could be any non-zero and even value. When used as fixup, tells
1401 * the driver to ignore any present sku defines.
1402 */
1403#define ALC_FIXUP_SKU_IGNORE (2)
1404
Kailang Yangda00c242010-03-19 11:23:45 +01001405static int alc_auto_parse_customize_define(struct hda_codec *codec)
1406{
1407 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001408 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001409 struct alc_spec *spec = codec->spec;
1410
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001411 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1412
David Henningsson90622912010-10-14 14:50:18 +02001413 if (spec->cdefine.fixup) {
1414 ass = spec->cdefine.sku_cfg;
1415 if (ass == ALC_FIXUP_SKU_IGNORE)
1416 return -1;
1417 goto do_sku;
1418 }
1419
Kailang Yangda00c242010-03-19 11:23:45 +01001420 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001421 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +01001422 goto do_sku;
1423
1424 nid = 0x1d;
1425 if (codec->vendor_id == 0x10ec0260)
1426 nid = 0x17;
1427 ass = snd_hda_codec_get_pincfg(codec, nid);
1428
1429 if (!(ass & 1)) {
1430 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1431 codec->chip_name, ass);
1432 return -1;
1433 }
1434
1435 /* check sum */
1436 tmp = 0;
1437 for (i = 1; i < 16; i++) {
1438 if ((ass >> i) & 1)
1439 tmp++;
1440 }
1441 if (((ass >> 16) & 0xf) != tmp)
1442 return -1;
1443
1444 spec->cdefine.port_connectivity = ass >> 30;
1445 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1446 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1447 spec->cdefine.customization = ass >> 8;
1448do_sku:
1449 spec->cdefine.sku_cfg = ass;
1450 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1451 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1452 spec->cdefine.swap = (ass & 0x2) >> 1;
1453 spec->cdefine.override = ass & 0x1;
1454
1455 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1456 nid, spec->cdefine.sku_cfg);
1457 snd_printd("SKU: port_connectivity=0x%x\n",
1458 spec->cdefine.port_connectivity);
1459 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1460 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1461 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1462 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1463 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1464 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1465 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1466
1467 return 0;
1468}
1469
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001470/* check subsystem ID and set up device-specific initialization;
1471 * return 1 if initialized, 0 if invalid SSID
1472 */
1473/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1474 * 31 ~ 16 : Manufacture ID
1475 * 15 ~ 8 : SKU ID
1476 * 7 ~ 0 : Assembly ID
1477 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1478 */
1479static int alc_subsystem_id(struct hda_codec *codec,
1480 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001481 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001482{
1483 unsigned int ass, tmp, i;
1484 unsigned nid;
1485 struct alc_spec *spec = codec->spec;
1486
David Henningsson90622912010-10-14 14:50:18 +02001487 if (spec->cdefine.fixup) {
1488 ass = spec->cdefine.sku_cfg;
1489 if (ass == ALC_FIXUP_SKU_IGNORE)
1490 return 0;
1491 goto do_sku;
1492 }
1493
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001494 ass = codec->subsystem_id & 0xffff;
1495 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1496 goto do_sku;
1497
1498 /* invalid SSID, check the special NID pin defcfg instead */
1499 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001500 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001501 * 29~21 : reserve
1502 * 20 : PCBEEP input
1503 * 19~16 : Check sum (15:1)
1504 * 15~1 : Custom
1505 * 0 : override
1506 */
1507 nid = 0x1d;
1508 if (codec->vendor_id == 0x10ec0260)
1509 nid = 0x17;
1510 ass = snd_hda_codec_get_pincfg(codec, nid);
1511 snd_printd("realtek: No valid SSID, "
1512 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001513 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001514 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001515 return 0;
1516 if ((ass >> 30) != 1) /* no physical connection */
1517 return 0;
1518
1519 /* check sum */
1520 tmp = 0;
1521 for (i = 1; i < 16; i++) {
1522 if ((ass >> i) & 1)
1523 tmp++;
1524 }
1525 if (((ass >> 16) & 0xf) != tmp)
1526 return 0;
1527do_sku:
1528 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1529 ass & 0xffff, codec->vendor_id);
1530 /*
1531 * 0 : override
1532 * 1 : Swap Jack
1533 * 2 : 0 --> Desktop, 1 --> Laptop
1534 * 3~5 : External Amplifier control
1535 * 7~6 : Reserved
1536 */
1537 tmp = (ass & 0x38) >> 3; /* external Amp control */
1538 switch (tmp) {
1539 case 1:
1540 spec->init_amp = ALC_INIT_GPIO1;
1541 break;
1542 case 3:
1543 spec->init_amp = ALC_INIT_GPIO2;
1544 break;
1545 case 7:
1546 spec->init_amp = ALC_INIT_GPIO3;
1547 break;
1548 case 5:
Takashi Iwai5a8cfb42010-11-26 17:11:18 +01001549 default:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001550 spec->init_amp = ALC_INIT_DEFAULT;
1551 break;
1552 }
1553
1554 /* is laptop or Desktop and enable the function "Mute internal speaker
1555 * when the external headphone out jack is plugged"
1556 */
1557 if (!(ass & 0x8000))
1558 return 1;
1559 /*
1560 * 10~8 : Jack location
1561 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1562 * 14~13: Resvered
1563 * 15 : 1 --> enable the function "Mute internal speaker
1564 * when the external headphone out jack is plugged"
1565 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001566 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001567 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001568 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1569 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001570 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001571 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001572 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001573 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001574 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001575 else if (tmp == 3)
1576 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001577 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001578 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001579 for (i = 0; i < spec->autocfg.line_outs; i++)
1580 if (spec->autocfg.line_out_pins[i] == nid)
1581 return 1;
1582 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001583 }
1584
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001585 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001586 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001587 return 1;
1588}
Kailang Yangea1fb292008-08-26 12:58:38 +02001589
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001590static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001591 hda_nid_t porta, hda_nid_t porte,
1592 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001593{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001594 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001595 struct alc_spec *spec = codec->spec;
1596 snd_printd("realtek: "
1597 "Enable default setup for auto mode as fallback\n");
1598 spec->init_amp = ALC_INIT_DEFAULT;
1599 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001600 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001601 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001602}
1603
Takashi Iwai41e41f12005-06-08 14:48:49 +02001604/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001605 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001606 */
1607
1608struct alc_pincfg {
1609 hda_nid_t nid;
1610 u32 val;
1611};
1612
Todd Broche1eb5f12010-12-06 11:19:51 -08001613struct alc_model_fixup {
1614 const int id;
1615 const char *name;
1616};
1617
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001618struct alc_fixup {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001619 int type;
Takashi Iwai361fe6e2011-01-14 09:55:32 +01001620 bool chained;
1621 int chain_id;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001622 union {
1623 unsigned int sku;
1624 const struct alc_pincfg *pins;
1625 const struct hda_verb *verbs;
1626 void (*func)(struct hda_codec *codec,
1627 const struct alc_fixup *fix,
1628 int action);
1629 } v;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001630};
1631
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001632enum {
1633 ALC_FIXUP_INVALID,
1634 ALC_FIXUP_SKU,
1635 ALC_FIXUP_PINS,
1636 ALC_FIXUP_VERBS,
1637 ALC_FIXUP_FUNC,
1638};
Takashi Iwaif95474e2007-07-10 00:47:43 +02001639
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001640enum {
1641 ALC_FIXUP_ACT_PRE_PROBE,
1642 ALC_FIXUP_ACT_PROBE,
Takashi Iwai58701122011-01-13 15:41:45 +01001643 ALC_FIXUP_ACT_INIT,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001644};
1645
1646static void alc_apply_fixup(struct hda_codec *codec, int action)
1647{
1648 struct alc_spec *spec = codec->spec;
1649 int id = spec->fixup_id;
Takashi Iwaiaa1d0c52011-01-19 17:27:58 +01001650#ifdef CONFIG_SND_DEBUG_VERBOSE
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001651 const char *modelname = spec->fixup_name;
Takashi Iwaiaa1d0c52011-01-19 17:27:58 +01001652#endif
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001653 int depth = 0;
1654
1655 if (!spec->fixup_list)
1656 return;
1657
1658 while (id >= 0) {
1659 const struct alc_fixup *fix = spec->fixup_list + id;
1660 const struct alc_pincfg *cfg;
1661
1662 switch (fix->type) {
1663 case ALC_FIXUP_SKU:
1664 if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku)
1665 break;;
1666 snd_printdd(KERN_INFO "hda_codec: %s: "
1667 "Apply sku override for %s\n",
1668 codec->chip_name, modelname);
1669 spec->cdefine.sku_cfg = fix->v.sku;
1670 spec->cdefine.fixup = 1;
1671 break;
1672 case ALC_FIXUP_PINS:
1673 cfg = fix->v.pins;
1674 if (action != ALC_FIXUP_ACT_PRE_PROBE || !cfg)
1675 break;
1676 snd_printdd(KERN_INFO "hda_codec: %s: "
1677 "Apply pincfg for %s\n",
1678 codec->chip_name, modelname);
1679 for (; cfg->nid; cfg++)
1680 snd_hda_codec_set_pincfg(codec, cfg->nid,
1681 cfg->val);
1682 break;
1683 case ALC_FIXUP_VERBS:
1684 if (action != ALC_FIXUP_ACT_PROBE || !fix->v.verbs)
1685 break;
1686 snd_printdd(KERN_INFO "hda_codec: %s: "
1687 "Apply fix-verbs for %s\n",
1688 codec->chip_name, modelname);
1689 add_verb(codec->spec, fix->v.verbs);
1690 break;
1691 case ALC_FIXUP_FUNC:
1692 if (!fix->v.func)
1693 break;
1694 snd_printdd(KERN_INFO "hda_codec: %s: "
1695 "Apply fix-func for %s\n",
1696 codec->chip_name, modelname);
1697 fix->v.func(codec, fix, action);
1698 break;
1699 default:
1700 snd_printk(KERN_ERR "hda_codec: %s: "
1701 "Invalid fixup type %d\n",
1702 codec->chip_name, fix->type);
1703 break;
1704 }
1705 if (!fix[id].chained)
1706 break;
1707 if (++depth > 10)
1708 break;
1709 id = fix[id].chain_id;
Takashi Iwai9d578832010-11-22 13:29:19 +01001710 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001711}
1712
Todd Broche1eb5f12010-12-06 11:19:51 -08001713static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001714 const struct alc_model_fixup *models,
1715 const struct snd_pci_quirk *quirk,
1716 const struct alc_fixup *fixlist)
Todd Broche1eb5f12010-12-06 11:19:51 -08001717{
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001718 struct alc_spec *spec = codec->spec;
1719 int id = -1;
1720 const char *name = NULL;
Todd Broche1eb5f12010-12-06 11:19:51 -08001721
Todd Broche1eb5f12010-12-06 11:19:51 -08001722 if (codec->modelname && models) {
1723 while (models->name) {
1724 if (!strcmp(codec->modelname, models->name)) {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001725 id = models->id;
1726 name = models->name;
Todd Broche1eb5f12010-12-06 11:19:51 -08001727 break;
1728 }
1729 models++;
1730 }
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001731 }
1732 if (id < 0) {
1733 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1734 if (quirk) {
1735 id = quirk->value;
1736#ifdef CONFIG_SND_DEBUG_VERBOSE
1737 name = quirk->name;
1738#endif
1739 }
1740 }
1741
1742 spec->fixup_id = id;
1743 if (id >= 0) {
1744 spec->fixup_list = fixlist;
1745 spec->fixup_name = name;
Todd Broche1eb5f12010-12-06 11:19:51 -08001746 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001747}
1748
Kailang Yang274693f2009-12-03 10:07:50 +01001749static int alc_read_coef_idx(struct hda_codec *codec,
1750 unsigned int coef_idx)
1751{
1752 unsigned int val;
1753 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1754 coef_idx);
1755 val = snd_hda_codec_read(codec, 0x20, 0,
1756 AC_VERB_GET_PROC_COEF, 0);
1757 return val;
1758}
1759
Kailang Yang977ddd62010-09-15 10:02:29 +02001760static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1761 unsigned int coef_val)
1762{
1763 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1764 coef_idx);
1765 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1766 coef_val);
1767}
1768
Takashi Iwai757899a2010-07-30 10:48:14 +02001769/* set right pin controls for digital I/O */
1770static void alc_auto_init_digital(struct hda_codec *codec)
1771{
1772 struct alc_spec *spec = codec->spec;
1773 int i;
1774 hda_nid_t pin;
1775
1776 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1777 pin = spec->autocfg.dig_out_pins[i];
1778 if (pin) {
1779 snd_hda_codec_write(codec, pin, 0,
1780 AC_VERB_SET_PIN_WIDGET_CONTROL,
1781 PIN_OUT);
1782 }
1783 }
1784 pin = spec->autocfg.dig_in_pin;
1785 if (pin)
1786 snd_hda_codec_write(codec, pin, 0,
1787 AC_VERB_SET_PIN_WIDGET_CONTROL,
1788 PIN_IN);
1789}
1790
1791/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1792static void alc_auto_parse_digital(struct hda_codec *codec)
1793{
1794 struct alc_spec *spec = codec->spec;
1795 int i, err;
1796 hda_nid_t dig_nid;
1797
1798 /* support multiple SPDIFs; the secondary is set up as a slave */
1799 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1800 err = snd_hda_get_connections(codec,
1801 spec->autocfg.dig_out_pins[i],
1802 &dig_nid, 1);
1803 if (err < 0)
1804 continue;
1805 if (!i) {
1806 spec->multiout.dig_out_nid = dig_nid;
1807 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1808 } else {
1809 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1810 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1811 break;
1812 spec->slave_dig_outs[i - 1] = dig_nid;
1813 }
1814 }
1815
1816 if (spec->autocfg.dig_in_pin) {
Takashi Iwai01fdf182010-09-24 09:09:42 +02001817 dig_nid = codec->start_nid;
1818 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
1819 unsigned int wcaps = get_wcaps(codec, dig_nid);
1820 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
1821 continue;
1822 if (!(wcaps & AC_WCAP_DIGITAL))
1823 continue;
1824 if (!(wcaps & AC_WCAP_CONN_LIST))
1825 continue;
1826 err = get_connection_index(codec, dig_nid,
1827 spec->autocfg.dig_in_pin);
1828 if (err >= 0) {
1829 spec->dig_in_nid = dig_nid;
1830 break;
1831 }
1832 }
Takashi Iwai757899a2010-07-30 10:48:14 +02001833 }
1834}
1835
Takashi Iwaif95474e2007-07-10 00:47:43 +02001836/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001837 * ALC888
1838 */
1839
1840/*
1841 * 2ch mode
1842 */
1843static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1844/* Mic-in jack as mic in */
1845 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1846 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1847/* Line-in jack as Line in */
1848 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1849 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1850/* Line-Out as Front */
1851 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1852 { } /* end */
1853};
1854
1855/*
1856 * 4ch mode
1857 */
1858static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1859/* Mic-in jack as mic in */
1860 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1861 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1862/* Line-in jack as Surround */
1863 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1864 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1865/* Line-Out as Front */
1866 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1867 { } /* end */
1868};
1869
1870/*
1871 * 6ch mode
1872 */
1873static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1874/* Mic-in jack as CLFE */
1875 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1876 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1877/* Line-in jack as Surround */
1878 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1879 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1880/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1881 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1882 { } /* end */
1883};
1884
1885/*
1886 * 8ch mode
1887 */
1888static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1889/* Mic-in jack as CLFE */
1890 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1891 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1892/* Line-in jack as Surround */
1893 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1894 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1895/* Line-Out as Side */
1896 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1897 { } /* end */
1898};
1899
1900static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1901 { 2, alc888_4ST_ch2_intel_init },
1902 { 4, alc888_4ST_ch4_intel_init },
1903 { 6, alc888_4ST_ch6_intel_init },
1904 { 8, alc888_4ST_ch8_intel_init },
1905};
1906
1907/*
1908 * ALC888 Fujitsu Siemens Amillo xa3530
1909 */
1910
1911static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1912/* Front Mic: set to PIN_IN (empty by default) */
1913 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1914/* Connect Internal HP to Front */
1915 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1916 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1917 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1918/* Connect Bass HP to Front */
1919 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1920 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1921 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1922/* Connect Line-Out side jack (SPDIF) to Side */
1923 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1924 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1925 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1926/* Connect Mic jack to CLFE */
1927 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1928 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1929 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1930/* Connect Line-in jack to Surround */
1931 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1932 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1933 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1934/* Connect HP out jack to Front */
1935 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1936 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1937 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1938/* Enable unsolicited event for HP jack and Line-out jack */
1939 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1940 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1941 {}
1942};
1943
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001944static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001945{
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001946 alc_automute_speaker(codec, 0);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001947}
1948
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001949static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1950 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001951{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001952 if (codec->vendor_id == 0x10ec0880)
1953 res >>= 28;
1954 else
1955 res >>= 26;
1956 if (res == ALC880_HP_EVENT)
1957 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001958}
1959
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001960static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001961{
1962 struct alc_spec *spec = codec->spec;
1963
1964 spec->autocfg.hp_pins[0] = 0x15;
1965 spec->autocfg.speaker_pins[0] = 0x14;
1966 spec->autocfg.speaker_pins[1] = 0x16;
1967 spec->autocfg.speaker_pins[2] = 0x17;
1968 spec->autocfg.speaker_pins[3] = 0x19;
1969 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001970}
1971
1972static void alc889_intel_init_hook(struct hda_codec *codec)
1973{
1974 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001975 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001976}
1977
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001978static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001979{
1980 struct alc_spec *spec = codec->spec;
1981
1982 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1983 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1984 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1985 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001986}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001987
1988/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001989 * ALC888 Acer Aspire 4930G model
1990 */
1991
1992static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1993/* Front Mic: set to PIN_IN (empty by default) */
1994 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1995/* Unselect Front Mic by default in input mixer 3 */
1996 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001997/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001998 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1999/* Connect Internal HP to front */
2000 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2001 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2002 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2003/* Connect HP out to front */
2004 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2005 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2006 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie2e93292011-01-12 08:03:39 +01002007 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002008 { }
2009};
2010
Hector Martin3b315d72009-06-02 10:54:19 +02002011/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01002012 * ALC888 Acer Aspire 6530G model
2013 */
2014
2015static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01002016/* Route to built-in subwoofer as well as speakers */
2017 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2018 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2019 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2020 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002021/* Bias voltage on for external mic port */
2022 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02002023/* Front Mic: set to PIN_IN (empty by default) */
2024 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2025/* Unselect Front Mic by default in input mixer 3 */
2026 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002027/* Enable unsolicited event for HP jack */
2028 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2029/* Enable speaker output */
2030 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2031 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01002032 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002033/* Enable headphone output */
2034 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2035 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2036 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01002037 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002038 { }
2039};
2040
2041/*
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002042 *ALC888 Acer Aspire 7730G model
2043 */
2044
2045static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
2046/* Bias voltage on for external mic port */
2047 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
2048/* Front Mic: set to PIN_IN (empty by default) */
2049 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2050/* Unselect Front Mic by default in input mixer 3 */
2051 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2052/* Enable unsolicited event for HP jack */
2053 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2054/* Enable speaker output */
2055 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2056 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2057 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
2058/* Enable headphone output */
2059 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2060 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2061 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2062 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
2063/*Enable internal subwoofer */
2064 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2065 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2066 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
2067 {0x17, AC_VERB_SET_EAPD_BTLENABLE, 2},
2068 { }
2069};
2070
2071/*
Hector Martin018df412009-06-04 00:13:40 +02002072 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02002073 */
2074
Hector Martin018df412009-06-04 00:13:40 +02002075static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02002076/* Front Mic: set to PIN_IN (empty by default) */
2077 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2078/* Unselect Front Mic by default in input mixer 3 */
2079 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2080/* Enable unsolicited event for HP jack */
2081 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2082/* Connect Internal Front to Front */
2083 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2084 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2085 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2086/* Connect Internal Rear to Rear */
2087 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2088 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2089 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
2090/* Connect Internal CLFE to CLFE */
2091 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2092 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2093 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
2094/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02002095 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02002096 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2097 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2098/* Enable all DACs */
2099/* DAC DISABLE/MUTE 1? */
2100/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
2101 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
2102 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2103/* DAC DISABLE/MUTE 2? */
2104/* some bit here disables the other DACs. Init=0x4900 */
2105 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
2106 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02002107/* DMIC fix
2108 * This laptop has a stereo digital microphone. The mics are only 1cm apart
2109 * which makes the stereo useless. However, either the mic or the ALC889
2110 * makes the signal become a difference/sum signal instead of standard
2111 * stereo, which is annoying. So instead we flip this bit which makes the
2112 * codec replicate the sum signal to both channels, turning it into a
2113 * normal mono mic.
2114 */
2115/* DMIC_CONTROL? Init value = 0x0001 */
2116 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
2117 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02002118 { }
2119};
2120
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002121static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002122 /* Front mic only available on one ADC */
2123 {
2124 .num_items = 4,
2125 .items = {
2126 { "Mic", 0x0 },
2127 { "Line", 0x2 },
2128 { "CD", 0x4 },
2129 { "Front Mic", 0xb },
2130 },
2131 },
2132 {
2133 .num_items = 3,
2134 .items = {
2135 { "Mic", 0x0 },
2136 { "Line", 0x2 },
2137 { "CD", 0x4 },
2138 },
2139 }
2140};
2141
Tony Vroond2fd4b02009-06-21 00:40:10 +01002142static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2143 /* Interal mic only available on one ADC */
2144 {
Tony Vroon684a8842009-06-26 09:27:50 +01002145 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002146 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +01002147 { "Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002148 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002149 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002150 { "Input Mix", 0xa },
David Henningsson28c4edb2010-12-20 14:24:29 +01002151 { "Internal Mic", 0xb },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002152 },
2153 },
2154 {
Tony Vroon684a8842009-06-26 09:27:50 +01002155 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002156 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +01002157 { "Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002158 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002159 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002160 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002161 },
2162 }
2163};
2164
Hector Martin018df412009-06-04 00:13:40 +02002165static struct hda_input_mux alc889_capture_sources[3] = {
2166 /* Digital mic only available on first "ADC" */
2167 {
2168 .num_items = 5,
2169 .items = {
2170 { "Mic", 0x0 },
2171 { "Line", 0x2 },
2172 { "CD", 0x4 },
2173 { "Front Mic", 0xb },
2174 { "Input Mix", 0xa },
2175 },
2176 },
2177 {
2178 .num_items = 4,
2179 .items = {
2180 { "Mic", 0x0 },
2181 { "Line", 0x2 },
2182 { "CD", 0x4 },
2183 { "Input Mix", 0xa },
2184 },
2185 },
2186 {
2187 .num_items = 4,
2188 .items = {
2189 { "Mic", 0x0 },
2190 { "Line", 0x2 },
2191 { "CD", 0x4 },
2192 { "Input Mix", 0xa },
2193 },
2194 }
2195};
2196
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002197static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002198 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2199 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2200 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2201 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2202 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2203 HDA_OUTPUT),
2204 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2205 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2206 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2207 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2208 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2209 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2210 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2211 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2212 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2213 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01002214 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002215 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002216 { } /* end */
2217};
2218
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002219static struct snd_kcontrol_new alc888_acer_aspire_4930g_mixer[] = {
2220 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2221 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2222 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2223 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Łukasz Wojniłowicz786c51f2011-02-24 10:03:31 +01002224 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002225 HDA_OUTPUT),
Łukasz Wojniłowicz786c51f2011-02-24 10:03:31 +01002226 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2227 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2228 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2229 HDA_CODEC_VOLUME_MONO("Internal LFE Playback Volume", 0x0f, 1, 0x0, HDA_OUTPUT),
2230 HDA_BIND_MUTE_MONO("Internal LFE Playback Switch", 0x0f, 1, 2, HDA_INPUT),
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002231 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2232 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2233 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2234 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2235 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2236 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
2237 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2238 { } /* end */
2239};
2240
Hector Martin556eea92009-12-20 22:51:23 +01002241static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2242 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2243 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2244 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2245 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2246 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2247 HDA_OUTPUT),
2248 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2249 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2250 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2251 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2252 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2253 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01002254 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hector Martin556eea92009-12-20 22:51:23 +01002255 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2256 { } /* end */
2257};
2258
2259
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002260static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002261{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002262 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002263
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002264 spec->autocfg.hp_pins[0] = 0x15;
2265 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01002266 spec->autocfg.speaker_pins[1] = 0x16;
2267 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002268}
2269
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002270static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02002271{
2272 struct alc_spec *spec = codec->spec;
2273
2274 spec->autocfg.hp_pins[0] = 0x15;
2275 spec->autocfg.speaker_pins[0] = 0x14;
2276 spec->autocfg.speaker_pins[1] = 0x16;
2277 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02002278}
2279
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002280static void alc888_acer_aspire_7730g_setup(struct hda_codec *codec)
2281{
2282 struct alc_spec *spec = codec->spec;
2283
2284 spec->autocfg.hp_pins[0] = 0x15;
2285 spec->autocfg.speaker_pins[0] = 0x14;
2286 spec->autocfg.speaker_pins[1] = 0x16;
2287 spec->autocfg.speaker_pins[2] = 0x17;
2288}
2289
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002290static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02002291{
2292 struct alc_spec *spec = codec->spec;
2293
2294 spec->autocfg.hp_pins[0] = 0x15;
2295 spec->autocfg.speaker_pins[0] = 0x14;
2296 spec->autocfg.speaker_pins[1] = 0x16;
2297 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02002298}
2299
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002300/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002301 * ALC880 3-stack model
2302 *
2303 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002304 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2305 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07002306 */
2307
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002308static hda_nid_t alc880_dac_nids[4] = {
2309 /* front, rear, clfe, rear_surr */
2310 0x02, 0x05, 0x04, 0x03
2311};
2312
2313static hda_nid_t alc880_adc_nids[3] = {
2314 /* ADC0-2 */
2315 0x07, 0x08, 0x09,
2316};
2317
2318/* The datasheet says the node 0x07 is connected from inputs,
2319 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01002320 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07002321 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002322static hda_nid_t alc880_adc_nids_alt[2] = {
2323 /* ADC1-2 */
2324 0x08, 0x09,
2325};
2326
2327#define ALC880_DIGOUT_NID 0x06
2328#define ALC880_DIGIN_NID 0x0a
2329
2330static struct hda_input_mux alc880_capture_source = {
2331 .num_items = 4,
2332 .items = {
2333 { "Mic", 0x0 },
2334 { "Front Mic", 0x3 },
2335 { "Line", 0x2 },
2336 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002337 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002338};
2339
2340/* channel source setting (2/6 channel selection for 3-stack) */
2341/* 2ch mode */
2342static struct hda_verb alc880_threestack_ch2_init[] = {
2343 /* set line-in to input, mute it */
2344 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2345 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2346 /* set mic-in to input vref 80%, mute it */
2347 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2348 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002349 { } /* end */
2350};
2351
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002352/* 6ch mode */
2353static struct hda_verb alc880_threestack_ch6_init[] = {
2354 /* set line-in to output, unmute it */
2355 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2356 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2357 /* set mic-in to output, unmute it */
2358 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2359 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2360 { } /* end */
2361};
2362
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002363static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002364 { 2, alc880_threestack_ch2_init },
2365 { 6, alc880_threestack_ch6_init },
2366};
2367
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002368static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002369 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002370 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002371 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002372 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002373 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2374 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002375 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2376 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002377 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2378 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2379 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2380 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2381 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2382 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2383 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2384 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002385 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002386 {
2387 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2388 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002389 .info = alc_ch_mode_info,
2390 .get = alc_ch_mode_get,
2391 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002392 },
2393 { } /* end */
2394};
2395
2396/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002397static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2398 struct snd_ctl_elem_info *uinfo)
2399{
2400 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2401 struct alc_spec *spec = codec->spec;
2402 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002403
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002404 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002405 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2406 HDA_INPUT);
2407 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002408 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002409 return err;
2410}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002411
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002412static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2413 unsigned int size, unsigned int __user *tlv)
2414{
2415 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2416 struct alc_spec *spec = codec->spec;
2417 int err;
2418
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002419 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002420 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2421 HDA_INPUT);
2422 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002423 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002424 return err;
2425}
2426
2427typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2428 struct snd_ctl_elem_value *ucontrol);
2429
2430static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2431 struct snd_ctl_elem_value *ucontrol,
2432 getput_call_t func)
2433{
2434 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2435 struct alc_spec *spec = codec->spec;
2436 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2437 int err;
2438
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002439 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002440 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2441 3, 0, HDA_INPUT);
2442 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002443 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002444 return err;
2445}
2446
2447static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2448 struct snd_ctl_elem_value *ucontrol)
2449{
2450 return alc_cap_getput_caller(kcontrol, ucontrol,
2451 snd_hda_mixer_amp_volume_get);
2452}
2453
2454static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2455 struct snd_ctl_elem_value *ucontrol)
2456{
2457 return alc_cap_getput_caller(kcontrol, ucontrol,
2458 snd_hda_mixer_amp_volume_put);
2459}
2460
2461/* capture mixer elements */
2462#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2463
2464static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2465 struct snd_ctl_elem_value *ucontrol)
2466{
2467 return alc_cap_getput_caller(kcontrol, ucontrol,
2468 snd_hda_mixer_amp_switch_get);
2469}
2470
2471static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2472 struct snd_ctl_elem_value *ucontrol)
2473{
2474 return alc_cap_getput_caller(kcontrol, ucontrol,
2475 snd_hda_mixer_amp_switch_put);
2476}
2477
Takashi Iwaia23b6882009-03-23 15:21:36 +01002478#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002479 { \
2480 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2481 .name = "Capture Switch", \
2482 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2483 .count = num, \
2484 .info = alc_cap_sw_info, \
2485 .get = alc_cap_sw_get, \
2486 .put = alc_cap_sw_put, \
2487 }, \
2488 { \
2489 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2490 .name = "Capture Volume", \
2491 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2492 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2493 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2494 .count = num, \
2495 .info = alc_cap_vol_info, \
2496 .get = alc_cap_vol_get, \
2497 .put = alc_cap_vol_put, \
2498 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002499 }
2500
2501#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002502 { \
2503 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2504 /* .name = "Capture Source", */ \
2505 .name = "Input Source", \
2506 .count = num, \
2507 .info = alc_mux_enum_info, \
2508 .get = alc_mux_enum_get, \
2509 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002510 }
2511
2512#define DEFINE_CAPMIX(num) \
2513static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2514 _DEFINE_CAPMIX(num), \
2515 _DEFINE_CAPSRC(num), \
2516 { } /* end */ \
2517}
2518
2519#define DEFINE_CAPMIX_NOSRC(num) \
2520static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2521 _DEFINE_CAPMIX(num), \
2522 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002523}
2524
2525/* up to three ADCs */
2526DEFINE_CAPMIX(1);
2527DEFINE_CAPMIX(2);
2528DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002529DEFINE_CAPMIX_NOSRC(1);
2530DEFINE_CAPMIX_NOSRC(2);
2531DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002532
2533/*
2534 * ALC880 5-stack model
2535 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002536 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2537 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002538 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2539 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2540 */
2541
2542/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002543static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002544 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002545 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002546 { } /* end */
2547};
2548
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002549/* channel source setting (6/8 channel selection for 5-stack) */
2550/* 6ch mode */
2551static struct hda_verb alc880_fivestack_ch6_init[] = {
2552 /* set line-in to input, mute it */
2553 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2554 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002555 { } /* end */
2556};
2557
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002558/* 8ch mode */
2559static struct hda_verb alc880_fivestack_ch8_init[] = {
2560 /* set line-in to output, unmute it */
2561 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2562 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2563 { } /* end */
2564};
2565
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002566static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002567 { 6, alc880_fivestack_ch6_init },
2568 { 8, alc880_fivestack_ch8_init },
2569};
2570
2571
2572/*
2573 * ALC880 6-stack model
2574 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002575 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2576 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002577 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2578 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2579 */
2580
2581static hda_nid_t alc880_6st_dac_nids[4] = {
2582 /* front, rear, clfe, rear_surr */
2583 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002584};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002585
2586static struct hda_input_mux alc880_6stack_capture_source = {
2587 .num_items = 4,
2588 .items = {
2589 { "Mic", 0x0 },
2590 { "Front Mic", 0x1 },
2591 { "Line", 0x2 },
2592 { "CD", 0x4 },
2593 },
2594};
2595
2596/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002597static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002598 { 8, NULL },
2599};
2600
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002601static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002602 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002603 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002604 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002605 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002606 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2607 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002608 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2609 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002610 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002611 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002612 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2613 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2614 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2615 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2616 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2617 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2618 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2619 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002620 {
2621 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2622 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002623 .info = alc_ch_mode_info,
2624 .get = alc_ch_mode_get,
2625 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002626 },
2627 { } /* end */
2628};
2629
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002630
2631/*
2632 * ALC880 W810 model
2633 *
2634 * W810 has rear IO for:
2635 * Front (DAC 02)
2636 * Surround (DAC 03)
2637 * Center/LFE (DAC 04)
2638 * Digital out (06)
2639 *
2640 * The system also has a pair of internal speakers, and a headphone jack.
2641 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002642 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002643 * There is a variable resistor to control the speaker or headphone
2644 * volume. This is a hardware-only device without a software API.
2645 *
2646 * Plugging headphones in will disable the internal speakers. This is
2647 * implemented in hardware, not via the driver using jack sense. In
2648 * a similar fashion, plugging into the rear socket marked "front" will
2649 * disable both the speakers and headphones.
2650 *
2651 * For input, there's a microphone jack, and an "audio in" jack.
2652 * These may not do anything useful with this driver yet, because I
2653 * haven't setup any initialization verbs for these yet...
2654 */
2655
2656static hda_nid_t alc880_w810_dac_nids[3] = {
2657 /* front, rear/surround, clfe */
2658 0x02, 0x03, 0x04
2659};
2660
2661/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002662static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002663 { 6, NULL }
2664};
2665
2666/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002667static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002668 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002669 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002670 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002671 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002672 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2673 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002674 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2675 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002676 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2677 { } /* end */
2678};
2679
2680
2681/*
2682 * Z710V model
2683 *
2684 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002685 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2686 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002687 */
2688
2689static hda_nid_t alc880_z71v_dac_nids[1] = {
2690 0x02
2691};
2692#define ALC880_Z71V_HP_DAC 0x03
2693
2694/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002695static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002696 { 2, NULL }
2697};
2698
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002699static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002700 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002701 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002702 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002703 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002704 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2705 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2706 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2707 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2708 { } /* end */
2709};
2710
2711
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002712/*
2713 * ALC880 F1734 model
2714 *
2715 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2716 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2717 */
2718
2719static hda_nid_t alc880_f1734_dac_nids[1] = {
2720 0x03
2721};
2722#define ALC880_F1734_HP_DAC 0x02
2723
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002724static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002725 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002726 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002727 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2728 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002729 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2730 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002731 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2732 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002733 { } /* end */
2734};
2735
Takashi Iwai937b4162008-02-11 14:52:36 +01002736static struct hda_input_mux alc880_f1734_capture_source = {
2737 .num_items = 2,
2738 .items = {
2739 { "Mic", 0x1 },
2740 { "CD", 0x4 },
2741 },
2742};
2743
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002744
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002745/*
2746 * ALC880 ASUS model
2747 *
2748 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2749 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2750 * Mic = 0x18, Line = 0x1a
2751 */
2752
2753#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2754#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2755
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002756static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002757 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002758 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002759 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002760 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002761 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2762 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002763 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2764 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002765 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2766 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2767 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2768 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2769 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2770 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002771 {
2772 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2773 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002774 .info = alc_ch_mode_info,
2775 .get = alc_ch_mode_get,
2776 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002777 },
2778 { } /* end */
2779};
2780
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002781/*
2782 * ALC880 ASUS W1V model
2783 *
2784 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2785 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2786 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2787 */
2788
2789/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002790static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002791 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2792 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002793 { } /* end */
2794};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002795
Kailang Yangdf694da2005-12-05 19:42:22 +01002796/* TCL S700 */
2797static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2798 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2799 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2800 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2801 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2802 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2803 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2804 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2805 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2806 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002807 { } /* end */
2808};
2809
Kailang Yangccc656c2006-10-17 12:32:26 +02002810/* Uniwill */
2811static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002812 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2813 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2814 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2815 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002816 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2817 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2818 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2819 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2820 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2821 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2822 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2823 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2824 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2825 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2826 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2827 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002828 {
2829 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2830 .name = "Channel Mode",
2831 .info = alc_ch_mode_info,
2832 .get = alc_ch_mode_get,
2833 .put = alc_ch_mode_put,
2834 },
2835 { } /* end */
2836};
2837
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002838static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2839 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2840 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2841 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2842 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2843 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2844 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +01002845 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2846 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01002847 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2848 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002849 { } /* end */
2850};
2851
Kailang Yangccc656c2006-10-17 12:32:26 +02002852static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002853 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2854 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2855 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2856 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002857 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2858 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2859 { } /* end */
2860};
2861
Linus Torvalds1da177e2005-04-16 15:20:36 -07002862/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002863 * virtual master controls
2864 */
2865
2866/*
2867 * slave controls for virtual master
2868 */
Takashi Iwaiea734962011-01-17 11:29:34 +01002869static const char * const alc_slave_vols[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002870 "Front Playback Volume",
2871 "Surround Playback Volume",
2872 "Center Playback Volume",
2873 "LFE Playback Volume",
2874 "Side Playback Volume",
2875 "Headphone Playback Volume",
2876 "Speaker Playback Volume",
2877 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002878 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002879 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002880 NULL,
2881};
2882
Takashi Iwaiea734962011-01-17 11:29:34 +01002883static const char * const alc_slave_sws[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002884 "Front Playback Switch",
2885 "Surround Playback Switch",
2886 "Center Playback Switch",
2887 "LFE Playback Switch",
2888 "Side Playback Switch",
2889 "Headphone Playback Switch",
2890 "Speaker Playback Switch",
2891 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002892 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002893 "Line-Out Playback Switch",
2894 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002895 NULL,
2896};
2897
2898/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002899 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002900 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002901
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002902#define NID_MAPPING (-1)
2903
2904#define SUBDEV_SPEAKER_ (0 << 6)
2905#define SUBDEV_HP_ (1 << 6)
2906#define SUBDEV_LINE_ (2 << 6)
2907#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2908#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2909#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2910
Takashi Iwai603c4012008-07-30 15:01:44 +02002911static void alc_free_kctls(struct hda_codec *codec);
2912
Takashi Iwai67d634c2009-11-16 15:35:59 +01002913#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002914/* additional beep mixers; the actual parameters are overwritten at build */
2915static struct snd_kcontrol_new alc_beep_mixer[] = {
2916 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002917 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002918 { } /* end */
2919};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002920#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002921
Linus Torvalds1da177e2005-04-16 15:20:36 -07002922static int alc_build_controls(struct hda_codec *codec)
2923{
2924 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02002925 struct snd_kcontrol *kctl = NULL;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002926 struct snd_kcontrol_new *knew;
2927 int i, j, err;
2928 unsigned int u;
2929 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002930
2931 for (i = 0; i < spec->num_mixers; i++) {
2932 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2933 if (err < 0)
2934 return err;
2935 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002936 if (spec->cap_mixer) {
2937 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2938 if (err < 0)
2939 return err;
2940 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002941 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002942 err = snd_hda_create_spdif_out_ctls(codec,
2943 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002944 if (err < 0)
2945 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002946 if (!spec->no_analog) {
2947 err = snd_hda_create_spdif_share_sw(codec,
2948 &spec->multiout);
2949 if (err < 0)
2950 return err;
2951 spec->multiout.share_spdif = 1;
2952 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002953 }
2954 if (spec->dig_in_nid) {
2955 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2956 if (err < 0)
2957 return err;
2958 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002959
Takashi Iwai67d634c2009-11-16 15:35:59 +01002960#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002961 /* create beep controls if needed */
2962 if (spec->beep_amp) {
2963 struct snd_kcontrol_new *knew;
2964 for (knew = alc_beep_mixer; knew->name; knew++) {
2965 struct snd_kcontrol *kctl;
2966 kctl = snd_ctl_new1(knew, codec);
2967 if (!kctl)
2968 return -ENOMEM;
2969 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002970 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002971 if (err < 0)
2972 return err;
2973 }
2974 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002975#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002976
Takashi Iwai2134ea42008-01-10 16:53:55 +01002977 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002978 if (!spec->no_analog &&
2979 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002980 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002981 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002982 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002983 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002984 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002985 if (err < 0)
2986 return err;
2987 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002988 if (!spec->no_analog &&
2989 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002990 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2991 NULL, alc_slave_sws);
2992 if (err < 0)
2993 return err;
2994 }
2995
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002996 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02002997 if (spec->capsrc_nids || spec->adc_nids) {
2998 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2999 if (!kctl)
3000 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
3001 for (i = 0; kctl && i < kctl->count; i++) {
3002 hda_nid_t *nids = spec->capsrc_nids;
3003 if (!nids)
3004 nids = spec->adc_nids;
3005 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
3006 if (err < 0)
3007 return err;
3008 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003009 }
3010 if (spec->cap_mixer) {
3011 const char *kname = kctl ? kctl->id.name : NULL;
3012 for (knew = spec->cap_mixer; knew->name; knew++) {
3013 if (kname && strcmp(knew->name, kname) == 0)
3014 continue;
3015 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3016 for (i = 0; kctl && i < kctl->count; i++) {
3017 err = snd_hda_add_nid(codec, kctl, i,
3018 spec->adc_nids[i]);
3019 if (err < 0)
3020 return err;
3021 }
3022 }
3023 }
3024
3025 /* other nid->control mapping */
3026 for (i = 0; i < spec->num_mixers; i++) {
3027 for (knew = spec->mixers[i]; knew->name; knew++) {
3028 if (knew->iface != NID_MAPPING)
3029 continue;
3030 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3031 if (kctl == NULL)
3032 continue;
3033 u = knew->subdevice;
3034 for (j = 0; j < 4; j++, u >>= 8) {
3035 nid = u & 0x3f;
3036 if (nid == 0)
3037 continue;
3038 switch (u & 0xc0) {
3039 case SUBDEV_SPEAKER_:
3040 nid = spec->autocfg.speaker_pins[nid];
3041 break;
3042 case SUBDEV_LINE_:
3043 nid = spec->autocfg.line_out_pins[nid];
3044 break;
3045 case SUBDEV_HP_:
3046 nid = spec->autocfg.hp_pins[nid];
3047 break;
3048 default:
3049 continue;
3050 }
3051 err = snd_hda_add_nid(codec, kctl, 0, nid);
3052 if (err < 0)
3053 return err;
3054 }
3055 u = knew->private_value;
3056 for (j = 0; j < 4; j++, u >>= 8) {
3057 nid = u & 0xff;
3058 if (nid == 0)
3059 continue;
3060 err = snd_hda_add_nid(codec, kctl, 0, nid);
3061 if (err < 0)
3062 return err;
3063 }
3064 }
3065 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01003066
3067 alc_free_kctls(codec); /* no longer needed */
3068
Linus Torvalds1da177e2005-04-16 15:20:36 -07003069 return 0;
3070}
3071
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003072
Linus Torvalds1da177e2005-04-16 15:20:36 -07003073/*
3074 * initialize the codec volumes, etc
3075 */
3076
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003077/*
3078 * generic initialization of ADC, input mixers and output mixers
3079 */
3080static struct hda_verb alc880_volume_init_verbs[] = {
3081 /*
3082 * Unmute ADC0-2 and set the default input to mic-in
3083 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003084 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003085 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003086 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003087 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003088 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003089 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003090
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003091 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3092 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003093 * Note: PASD motherboards uses the Line In 2 as the input for front
3094 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003095 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003096 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003097 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3098 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3099 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3101 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003104
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003105 /*
3106 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003107 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003108 /* set vol=0 to output mixers */
3109 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3110 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3111 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3112 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3113 /* set up input amps for analog loopback */
3114 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003115 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3116 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003117 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3118 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003119 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3120 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003121 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3122 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003123
3124 { }
3125};
3126
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003127/*
3128 * 3-stack pin configuration:
3129 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
3130 */
3131static struct hda_verb alc880_pin_3stack_init_verbs[] = {
3132 /*
3133 * preset connection lists of input pins
3134 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3135 */
3136 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3137 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3138 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3139
3140 /*
3141 * Set pin mode and muting
3142 */
3143 /* set front pin widgets 0x14 for output */
3144 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3145 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3146 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3147 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3148 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3149 /* Mic2 (as headphone out) for HP output */
3150 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3151 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3152 /* Line In pin widget for input */
3153 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3154 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3155 /* Line2 (as front mic) pin widget for input and vref at 80% */
3156 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3157 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3158 /* CD pin widget for input */
3159 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3160
3161 { }
3162};
3163
3164/*
3165 * 5-stack pin configuration:
3166 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3167 * line-in/side = 0x1a, f-mic = 0x1b
3168 */
3169static struct hda_verb alc880_pin_5stack_init_verbs[] = {
3170 /*
3171 * preset connection lists of input pins
3172 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3173 */
3174 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3175 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3176
3177 /*
3178 * Set pin mode and muting
3179 */
3180 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02003181 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3182 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3183 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3184 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003185 /* unmute pins for output (no gain on this amp) */
3186 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3187 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3188 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3189 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3190
Linus Torvalds1da177e2005-04-16 15:20:36 -07003191 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003192 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003193 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3194 /* Mic2 (as headphone out) for HP output */
3195 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003196 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003197 /* Line In pin widget for input */
3198 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3199 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3200 /* Line2 (as front mic) pin widget for input and vref at 80% */
3201 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3202 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3203 /* CD pin widget for input */
3204 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003205
3206 { }
3207};
3208
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003209/*
3210 * W810 pin configuration:
3211 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3212 */
3213static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003214 /* hphone/speaker input selector: front DAC */
3215 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3216
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003217 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3218 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3219 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3220 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3221 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3222 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3223
3224 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003225 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003226
Linus Torvalds1da177e2005-04-16 15:20:36 -07003227 { }
3228};
3229
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003230/*
3231 * Z71V pin configuration:
3232 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3233 */
3234static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003235 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003236 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02003237 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003238 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003239
Takashi Iwai16ded522005-06-10 19:58:24 +02003240 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003241 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003242 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003243 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003244
3245 { }
3246};
3247
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003248/*
3249 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003250 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3251 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003252 */
3253static struct hda_verb alc880_pin_6stack_init_verbs[] = {
3254 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3255
Takashi Iwai16ded522005-06-10 19:58:24 +02003256 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003257 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003258 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003259 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003260 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003261 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003262 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003263 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3264
Takashi Iwai16ded522005-06-10 19:58:24 +02003265 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003266 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003267 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003268 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003269 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003270 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003271 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003272 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003273 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003274
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003275 { }
3276};
Takashi Iwai16ded522005-06-10 19:58:24 +02003277
Kailang Yangccc656c2006-10-17 12:32:26 +02003278/*
3279 * Uniwill pin configuration:
3280 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3281 * line = 0x1a
3282 */
3283static struct hda_verb alc880_uniwill_init_verbs[] = {
3284 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3285
3286 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3287 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3288 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3289 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3290 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3291 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3292 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3293 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3294 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3295 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3296 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3297 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3298 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3299 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3300
3301 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3302 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3303 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3304 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3305 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3306 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3307 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3308 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3309 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3310
3311 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3312 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3313
3314 { }
3315};
3316
3317/*
3318* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003319* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003320 */
3321static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3322 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3323
3324 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3325 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3326 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3327 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3328 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3329 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3330 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3331 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3332 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3333 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3335 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3336
3337 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3338 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3339 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3340 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3341 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3342 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3343
3344 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3345 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3346
3347 { }
3348};
3349
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003350static struct hda_verb alc880_beep_init_verbs[] = {
3351 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3352 { }
3353};
3354
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003355/* auto-toggle front mic */
Anisse Astiereeb43382010-12-16 12:19:47 +01003356static void alc88x_simple_mic_automute(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003357{
3358 unsigned int present;
3359 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003360
Wu Fengguang864f92b2009-11-18 12:38:02 +08003361 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003362 bits = present ? HDA_AMP_MUTE : 0;
3363 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003364}
3365
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003366static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003367{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003368 struct alc_spec *spec = codec->spec;
3369
3370 spec->autocfg.hp_pins[0] = 0x14;
3371 spec->autocfg.speaker_pins[0] = 0x15;
3372 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003373}
3374
3375static void alc880_uniwill_init_hook(struct hda_codec *codec)
3376{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003377 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01003378 alc88x_simple_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003379}
3380
3381static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3382 unsigned int res)
3383{
3384 /* Looks like the unsol event is incompatible with the standard
3385 * definition. 4bit tag is placed at 28 bit!
3386 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003387 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003388 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01003389 alc88x_simple_mic_automute(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003390 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003391 default:
3392 alc_automute_amp_unsol_event(codec, res);
3393 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003394 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003395}
3396
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003397static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003398{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003399 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003400
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003401 spec->autocfg.hp_pins[0] = 0x14;
3402 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02003403}
3404
3405static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3406{
3407 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003408
Kailang Yangccc656c2006-10-17 12:32:26 +02003409 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003410 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3411 present &= HDA_AMP_VOLMASK;
3412 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3413 HDA_AMP_VOLMASK, present);
3414 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3415 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003416}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003417
Kailang Yangccc656c2006-10-17 12:32:26 +02003418static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3419 unsigned int res)
3420{
3421 /* Looks like the unsol event is incompatible with the standard
3422 * definition. 4bit tag is placed at 28 bit!
3423 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003424 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003425 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003426 else
3427 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003428}
3429
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003430/*
3431 * F1734 pin configuration:
3432 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3433 */
3434static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003435 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003436 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3437 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3438 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3439 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3440
3441 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3442 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3443 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3444 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3445
3446 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3447 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003448 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003449 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3450 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3451 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3452 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3453 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3454 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003455
Takashi Iwai937b4162008-02-11 14:52:36 +01003456 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3457 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3458
Takashi Iwai16ded522005-06-10 19:58:24 +02003459 { }
3460};
3461
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003462/*
3463 * ASUS pin configuration:
3464 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3465 */
3466static struct hda_verb alc880_pin_asus_init_verbs[] = {
3467 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3468 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3469 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3470 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3471
3472 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3473 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3474 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3475 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3476 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3477 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3478 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3479 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3480
3481 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3482 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3483 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3484 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3485 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3486 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3487 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3488 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3489 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003490
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003491 { }
3492};
3493
3494/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003495#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3496#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003497#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003498
Kailang Yangdf694da2005-12-05 19:42:22 +01003499/* Clevo m520g init */
3500static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3501 /* headphone output */
3502 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3503 /* line-out */
3504 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3505 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3506 /* Line-in */
3507 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3508 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3509 /* CD */
3510 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3511 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3512 /* Mic1 (rear panel) */
3513 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3514 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3515 /* Mic2 (front panel) */
3516 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3517 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3518 /* headphone */
3519 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3520 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3521 /* change to EAPD mode */
3522 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3523 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3524
3525 { }
3526};
3527
3528static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003529 /* change to EAPD mode */
3530 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3531 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3532
Kailang Yangdf694da2005-12-05 19:42:22 +01003533 /* Headphone output */
3534 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3535 /* Front output*/
3536 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3537 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3538
3539 /* Line In pin widget for input */
3540 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3541 /* CD pin widget for input */
3542 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3543 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3544 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3545
3546 /* change to EAPD mode */
3547 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3548 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3549
3550 { }
3551};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003552
3553/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003554 * LG m1 express dual
3555 *
3556 * Pin assignment:
3557 * Rear Line-In/Out (blue): 0x14
3558 * Build-in Mic-In: 0x15
3559 * Speaker-out: 0x17
3560 * HP-Out (green): 0x1b
3561 * Mic-In/Out (red): 0x19
3562 * SPDIF-Out: 0x1e
3563 */
3564
3565/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3566static hda_nid_t alc880_lg_dac_nids[3] = {
3567 0x05, 0x02, 0x03
3568};
3569
3570/* seems analog CD is not working */
3571static struct hda_input_mux alc880_lg_capture_source = {
3572 .num_items = 3,
3573 .items = {
3574 { "Mic", 0x1 },
3575 { "Line", 0x5 },
3576 { "Internal Mic", 0x6 },
3577 },
3578};
3579
3580/* 2,4,6 channel modes */
3581static struct hda_verb alc880_lg_ch2_init[] = {
3582 /* set line-in and mic-in to input */
3583 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3584 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3585 { }
3586};
3587
3588static struct hda_verb alc880_lg_ch4_init[] = {
3589 /* set line-in to out and mic-in to input */
3590 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3591 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3592 { }
3593};
3594
3595static struct hda_verb alc880_lg_ch6_init[] = {
3596 /* set line-in and mic-in to output */
3597 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3598 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3599 { }
3600};
3601
3602static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3603 { 2, alc880_lg_ch2_init },
3604 { 4, alc880_lg_ch4_init },
3605 { 6, alc880_lg_ch6_init },
3606};
3607
3608static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003609 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3610 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003611 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3612 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3613 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3614 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3615 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3616 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3617 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3618 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3619 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3620 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3621 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3622 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3623 {
3624 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3625 .name = "Channel Mode",
3626 .info = alc_ch_mode_info,
3627 .get = alc_ch_mode_get,
3628 .put = alc_ch_mode_put,
3629 },
3630 { } /* end */
3631};
3632
3633static struct hda_verb alc880_lg_init_verbs[] = {
3634 /* set capture source to mic-in */
3635 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3636 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3637 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3638 /* mute all amp mixer inputs */
3639 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003642 /* line-in to input */
3643 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3644 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3645 /* built-in mic */
3646 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3647 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3648 /* speaker-out */
3649 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3650 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3651 /* mic-in to input */
3652 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3653 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3654 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3655 /* HP-out */
3656 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3657 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3658 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3659 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003660 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003661 { }
3662};
3663
3664/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003665static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003666{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003667 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003668
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003669 spec->autocfg.hp_pins[0] = 0x1b;
3670 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003671}
3672
3673/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003674 * LG LW20
3675 *
3676 * Pin assignment:
3677 * Speaker-out: 0x14
3678 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003679 * Built-in Mic-In: 0x19
3680 * Line-In: 0x1b
3681 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003682 * SPDIF-Out: 0x1e
3683 */
3684
Takashi Iwaid6815182006-03-23 16:06:23 +01003685static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003686 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003687 .items = {
3688 { "Mic", 0x0 },
3689 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003690 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003691 },
3692};
3693
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003694#define alc880_lg_lw_modes alc880_threestack_modes
3695
Takashi Iwaid6815182006-03-23 16:06:23 +01003696static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003697 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3698 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3699 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3700 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3701 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3702 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3703 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3704 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3705 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3706 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3709 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3710 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003711 {
3712 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3713 .name = "Channel Mode",
3714 .info = alc_ch_mode_info,
3715 .get = alc_ch_mode_get,
3716 .put = alc_ch_mode_put,
3717 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003718 { } /* end */
3719};
3720
3721static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003722 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3723 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3724 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3725
Takashi Iwaid6815182006-03-23 16:06:23 +01003726 /* set capture source to mic-in */
3727 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3728 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3729 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003730 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003731 /* speaker-out */
3732 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3733 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3734 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003735 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3736 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3737 /* mic-in to input */
3738 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3739 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3740 /* built-in mic */
3741 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3742 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3743 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003744 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003745 { }
3746};
3747
3748/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003749static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003750{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003751 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003752
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003753 spec->autocfg.hp_pins[0] = 0x1b;
3754 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003755}
3756
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003757static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3758 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3759 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3760 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3761 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3762 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3763 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3764 { } /* end */
3765};
3766
3767static struct hda_input_mux alc880_medion_rim_capture_source = {
3768 .num_items = 2,
3769 .items = {
3770 { "Mic", 0x0 },
3771 { "Internal Mic", 0x1 },
3772 },
3773};
3774
3775static struct hda_verb alc880_medion_rim_init_verbs[] = {
3776 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3777
3778 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3779 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3780
3781 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3782 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3783 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3784 /* Mic2 (as headphone out) for HP output */
3785 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3786 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3787 /* Internal Speaker */
3788 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3789 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3790
3791 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3792 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3793
3794 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3795 { }
3796};
3797
3798/* toggle speaker-output according to the hp-jack state */
3799static void alc880_medion_rim_automute(struct hda_codec *codec)
3800{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003801 struct alc_spec *spec = codec->spec;
3802 alc_automute_amp(codec);
3803 /* toggle EAPD */
3804 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003805 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3806 else
3807 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3808}
3809
3810static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3811 unsigned int res)
3812{
3813 /* Looks like the unsol event is incompatible with the standard
3814 * definition. 4bit tag is placed at 28 bit!
3815 */
3816 if ((res >> 28) == ALC880_HP_EVENT)
3817 alc880_medion_rim_automute(codec);
3818}
3819
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003820static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003821{
3822 struct alc_spec *spec = codec->spec;
3823
3824 spec->autocfg.hp_pins[0] = 0x14;
3825 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003826}
3827
Takashi Iwaicb53c622007-08-10 17:21:45 +02003828#ifdef CONFIG_SND_HDA_POWER_SAVE
3829static struct hda_amp_list alc880_loopbacks[] = {
3830 { 0x0b, HDA_INPUT, 0 },
3831 { 0x0b, HDA_INPUT, 1 },
3832 { 0x0b, HDA_INPUT, 2 },
3833 { 0x0b, HDA_INPUT, 3 },
3834 { 0x0b, HDA_INPUT, 4 },
3835 { } /* end */
3836};
3837
3838static struct hda_amp_list alc880_lg_loopbacks[] = {
3839 { 0x0b, HDA_INPUT, 1 },
3840 { 0x0b, HDA_INPUT, 6 },
3841 { 0x0b, HDA_INPUT, 7 },
3842 { } /* end */
3843};
3844#endif
3845
Takashi Iwaid6815182006-03-23 16:06:23 +01003846/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003847 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003848 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003849
Linus Torvalds1da177e2005-04-16 15:20:36 -07003850static int alc_init(struct hda_codec *codec)
3851{
3852 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003853 unsigned int i;
3854
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003855 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003856 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003857
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003858 for (i = 0; i < spec->num_init_verbs; i++)
3859 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003860
3861 if (spec->init_hook)
3862 spec->init_hook(codec);
3863
Takashi Iwai58701122011-01-13 15:41:45 +01003864 alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT);
3865
Takashi Iwai9e5341b2010-09-21 09:57:06 +02003866 hda_call_check_power_status(codec, 0x01);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003867 return 0;
3868}
3869
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003870static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3871{
3872 struct alc_spec *spec = codec->spec;
3873
3874 if (spec->unsol_event)
3875 spec->unsol_event(codec, res);
3876}
3877
Takashi Iwaicb53c622007-08-10 17:21:45 +02003878#ifdef CONFIG_SND_HDA_POWER_SAVE
3879static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3880{
3881 struct alc_spec *spec = codec->spec;
3882 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3883}
3884#endif
3885
Linus Torvalds1da177e2005-04-16 15:20:36 -07003886/*
3887 * Analog playback callbacks
3888 */
3889static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3890 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003891 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003892{
3893 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003894 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3895 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003896}
3897
3898static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3899 struct hda_codec *codec,
3900 unsigned int stream_tag,
3901 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003902 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003903{
3904 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003905 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3906 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003907}
3908
3909static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3910 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003911 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003912{
3913 struct alc_spec *spec = codec->spec;
3914 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3915}
3916
3917/*
3918 * Digital out
3919 */
3920static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3921 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003922 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003923{
3924 struct alc_spec *spec = codec->spec;
3925 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3926}
3927
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003928static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3929 struct hda_codec *codec,
3930 unsigned int stream_tag,
3931 unsigned int format,
3932 struct snd_pcm_substream *substream)
3933{
3934 struct alc_spec *spec = codec->spec;
3935 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3936 stream_tag, format, substream);
3937}
3938
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003939static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3940 struct hda_codec *codec,
3941 struct snd_pcm_substream *substream)
3942{
3943 struct alc_spec *spec = codec->spec;
3944 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3945}
3946
Linus Torvalds1da177e2005-04-16 15:20:36 -07003947static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3948 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003949 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003950{
3951 struct alc_spec *spec = codec->spec;
3952 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3953}
3954
3955/*
3956 * Analog capture
3957 */
Takashi Iwai63300792008-01-24 15:31:36 +01003958static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003959 struct hda_codec *codec,
3960 unsigned int stream_tag,
3961 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003962 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003963{
3964 struct alc_spec *spec = codec->spec;
3965
Takashi Iwai63300792008-01-24 15:31:36 +01003966 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003967 stream_tag, 0, format);
3968 return 0;
3969}
3970
Takashi Iwai63300792008-01-24 15:31:36 +01003971static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003972 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003973 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003974{
3975 struct alc_spec *spec = codec->spec;
3976
Takashi Iwai888afa12008-03-18 09:57:50 +01003977 snd_hda_codec_cleanup_stream(codec,
3978 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003979 return 0;
3980}
3981
Takashi Iwai840b64c2010-07-13 22:49:01 +02003982/* analog capture with dynamic dual-adc changes */
3983static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3984 struct hda_codec *codec,
3985 unsigned int stream_tag,
3986 unsigned int format,
3987 struct snd_pcm_substream *substream)
3988{
3989 struct alc_spec *spec = codec->spec;
3990 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
3991 spec->cur_adc_stream_tag = stream_tag;
3992 spec->cur_adc_format = format;
3993 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
3994 return 0;
3995}
3996
3997static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3998 struct hda_codec *codec,
3999 struct snd_pcm_substream *substream)
4000{
4001 struct alc_spec *spec = codec->spec;
4002 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
4003 spec->cur_adc = 0;
4004 return 0;
4005}
4006
4007static struct hda_pcm_stream dualmic_pcm_analog_capture = {
4008 .substreams = 1,
4009 .channels_min = 2,
4010 .channels_max = 2,
4011 .nid = 0, /* fill later */
4012 .ops = {
4013 .prepare = dualmic_capture_pcm_prepare,
4014 .cleanup = dualmic_capture_pcm_cleanup
4015 },
4016};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004017
4018/*
4019 */
4020static struct hda_pcm_stream alc880_pcm_analog_playback = {
4021 .substreams = 1,
4022 .channels_min = 2,
4023 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004024 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004025 .ops = {
4026 .open = alc880_playback_pcm_open,
4027 .prepare = alc880_playback_pcm_prepare,
4028 .cleanup = alc880_playback_pcm_cleanup
4029 },
4030};
4031
4032static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01004033 .substreams = 1,
4034 .channels_min = 2,
4035 .channels_max = 2,
4036 /* NID is set in alc_build_pcms */
4037};
4038
4039static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
4040 .substreams = 1,
4041 .channels_min = 2,
4042 .channels_max = 2,
4043 /* NID is set in alc_build_pcms */
4044};
4045
4046static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
4047 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004048 .channels_min = 2,
4049 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004050 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004051 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01004052 .prepare = alc880_alt_capture_pcm_prepare,
4053 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004054 },
4055};
4056
4057static struct hda_pcm_stream alc880_pcm_digital_playback = {
4058 .substreams = 1,
4059 .channels_min = 2,
4060 .channels_max = 2,
4061 /* NID is set in alc_build_pcms */
4062 .ops = {
4063 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02004064 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01004065 .prepare = alc880_dig_playback_pcm_prepare,
4066 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004067 },
4068};
4069
4070static struct hda_pcm_stream alc880_pcm_digital_capture = {
4071 .substreams = 1,
4072 .channels_min = 2,
4073 .channels_max = 2,
4074 /* NID is set in alc_build_pcms */
4075};
4076
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004077/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01004078static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004079 .substreams = 0,
4080 .channels_min = 0,
4081 .channels_max = 0,
4082};
4083
Linus Torvalds1da177e2005-04-16 15:20:36 -07004084static int alc_build_pcms(struct hda_codec *codec)
4085{
4086 struct alc_spec *spec = codec->spec;
4087 struct hda_pcm *info = spec->pcm_rec;
4088 int i;
4089
4090 codec->num_pcms = 1;
4091 codec->pcm_info = info;
4092
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004093 if (spec->no_analog)
4094 goto skip_analog;
4095
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004096 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
4097 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004098 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01004099
Takashi Iwai4a471b72005-12-07 13:56:29 +01004100 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004101 if (snd_BUG_ON(!spec->multiout.dac_nids))
4102 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004103 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
4104 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
4105 }
4106 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004107 if (snd_BUG_ON(!spec->adc_nids))
4108 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004109 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
4110 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
4111 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004112
Takashi Iwai4a471b72005-12-07 13:56:29 +01004113 if (spec->channel_mode) {
4114 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
4115 for (i = 0; i < spec->num_channel_mode; i++) {
4116 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
4117 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
4118 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004119 }
4120 }
4121
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004122 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02004123 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004124 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004125 snprintf(spec->stream_name_digital,
4126 sizeof(spec->stream_name_digital),
4127 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02004128 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08004129 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004130 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004131 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01004132 if (spec->dig_out_type)
4133 info->pcm_type = spec->dig_out_type;
4134 else
4135 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004136 if (spec->multiout.dig_out_nid &&
4137 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004138 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
4139 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
4140 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004141 if (spec->dig_in_nid &&
4142 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004143 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
4144 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
4145 }
Takashi Iwai963f8032008-08-11 10:04:40 +02004146 /* FIXME: do we need this for all Realtek codec models? */
4147 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004148 }
4149
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004150 if (spec->no_analog)
4151 return 0;
4152
Takashi Iwaie08a0072006-09-07 17:52:14 +02004153 /* If the use of more than one ADC is requested for the current
4154 * model, configure a second analog capture-only PCM.
4155 */
4156 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01004157 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
4158 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02004159 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004160 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004161 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01004162 if (spec->alt_dac_nid) {
4163 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4164 *spec->stream_analog_alt_playback;
4165 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
4166 spec->alt_dac_nid;
4167 } else {
4168 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4169 alc_pcm_null_stream;
4170 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
4171 }
4172 if (spec->num_adc_nids > 1) {
4173 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4174 *spec->stream_analog_alt_capture;
4175 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
4176 spec->adc_nids[1];
4177 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
4178 spec->num_adc_nids - 1;
4179 } else {
4180 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4181 alc_pcm_null_stream;
4182 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004183 }
4184 }
4185
Linus Torvalds1da177e2005-04-16 15:20:36 -07004186 return 0;
4187}
4188
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004189static inline void alc_shutup(struct hda_codec *codec)
4190{
4191 snd_hda_shutup_pins(codec);
4192}
4193
Takashi Iwai603c4012008-07-30 15:01:44 +02004194static void alc_free_kctls(struct hda_codec *codec)
4195{
4196 struct alc_spec *spec = codec->spec;
4197
4198 if (spec->kctls.list) {
4199 struct snd_kcontrol_new *kctl = spec->kctls.list;
4200 int i;
4201 for (i = 0; i < spec->kctls.used; i++)
4202 kfree(kctl[i].name);
4203 }
4204 snd_array_free(&spec->kctls);
4205}
4206
Linus Torvalds1da177e2005-04-16 15:20:36 -07004207static void alc_free(struct hda_codec *codec)
4208{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004209 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004210
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004211 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004212 return;
4213
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004214 alc_shutup(codec);
Takashi Iwaicd372fb2011-03-03 14:40:14 +01004215 snd_hda_input_jack_free(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02004216 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004217 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004218 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004219}
4220
Hector Martinf5de24b2009-12-20 22:51:31 +01004221#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05004222static void alc_power_eapd(struct hda_codec *codec)
4223{
4224 /* We currently only handle front, HP */
4225 switch (codec->vendor_id) {
4226 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004227 set_eapd(codec, 0x0f, 0);
4228 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004229 break;
4230 case 0x10ec0262:
4231 case 0x10ec0267:
4232 case 0x10ec0268:
4233 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004234 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05004235 case 0x10ec0272:
4236 case 0x10ec0660:
4237 case 0x10ec0662:
4238 case 0x10ec0663:
4239 case 0x10ec0862:
4240 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004241 set_eapd(codec, 0x14, 0);
4242 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004243 break;
4244 }
4245}
4246
Hector Martinf5de24b2009-12-20 22:51:31 +01004247static int alc_suspend(struct hda_codec *codec, pm_message_t state)
4248{
4249 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004250 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004251 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05004252 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004253 return 0;
4254}
4255#endif
4256
Takashi Iwaie044c392008-10-27 16:56:24 +01004257#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01004258static int alc_resume(struct hda_codec *codec)
4259{
Takashi Iwaie044c392008-10-27 16:56:24 +01004260 codec->patch_ops.init(codec);
4261 snd_hda_codec_resume_amp(codec);
4262 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +02004263 hda_call_check_power_status(codec, 0x01);
Takashi Iwaie044c392008-10-27 16:56:24 +01004264 return 0;
4265}
Takashi Iwaie044c392008-10-27 16:56:24 +01004266#endif
4267
Linus Torvalds1da177e2005-04-16 15:20:36 -07004268/*
4269 */
4270static struct hda_codec_ops alc_patch_ops = {
4271 .build_controls = alc_build_controls,
4272 .build_pcms = alc_build_pcms,
4273 .init = alc_init,
4274 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004275 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004276#ifdef SND_HDA_NEEDS_RESUME
4277 .resume = alc_resume,
4278#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004279#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004280 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004281 .check_power_status = alc_check_power_status,
4282#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004283 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004284};
4285
Kailang Yangc027ddc2010-03-19 11:33:06 +01004286/* replace the codec chip_name with the given string */
4287static int alc_codec_rename(struct hda_codec *codec, const char *name)
4288{
4289 kfree(codec->chip_name);
4290 codec->chip_name = kstrdup(name, GFP_KERNEL);
4291 if (!codec->chip_name) {
4292 alc_free(codec);
4293 return -ENOMEM;
4294 }
4295 return 0;
4296}
4297
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004298/*
4299 * Test configuration for debugging
4300 *
4301 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4302 * enum controls.
4303 */
4304#ifdef CONFIG_SND_DEBUG
4305static hda_nid_t alc880_test_dac_nids[4] = {
4306 0x02, 0x03, 0x04, 0x05
4307};
4308
4309static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004310 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004311 .items = {
4312 { "In-1", 0x0 },
4313 { "In-2", 0x1 },
4314 { "In-3", 0x2 },
4315 { "In-4", 0x3 },
4316 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004317 { "Front", 0x5 },
4318 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004319 },
4320};
4321
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004322static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004323 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004324 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004325 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004326 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004327};
4328
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004329static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4330 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004331{
4332 static char *texts[] = {
4333 "N/A", "Line Out", "HP Out",
4334 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4335 };
4336 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4337 uinfo->count = 1;
4338 uinfo->value.enumerated.items = 8;
4339 if (uinfo->value.enumerated.item >= 8)
4340 uinfo->value.enumerated.item = 7;
4341 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4342 return 0;
4343}
4344
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004345static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4346 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004347{
4348 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4349 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4350 unsigned int pin_ctl, item = 0;
4351
4352 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4353 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4354 if (pin_ctl & AC_PINCTL_OUT_EN) {
4355 if (pin_ctl & AC_PINCTL_HP_EN)
4356 item = 2;
4357 else
4358 item = 1;
4359 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4360 switch (pin_ctl & AC_PINCTL_VREFEN) {
4361 case AC_PINCTL_VREF_HIZ: item = 3; break;
4362 case AC_PINCTL_VREF_50: item = 4; break;
4363 case AC_PINCTL_VREF_GRD: item = 5; break;
4364 case AC_PINCTL_VREF_80: item = 6; break;
4365 case AC_PINCTL_VREF_100: item = 7; break;
4366 }
4367 }
4368 ucontrol->value.enumerated.item[0] = item;
4369 return 0;
4370}
4371
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004372static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
4373 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004374{
4375 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4376 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4377 static unsigned int ctls[] = {
4378 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4379 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4380 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4381 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4382 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4383 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4384 };
4385 unsigned int old_ctl, new_ctl;
4386
4387 old_ctl = snd_hda_codec_read(codec, nid, 0,
4388 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4389 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4390 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004391 int val;
4392 snd_hda_codec_write_cache(codec, nid, 0,
4393 AC_VERB_SET_PIN_WIDGET_CONTROL,
4394 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004395 val = ucontrol->value.enumerated.item[0] >= 3 ?
4396 HDA_AMP_MUTE : 0;
4397 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4398 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004399 return 1;
4400 }
4401 return 0;
4402}
4403
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004404static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4405 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004406{
4407 static char *texts[] = {
4408 "Front", "Surround", "CLFE", "Side"
4409 };
4410 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4411 uinfo->count = 1;
4412 uinfo->value.enumerated.items = 4;
4413 if (uinfo->value.enumerated.item >= 4)
4414 uinfo->value.enumerated.item = 3;
4415 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4416 return 0;
4417}
4418
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004419static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4420 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004421{
4422 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4423 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4424 unsigned int sel;
4425
4426 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4427 ucontrol->value.enumerated.item[0] = sel & 3;
4428 return 0;
4429}
4430
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004431static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4432 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004433{
4434 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4435 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4436 unsigned int sel;
4437
4438 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4439 if (ucontrol->value.enumerated.item[0] != sel) {
4440 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004441 snd_hda_codec_write_cache(codec, nid, 0,
4442 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004443 return 1;
4444 }
4445 return 0;
4446}
4447
4448#define PIN_CTL_TEST(xname,nid) { \
4449 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4450 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004451 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004452 .info = alc_test_pin_ctl_info, \
4453 .get = alc_test_pin_ctl_get, \
4454 .put = alc_test_pin_ctl_put, \
4455 .private_value = nid \
4456 }
4457
4458#define PIN_SRC_TEST(xname,nid) { \
4459 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4460 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004461 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004462 .info = alc_test_pin_src_info, \
4463 .get = alc_test_pin_src_get, \
4464 .put = alc_test_pin_src_put, \
4465 .private_value = nid \
4466 }
4467
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004468static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004469 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4470 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4471 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4472 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004473 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4474 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4475 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4476 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004477 PIN_CTL_TEST("Front Pin Mode", 0x14),
4478 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4479 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4480 PIN_CTL_TEST("Side Pin Mode", 0x17),
4481 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4482 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4483 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4484 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4485 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4486 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4487 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4488 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4489 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4490 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4491 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4492 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4493 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4494 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4495 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4496 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4497 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4498 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004499 {
4500 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4501 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004502 .info = alc_ch_mode_info,
4503 .get = alc_ch_mode_get,
4504 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004505 },
4506 { } /* end */
4507};
4508
4509static struct hda_verb alc880_test_init_verbs[] = {
4510 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004511 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4512 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4513 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4514 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4515 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4516 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4517 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4518 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004519 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004520 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4521 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4522 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4523 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004524 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004525 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4526 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4527 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4528 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004529 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004530 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4531 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4532 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4533 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004534 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004535 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4536 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004537 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4538 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4539 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004540 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004541 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4542 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4543 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4544 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004545 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004546 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004547 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004548 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004549 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004550 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004551 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004552 /* Analog input/passthru */
4553 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4554 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4555 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4556 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4557 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004558 { }
4559};
4560#endif
4561
Linus Torvalds1da177e2005-04-16 15:20:36 -07004562/*
4563 */
4564
Takashi Iwaiea734962011-01-17 11:29:34 +01004565static const char * const alc880_models[ALC880_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004566 [ALC880_3ST] = "3stack",
4567 [ALC880_TCL_S700] = "tcl",
4568 [ALC880_3ST_DIG] = "3stack-digout",
4569 [ALC880_CLEVO] = "clevo",
4570 [ALC880_5ST] = "5stack",
4571 [ALC880_5ST_DIG] = "5stack-digout",
4572 [ALC880_W810] = "w810",
4573 [ALC880_Z71V] = "z71v",
4574 [ALC880_6ST] = "6stack",
4575 [ALC880_6ST_DIG] = "6stack-digout",
4576 [ALC880_ASUS] = "asus",
4577 [ALC880_ASUS_W1V] = "asus-w1v",
4578 [ALC880_ASUS_DIG] = "asus-dig",
4579 [ALC880_ASUS_DIG2] = "asus-dig2",
4580 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004581 [ALC880_UNIWILL_P53] = "uniwill-p53",
4582 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004583 [ALC880_F1734] = "F1734",
4584 [ALC880_LG] = "lg",
4585 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004586 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004587#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004588 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004589#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004590 [ALC880_AUTO] = "auto",
4591};
4592
4593static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004594 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004595 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4596 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4597 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4598 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4599 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4600 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4601 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4602 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004603 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4604 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004605 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4606 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4607 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4608 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4609 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4610 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4611 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4612 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4613 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4614 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004615 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004616 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4617 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4618 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004619 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004620 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004621 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4622 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004623 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4624 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004625 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4626 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4627 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4628 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004629 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4630 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004631 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004632 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004633 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004634 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004635 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4636 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004637 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004638 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004639 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004640 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004641 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004642 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004643 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004644 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004645 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004646 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
Daniel T Chen77c4d5c2010-12-02 22:45:45 -05004647 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004648 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004649 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004650 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4651 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4652 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4653 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004654 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4655 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004656 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004657 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004658 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4659 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004660 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4661 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4662 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004663 /* default Intel */
4664 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004665 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4666 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004667 {}
4668};
4669
Takashi Iwai16ded522005-06-10 19:58:24 +02004670/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004671 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004672 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004673static struct alc_config_preset alc880_presets[] = {
4674 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004675 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004676 .init_verbs = { alc880_volume_init_verbs,
4677 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004678 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004679 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004680 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4681 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004682 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004683 .input_mux = &alc880_capture_source,
4684 },
4685 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004686 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004687 .init_verbs = { alc880_volume_init_verbs,
4688 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004689 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004690 .dac_nids = alc880_dac_nids,
4691 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004692 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4693 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004694 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004695 .input_mux = &alc880_capture_source,
4696 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004697 [ALC880_TCL_S700] = {
4698 .mixers = { alc880_tcl_s700_mixer },
4699 .init_verbs = { alc880_volume_init_verbs,
4700 alc880_pin_tcl_S700_init_verbs,
4701 alc880_gpio2_init_verbs },
4702 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4703 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004704 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4705 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004706 .hp_nid = 0x03,
4707 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4708 .channel_mode = alc880_2_jack_modes,
4709 .input_mux = &alc880_capture_source,
4710 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004711 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004712 .mixers = { alc880_three_stack_mixer,
4713 alc880_five_stack_mixer},
4714 .init_verbs = { alc880_volume_init_verbs,
4715 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004716 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4717 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004718 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4719 .channel_mode = alc880_fivestack_modes,
4720 .input_mux = &alc880_capture_source,
4721 },
4722 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004723 .mixers = { alc880_three_stack_mixer,
4724 alc880_five_stack_mixer },
4725 .init_verbs = { alc880_volume_init_verbs,
4726 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004727 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4728 .dac_nids = alc880_dac_nids,
4729 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004730 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4731 .channel_mode = alc880_fivestack_modes,
4732 .input_mux = &alc880_capture_source,
4733 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004734 [ALC880_6ST] = {
4735 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004736 .init_verbs = { alc880_volume_init_verbs,
4737 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004738 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4739 .dac_nids = alc880_6st_dac_nids,
4740 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4741 .channel_mode = alc880_sixstack_modes,
4742 .input_mux = &alc880_6stack_capture_source,
4743 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004744 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004745 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004746 .init_verbs = { alc880_volume_init_verbs,
4747 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004748 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4749 .dac_nids = alc880_6st_dac_nids,
4750 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004751 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4752 .channel_mode = alc880_sixstack_modes,
4753 .input_mux = &alc880_6stack_capture_source,
4754 },
4755 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004756 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004757 .init_verbs = { alc880_volume_init_verbs,
4758 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004759 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004760 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4761 .dac_nids = alc880_w810_dac_nids,
4762 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004763 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4764 .channel_mode = alc880_w810_modes,
4765 .input_mux = &alc880_capture_source,
4766 },
4767 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004768 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004769 .init_verbs = { alc880_volume_init_verbs,
4770 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004771 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4772 .dac_nids = alc880_z71v_dac_nids,
4773 .dig_out_nid = ALC880_DIGOUT_NID,
4774 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004775 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4776 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004777 .input_mux = &alc880_capture_source,
4778 },
4779 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004780 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004781 .init_verbs = { alc880_volume_init_verbs,
4782 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004783 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4784 .dac_nids = alc880_f1734_dac_nids,
4785 .hp_nid = 0x02,
4786 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4787 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004788 .input_mux = &alc880_f1734_capture_source,
4789 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004790 .setup = alc880_uniwill_p53_setup,
4791 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004792 },
4793 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004794 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004795 .init_verbs = { alc880_volume_init_verbs,
4796 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004797 alc880_gpio1_init_verbs },
4798 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4799 .dac_nids = alc880_asus_dac_nids,
4800 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4801 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004802 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004803 .input_mux = &alc880_capture_source,
4804 },
4805 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004806 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004807 .init_verbs = { alc880_volume_init_verbs,
4808 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004809 alc880_gpio1_init_verbs },
4810 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4811 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004812 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004813 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4814 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004815 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004816 .input_mux = &alc880_capture_source,
4817 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004818 [ALC880_ASUS_DIG2] = {
4819 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004820 .init_verbs = { alc880_volume_init_verbs,
4821 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004822 alc880_gpio2_init_verbs }, /* use GPIO2 */
4823 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4824 .dac_nids = alc880_asus_dac_nids,
4825 .dig_out_nid = ALC880_DIGOUT_NID,
4826 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4827 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004828 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004829 .input_mux = &alc880_capture_source,
4830 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004831 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004832 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004833 .init_verbs = { alc880_volume_init_verbs,
4834 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004835 alc880_gpio1_init_verbs },
4836 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4837 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004838 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004839 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4840 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004841 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004842 .input_mux = &alc880_capture_source,
4843 },
4844 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004845 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004846 .init_verbs = { alc880_volume_init_verbs,
4847 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004848 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4849 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004850 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004851 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4852 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004853 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004854 .input_mux = &alc880_capture_source,
4855 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004856 [ALC880_UNIWILL] = {
4857 .mixers = { alc880_uniwill_mixer },
4858 .init_verbs = { alc880_volume_init_verbs,
4859 alc880_uniwill_init_verbs },
4860 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4861 .dac_nids = alc880_asus_dac_nids,
4862 .dig_out_nid = ALC880_DIGOUT_NID,
4863 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4864 .channel_mode = alc880_threestack_modes,
4865 .need_dac_fix = 1,
4866 .input_mux = &alc880_capture_source,
4867 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004868 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004869 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004870 },
4871 [ALC880_UNIWILL_P53] = {
4872 .mixers = { alc880_uniwill_p53_mixer },
4873 .init_verbs = { alc880_volume_init_verbs,
4874 alc880_uniwill_p53_init_verbs },
4875 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4876 .dac_nids = alc880_asus_dac_nids,
4877 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004878 .channel_mode = alc880_threestack_modes,
4879 .input_mux = &alc880_capture_source,
4880 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004881 .setup = alc880_uniwill_p53_setup,
4882 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004883 },
4884 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004885 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004886 .init_verbs = { alc880_volume_init_verbs,
4887 alc880_uniwill_p53_init_verbs,
4888 alc880_beep_init_verbs },
4889 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4890 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004891 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004892 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4893 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004894 .input_mux = &alc880_capture_source,
4895 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004896 .setup = alc880_uniwill_p53_setup,
4897 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004898 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004899 [ALC880_CLEVO] = {
4900 .mixers = { alc880_three_stack_mixer },
4901 .init_verbs = { alc880_volume_init_verbs,
4902 alc880_pin_clevo_init_verbs },
4903 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4904 .dac_nids = alc880_dac_nids,
4905 .hp_nid = 0x03,
4906 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4907 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004908 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004909 .input_mux = &alc880_capture_source,
4910 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004911 [ALC880_LG] = {
4912 .mixers = { alc880_lg_mixer },
4913 .init_verbs = { alc880_volume_init_verbs,
4914 alc880_lg_init_verbs },
4915 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4916 .dac_nids = alc880_lg_dac_nids,
4917 .dig_out_nid = ALC880_DIGOUT_NID,
4918 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4919 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004920 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004921 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004922 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004923 .setup = alc880_lg_setup,
4924 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004925#ifdef CONFIG_SND_HDA_POWER_SAVE
4926 .loopbacks = alc880_lg_loopbacks,
4927#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004928 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004929 [ALC880_LG_LW] = {
4930 .mixers = { alc880_lg_lw_mixer },
4931 .init_verbs = { alc880_volume_init_verbs,
4932 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004933 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004934 .dac_nids = alc880_dac_nids,
4935 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004936 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4937 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004938 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004939 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004940 .setup = alc880_lg_lw_setup,
4941 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004942 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004943 [ALC880_MEDION_RIM] = {
4944 .mixers = { alc880_medion_rim_mixer },
4945 .init_verbs = { alc880_volume_init_verbs,
4946 alc880_medion_rim_init_verbs,
4947 alc_gpio2_init_verbs },
4948 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4949 .dac_nids = alc880_dac_nids,
4950 .dig_out_nid = ALC880_DIGOUT_NID,
4951 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4952 .channel_mode = alc880_2_jack_modes,
4953 .input_mux = &alc880_medion_rim_capture_source,
4954 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004955 .setup = alc880_medion_rim_setup,
4956 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004957 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004958#ifdef CONFIG_SND_DEBUG
4959 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004960 .mixers = { alc880_test_mixer },
4961 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004962 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4963 .dac_nids = alc880_test_dac_nids,
4964 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004965 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4966 .channel_mode = alc880_test_modes,
4967 .input_mux = &alc880_test_capture_source,
4968 },
4969#endif
4970};
4971
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004972/*
4973 * Automatic parse of I/O pins from the BIOS configuration
4974 */
4975
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004976enum {
4977 ALC_CTL_WIDGET_VOL,
4978 ALC_CTL_WIDGET_MUTE,
4979 ALC_CTL_BIND_MUTE,
4980};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004981static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004982 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4983 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004984 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004985};
4986
4987/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004988static int add_control(struct alc_spec *spec, int type, const char *name,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004989 int cidx, unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004990{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004991 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004992
Takashi Iwai603c4012008-07-30 15:01:44 +02004993 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4994 knew = snd_array_new(&spec->kctls);
4995 if (!knew)
4996 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004997 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004998 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004999 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005000 return -ENOMEM;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005001 knew->index = cidx;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01005002 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01005003 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005004 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005005 return 0;
5006}
5007
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005008static int add_control_with_pfx(struct alc_spec *spec, int type,
5009 const char *pfx, const char *dir,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005010 const char *sfx, int cidx, unsigned long val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005011{
5012 char name[32];
5013 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005014 return add_control(spec, type, name, cidx, val);
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005015}
5016
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005017#define add_pb_vol_ctrl(spec, type, pfx, val) \
5018 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
5019#define add_pb_sw_ctrl(spec, type, pfx, val) \
5020 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
5021#define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
5022 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
5023#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
5024 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005025
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005026#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
5027#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
5028#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
5029#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005030#define alc880_idx_to_dac(nid) ((nid) + 0x02)
5031#define alc880_dac_to_idx(nid) ((nid) - 0x02)
5032#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
5033#define alc880_idx_to_selector(nid) ((nid) + 0x10)
5034#define ALC880_PIN_CD_NID 0x1c
5035
5036/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005037static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
5038 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005039{
5040 hda_nid_t nid;
5041 int assigned[4];
5042 int i, j;
5043
5044 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02005045 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005046
5047 /* check the pins hardwired to audio widget */
5048 for (i = 0; i < cfg->line_outs; i++) {
5049 nid = cfg->line_out_pins[i];
5050 if (alc880_is_fixed_pin(nid)) {
5051 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01005052 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005053 assigned[idx] = 1;
5054 }
5055 }
5056 /* left pins can be connect to any audio widget */
5057 for (i = 0; i < cfg->line_outs; i++) {
5058 nid = cfg->line_out_pins[i];
5059 if (alc880_is_fixed_pin(nid))
5060 continue;
5061 /* search for an empty channel */
5062 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005063 if (!assigned[j]) {
5064 spec->multiout.dac_nids[i] =
5065 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005066 assigned[j] = 1;
5067 break;
5068 }
5069 }
5070 }
5071 spec->multiout.num_dacs = cfg->line_outs;
5072 return 0;
5073}
5074
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005075static const char *alc_get_line_out_pfx(const struct auto_pin_cfg *cfg,
5076 bool can_be_master)
5077{
5078 if (!cfg->hp_outs && !cfg->speaker_outs && can_be_master)
5079 return "Master";
5080
5081 switch (cfg->line_out_type) {
5082 case AUTO_PIN_SPEAKER_OUT:
David Henningssonebbeb3d2011-03-04 14:08:30 +01005083 if (cfg->line_outs == 1)
5084 return "Speaker";
5085 break;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005086 case AUTO_PIN_HP_OUT:
5087 return "Headphone";
5088 default:
5089 if (cfg->line_outs == 1)
5090 return "PCM";
5091 break;
5092 }
5093 return NULL;
5094}
5095
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005096/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01005097static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
5098 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005099{
Takashi Iwaiea734962011-01-17 11:29:34 +01005100 static const char * const chname[4] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005101 "Front", "Surround", NULL /*CLFE*/, "Side"
5102 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005103 const char *pfx = alc_get_line_out_pfx(cfg, false);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005104 hda_nid_t nid;
5105 int i, err;
5106
5107 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005108 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005109 continue;
5110 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005111 if (!pfx && i == 2) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005112 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005113 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5114 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005115 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
5116 HDA_OUTPUT));
5117 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005118 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005119 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5120 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005121 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
5122 HDA_OUTPUT));
5123 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005124 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005125 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5126 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005127 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
5128 HDA_INPUT));
5129 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005130 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005131 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5132 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005133 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
5134 HDA_INPUT));
5135 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005136 return err;
5137 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005138 const char *name = pfx;
David Henningsson7e59e092011-03-04 14:22:25 +01005139 int index = i;
5140 if (!name) {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005141 name = chname[i];
David Henningsson7e59e092011-03-04 14:22:25 +01005142 index = 0;
5143 }
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005144 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
David Henningsson7e59e092011-03-04 14:22:25 +01005145 name, index,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005146 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
5147 HDA_OUTPUT));
5148 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005149 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005150 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
David Henningsson7e59e092011-03-04 14:22:25 +01005151 name, index,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005152 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
5153 HDA_INPUT));
5154 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005155 return err;
5156 }
5157 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005158 return 0;
5159}
5160
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005161/* add playback controls for speaker and HP outputs */
5162static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
5163 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005164{
5165 hda_nid_t nid;
5166 int err;
5167
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005168 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005169 return 0;
5170
5171 if (alc880_is_fixed_pin(pin)) {
5172 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01005173 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005174 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005175 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005176 else
5177 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005178 /* control HP volume/switch on the output mixer amp */
5179 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005180 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005181 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
5182 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005183 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005184 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005185 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
5186 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005187 return err;
5188 } else if (alc880_is_multi_pin(pin)) {
5189 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005190 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005191 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005192 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
5193 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005194 return err;
5195 }
5196 return 0;
5197}
5198
5199/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005200static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005201 const char *ctlname, int ctlidx,
Kailang Yangdf694da2005-12-05 19:42:22 +01005202 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005203{
Kailang Yangdf694da2005-12-05 19:42:22 +01005204 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005205
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005206 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005207 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5208 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005209 return err;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005210 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005211 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5212 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005213 return err;
5214 return 0;
5215}
5216
Takashi Iwai05f5f472009-08-25 13:10:18 +02005217static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005218{
Takashi Iwai05f5f472009-08-25 13:10:18 +02005219 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
5220 return (pincap & AC_PINCAP_IN) != 0;
5221}
5222
5223/* create playback/capture controls for input pins */
5224static int alc_auto_create_input_ctls(struct hda_codec *codec,
5225 const struct auto_pin_cfg *cfg,
5226 hda_nid_t mixer,
5227 hda_nid_t cap1, hda_nid_t cap2)
5228{
5229 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005230 struct hda_input_mux *imux = &spec->private_imux[0];
David Henningsson5322bf22011-01-05 11:03:56 +01005231 int i, err, idx, type_idx = 0;
5232 const char *prev_label = NULL;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005233
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005234 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02005235 hda_nid_t pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005236 const char *label;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005237
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005238 pin = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005239 if (!alc_is_input_pin(codec, pin))
5240 continue;
5241
David Henningsson5322bf22011-01-05 11:03:56 +01005242 label = hda_get_autocfg_input_label(codec, cfg, i);
5243 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005244 type_idx++;
5245 else
5246 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +01005247 prev_label = label;
5248
Takashi Iwai05f5f472009-08-25 13:10:18 +02005249 if (mixer) {
5250 idx = get_connection_index(codec, mixer, pin);
5251 if (idx >= 0) {
5252 err = new_analog_input(spec, pin,
Takashi Iwai10a20af2010-09-09 16:28:02 +02005253 label, type_idx,
5254 idx, mixer);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005255 if (err < 0)
5256 return err;
5257 }
5258 }
5259
5260 if (!cap1)
5261 continue;
5262 idx = get_connection_index(codec, cap1, pin);
5263 if (idx < 0 && cap2)
5264 idx = get_connection_index(codec, cap2, pin);
Takashi Iwai10a20af2010-09-09 16:28:02 +02005265 if (idx >= 0)
5266 snd_hda_add_imux_item(imux, label, idx, NULL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005267 }
5268 return 0;
5269}
5270
Takashi Iwai05f5f472009-08-25 13:10:18 +02005271static int alc880_auto_create_input_ctls(struct hda_codec *codec,
5272 const struct auto_pin_cfg *cfg)
5273{
5274 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
5275}
5276
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005277static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
5278 unsigned int pin_type)
5279{
5280 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5281 pin_type);
5282 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01005283 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5284 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005285}
5286
Kailang Yangdf694da2005-12-05 19:42:22 +01005287static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
5288 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005289 int dac_idx)
5290{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005291 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005292 /* need the manual connection? */
5293 if (alc880_is_multi_pin(nid)) {
5294 struct alc_spec *spec = codec->spec;
5295 int idx = alc880_multi_pin_idx(nid);
5296 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
5297 AC_VERB_SET_CONNECT_SEL,
5298 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
5299 }
5300}
5301
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005302static int get_pin_type(int line_out_type)
5303{
5304 if (line_out_type == AUTO_PIN_HP_OUT)
5305 return PIN_HP;
5306 else
5307 return PIN_OUT;
5308}
5309
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005310static void alc880_auto_init_multi_out(struct hda_codec *codec)
5311{
5312 struct alc_spec *spec = codec->spec;
5313 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005314
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005315 for (i = 0; i < spec->autocfg.line_outs; i++) {
5316 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005317 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5318 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005319 }
5320}
5321
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005322static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005323{
5324 struct alc_spec *spec = codec->spec;
5325 hda_nid_t pin;
5326
Takashi Iwai82bc9552006-03-21 11:24:42 +01005327 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005328 if (pin) /* connect to front */
5329 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005330 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005331 if (pin) /* connect to front */
5332 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5333}
5334
5335static void alc880_auto_init_analog_input(struct hda_codec *codec)
5336{
5337 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005338 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005339 int i;
5340
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005341 for (i = 0; i < cfg->num_inputs; i++) {
5342 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005343 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02005344 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005345 if (nid != ALC880_PIN_CD_NID &&
5346 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005347 snd_hda_codec_write(codec, nid, 0,
5348 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005349 AMP_OUT_MUTE);
5350 }
5351 }
5352}
5353
Takashi Iwai7f311a42010-04-09 17:32:23 +02005354static void alc880_auto_init_input_src(struct hda_codec *codec)
5355{
5356 struct alc_spec *spec = codec->spec;
5357 int c;
5358
5359 for (c = 0; c < spec->num_adc_nids; c++) {
5360 unsigned int mux_idx;
5361 const struct hda_input_mux *imux;
5362 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5363 imux = &spec->input_mux[mux_idx];
5364 if (!imux->num_items && mux_idx > 0)
5365 imux = &spec->input_mux[0];
5366 if (imux)
5367 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5368 AC_VERB_SET_CONNECT_SEL,
5369 imux->items[0].index);
5370 }
5371}
5372
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005373/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005374/* return 1 if successful, 0 if the proper config is not found,
5375 * or a negative error code
5376 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005377static int alc880_parse_auto_config(struct hda_codec *codec)
5378{
5379 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005380 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005381 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005382
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005383 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5384 alc880_ignore);
5385 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005386 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005387 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005388 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005389
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005390 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5391 if (err < 0)
5392 return err;
5393 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5394 if (err < 0)
5395 return err;
5396 err = alc880_auto_create_extra_out(spec,
5397 spec->autocfg.speaker_pins[0],
5398 "Speaker");
5399 if (err < 0)
5400 return err;
5401 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5402 "Headphone");
5403 if (err < 0)
5404 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005405 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005406 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005407 return err;
5408
5409 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5410
Takashi Iwai757899a2010-07-30 10:48:14 +02005411 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005412
Takashi Iwai603c4012008-07-30 15:01:44 +02005413 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005414 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005415
Takashi Iwaid88897e2008-10-31 15:01:37 +01005416 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005417
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005418 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005419 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005420
Kailang Yang6227cdc2010-02-25 08:36:52 +01005421 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005422
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005423 return 1;
5424}
5425
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005426/* additional initialization for auto-configuration model */
5427static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005428{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005429 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005430 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005431 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005432 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005433 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005434 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005435 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005436 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005437}
5438
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005439/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5440 * one of two digital mic pins, e.g. on ALC272
5441 */
5442static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005443{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005444 struct alc_spec *spec = codec->spec;
5445 int i;
5446
5447 for (i = 0; i < spec->num_adc_nids; i++) {
5448 hda_nid_t cap = spec->capsrc_nids ?
5449 spec->capsrc_nids[i] : spec->adc_nids[i];
5450 int iidx, eidx;
5451
5452 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5453 if (iidx < 0)
5454 continue;
5455 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5456 if (eidx < 0)
5457 continue;
5458 spec->int_mic.mux_idx = iidx;
5459 spec->ext_mic.mux_idx = eidx;
5460 if (spec->capsrc_nids)
5461 spec->capsrc_nids += i;
5462 spec->adc_nids += i;
5463 spec->num_adc_nids = 1;
5464 return;
5465 }
5466 snd_printd(KERN_INFO "hda_codec: %s: "
5467 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5468 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5469 spec->auto_mic = 0; /* disable auto-mic to be sure */
5470}
5471
Takashi Iwai748cce42010-08-04 07:37:39 +02005472/* select or unmute the given capsrc route */
5473static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5474 int idx)
5475{
5476 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5477 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5478 HDA_AMP_MUTE, 0);
5479 } else {
5480 snd_hda_codec_write_cache(codec, cap, 0,
5481 AC_VERB_SET_CONNECT_SEL, idx);
5482 }
5483}
5484
Takashi Iwai840b64c2010-07-13 22:49:01 +02005485/* set the default connection to that pin */
5486static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5487{
5488 struct alc_spec *spec = codec->spec;
5489 int i;
5490
5491 for (i = 0; i < spec->num_adc_nids; i++) {
5492 hda_nid_t cap = spec->capsrc_nids ?
5493 spec->capsrc_nids[i] : spec->adc_nids[i];
5494 int idx;
5495
5496 idx = get_connection_index(codec, cap, pin);
5497 if (idx < 0)
5498 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005499 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005500 return i; /* return the found index */
5501 }
5502 return -1; /* not found */
5503}
5504
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005505/* choose the ADC/MUX containing the input pin and initialize the setup */
5506static void fixup_single_adc(struct hda_codec *codec)
5507{
5508 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005509 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005510 int i;
5511
5512 /* search for the input pin; there must be only one */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005513 if (cfg->num_inputs != 1)
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005514 return;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005515 i = init_capsrc_for_pin(codec, cfg->inputs[0].pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005516 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005517 /* use only this ADC */
5518 if (spec->capsrc_nids)
5519 spec->capsrc_nids += i;
5520 spec->adc_nids += i;
5521 spec->num_adc_nids = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005522 }
5523}
5524
Takashi Iwai840b64c2010-07-13 22:49:01 +02005525/* initialize dual adcs */
5526static void fixup_dual_adc_switch(struct hda_codec *codec)
5527{
5528 struct alc_spec *spec = codec->spec;
5529 init_capsrc_for_pin(codec, spec->ext_mic.pin);
5530 init_capsrc_for_pin(codec, spec->int_mic.pin);
5531}
5532
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005533static void set_capture_mixer(struct hda_codec *codec)
5534{
5535 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005536 static struct snd_kcontrol_new *caps[2][3] = {
5537 { alc_capture_mixer_nosrc1,
5538 alc_capture_mixer_nosrc2,
5539 alc_capture_mixer_nosrc3 },
5540 { alc_capture_mixer1,
5541 alc_capture_mixer2,
5542 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005543 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005544 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005545 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005546 int num_adcs = spec->num_adc_nids;
5547 if (spec->dual_adc_switch)
5548 fixup_dual_adc_switch(codec);
5549 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005550 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005551 else if (spec->input_mux) {
5552 if (spec->input_mux->num_items > 1)
5553 mux = 1;
5554 else if (spec->input_mux->num_items == 1)
5555 fixup_single_adc(codec);
5556 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005557 if (spec->dual_adc_switch)
5558 num_adcs = 1;
5559 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005560 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005561}
5562
Takashi Iwai66946352010-03-29 17:21:45 +02005563/* fill adc_nids (and capsrc_nids) containing all active input pins */
5564static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5565 int num_nids)
5566{
5567 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005568 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai66946352010-03-29 17:21:45 +02005569 int n;
5570 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5571
5572 for (n = 0; n < num_nids; n++) {
5573 hda_nid_t adc, cap;
5574 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5575 int nconns, i, j;
5576
5577 adc = nids[n];
5578 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5579 continue;
5580 cap = adc;
5581 nconns = snd_hda_get_connections(codec, cap, conn,
5582 ARRAY_SIZE(conn));
5583 if (nconns == 1) {
5584 cap = conn[0];
5585 nconns = snd_hda_get_connections(codec, cap, conn,
5586 ARRAY_SIZE(conn));
5587 }
5588 if (nconns <= 0)
5589 continue;
5590 if (!fallback_adc) {
5591 fallback_adc = adc;
5592 fallback_cap = cap;
5593 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005594 for (i = 0; i < cfg->num_inputs; i++) {
5595 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai66946352010-03-29 17:21:45 +02005596 for (j = 0; j < nconns; j++) {
5597 if (conn[j] == nid)
5598 break;
5599 }
5600 if (j >= nconns)
5601 break;
5602 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005603 if (i >= cfg->num_inputs) {
Takashi Iwai66946352010-03-29 17:21:45 +02005604 int num_adcs = spec->num_adc_nids;
5605 spec->private_adc_nids[num_adcs] = adc;
5606 spec->private_capsrc_nids[num_adcs] = cap;
5607 spec->num_adc_nids++;
5608 spec->adc_nids = spec->private_adc_nids;
5609 if (adc != cap)
5610 spec->capsrc_nids = spec->private_capsrc_nids;
5611 }
5612 }
5613 if (!spec->num_adc_nids) {
5614 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005615 " using fallback 0x%x\n",
5616 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005617 spec->private_adc_nids[0] = fallback_adc;
5618 spec->adc_nids = spec->private_adc_nids;
5619 if (fallback_adc != fallback_cap) {
5620 spec->private_capsrc_nids[0] = fallback_cap;
5621 spec->capsrc_nids = spec->private_adc_nids;
5622 }
5623 }
5624}
5625
Takashi Iwai67d634c2009-11-16 15:35:59 +01005626#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005627#define set_beep_amp(spec, nid, idx, dir) \
5628 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005629
5630static struct snd_pci_quirk beep_white_list[] = {
5631 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005632 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005633 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005634 {}
5635};
5636
5637static inline int has_cdefine_beep(struct hda_codec *codec)
5638{
5639 struct alc_spec *spec = codec->spec;
5640 const struct snd_pci_quirk *q;
5641 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5642 if (q)
5643 return q->value;
5644 return spec->cdefine.enable_pcbeep;
5645}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005646#else
5647#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005648#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005649#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005650
5651/*
5652 * OK, here we have finally the patch for ALC880
5653 */
5654
Linus Torvalds1da177e2005-04-16 15:20:36 -07005655static int patch_alc880(struct hda_codec *codec)
5656{
5657 struct alc_spec *spec;
5658 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005659 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005660
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005661 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005662 if (spec == NULL)
5663 return -ENOMEM;
5664
5665 codec->spec = spec;
5666
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005667 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5668 alc880_models,
5669 alc880_cfg_tbl);
5670 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005671 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5672 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005673 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005674 }
5675
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005676 if (board_config == ALC880_AUTO) {
5677 /* automatic parse from the BIOS config */
5678 err = alc880_parse_auto_config(codec);
5679 if (err < 0) {
5680 alc_free(codec);
5681 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005682 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005683 printk(KERN_INFO
5684 "hda_codec: Cannot set up configuration "
5685 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005686 board_config = ALC880_3ST;
5687 }
5688 }
5689
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005690 err = snd_hda_attach_beep_device(codec, 0x1);
5691 if (err < 0) {
5692 alc_free(codec);
5693 return err;
5694 }
5695
Kailang Yangdf694da2005-12-05 19:42:22 +01005696 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005697 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005698
Linus Torvalds1da177e2005-04-16 15:20:36 -07005699 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5700 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005701 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005702
Linus Torvalds1da177e2005-04-16 15:20:36 -07005703 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5704 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5705
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005706 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005707 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005708 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005709 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005710 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005711 if (wcap != AC_WID_AUD_IN) {
5712 spec->adc_nids = alc880_adc_nids_alt;
5713 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005714 } else {
5715 spec->adc_nids = alc880_adc_nids;
5716 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005717 }
5718 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005719 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005720 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005721
Takashi Iwai2134ea42008-01-10 16:53:55 +01005722 spec->vmaster_nid = 0x0c;
5723
Linus Torvalds1da177e2005-04-16 15:20:36 -07005724 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005725 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005726 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005727#ifdef CONFIG_SND_HDA_POWER_SAVE
5728 if (!spec->loopback.amplist)
5729 spec->loopback.amplist = alc880_loopbacks;
5730#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005731
5732 return 0;
5733}
5734
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005735
Linus Torvalds1da177e2005-04-16 15:20:36 -07005736/*
5737 * ALC260 support
5738 */
5739
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005740static hda_nid_t alc260_dac_nids[1] = {
5741 /* front */
5742 0x02,
5743};
5744
5745static hda_nid_t alc260_adc_nids[1] = {
5746 /* ADC0 */
5747 0x04,
5748};
5749
Kailang Yangdf694da2005-12-05 19:42:22 +01005750static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005751 /* ADC1 */
5752 0x05,
5753};
5754
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005755/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5756 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5757 */
5758static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005759 /* ADC0, ADC1 */
5760 0x04, 0x05
5761};
5762
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005763#define ALC260_DIGOUT_NID 0x03
5764#define ALC260_DIGIN_NID 0x06
5765
5766static struct hda_input_mux alc260_capture_source = {
5767 .num_items = 4,
5768 .items = {
5769 { "Mic", 0x0 },
5770 { "Front Mic", 0x1 },
5771 { "Line", 0x2 },
5772 { "CD", 0x4 },
5773 },
5774};
5775
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005776/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005777 * headphone jack and the internal CD lines since these are the only pins at
5778 * which audio can appear. For flexibility, also allow the option of
5779 * recording the mixer output on the second ADC (ADC0 doesn't have a
5780 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005781 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005782static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5783 {
5784 .num_items = 3,
5785 .items = {
5786 { "Mic/Line", 0x0 },
5787 { "CD", 0x4 },
5788 { "Headphone", 0x2 },
5789 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005790 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005791 {
5792 .num_items = 4,
5793 .items = {
5794 { "Mic/Line", 0x0 },
5795 { "CD", 0x4 },
5796 { "Headphone", 0x2 },
5797 { "Mixer", 0x5 },
5798 },
5799 },
5800
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005801};
5802
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005803/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5804 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005805 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005806static struct hda_input_mux alc260_acer_capture_sources[2] = {
5807 {
5808 .num_items = 4,
5809 .items = {
5810 { "Mic", 0x0 },
5811 { "Line", 0x2 },
5812 { "CD", 0x4 },
5813 { "Headphone", 0x5 },
5814 },
5815 },
5816 {
5817 .num_items = 5,
5818 .items = {
5819 { "Mic", 0x0 },
5820 { "Line", 0x2 },
5821 { "CD", 0x4 },
5822 { "Headphone", 0x6 },
5823 { "Mixer", 0x5 },
5824 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005825 },
5826};
Michael Schwingencc959482009-02-22 18:58:45 +01005827
5828/* Maxdata Favorit 100XS */
5829static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5830 {
5831 .num_items = 2,
5832 .items = {
5833 { "Line/Mic", 0x0 },
5834 { "CD", 0x4 },
5835 },
5836 },
5837 {
5838 .num_items = 3,
5839 .items = {
5840 { "Line/Mic", 0x0 },
5841 { "CD", 0x4 },
5842 { "Mixer", 0x5 },
5843 },
5844 },
5845};
5846
Linus Torvalds1da177e2005-04-16 15:20:36 -07005847/*
5848 * This is just place-holder, so there's something for alc_build_pcms to look
5849 * at when it calculates the maximum number of channels. ALC260 has no mixer
5850 * element which allows changing the channel mode, so the verb list is
5851 * never used.
5852 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005853static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005854 { 2, NULL },
5855};
5856
Kailang Yangdf694da2005-12-05 19:42:22 +01005857
5858/* Mixer combinations
5859 *
5860 * basic: base_output + input + pc_beep + capture
5861 * HP: base_output + input + capture_alt
5862 * HP_3013: hp_3013 + input + capture
5863 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005864 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005865 */
5866
5867static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005868 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005869 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005870 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5871 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5872 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5873 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5874 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005875};
Kailang Yangdf694da2005-12-05 19:42:22 +01005876
5877static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005878 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5879 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5880 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5881 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5882 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5883 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5884 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5885 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005886 { } /* end */
5887};
5888
Takashi Iwaibec15c32008-01-28 18:16:30 +01005889/* update HP, line and mono out pins according to the master switch */
5890static void alc260_hp_master_update(struct hda_codec *codec,
5891 hda_nid_t hp, hda_nid_t line,
5892 hda_nid_t mono)
5893{
5894 struct alc_spec *spec = codec->spec;
5895 unsigned int val = spec->master_sw ? PIN_HP : 0;
5896 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005897 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005898 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005899 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005900 val);
5901 /* mono (speaker) depending on the HP jack sense */
5902 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005903 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005904 val);
5905}
5906
5907static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5908 struct snd_ctl_elem_value *ucontrol)
5909{
5910 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5911 struct alc_spec *spec = codec->spec;
5912 *ucontrol->value.integer.value = spec->master_sw;
5913 return 0;
5914}
5915
5916static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5917 struct snd_ctl_elem_value *ucontrol)
5918{
5919 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5920 struct alc_spec *spec = codec->spec;
5921 int val = !!*ucontrol->value.integer.value;
5922 hda_nid_t hp, line, mono;
5923
5924 if (val == spec->master_sw)
5925 return 0;
5926 spec->master_sw = val;
5927 hp = (kcontrol->private_value >> 16) & 0xff;
5928 line = (kcontrol->private_value >> 8) & 0xff;
5929 mono = kcontrol->private_value & 0xff;
5930 alc260_hp_master_update(codec, hp, line, mono);
5931 return 1;
5932}
5933
5934static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5935 {
5936 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5937 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005938 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005939 .info = snd_ctl_boolean_mono_info,
5940 .get = alc260_hp_master_sw_get,
5941 .put = alc260_hp_master_sw_put,
5942 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5943 },
5944 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5945 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5946 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5947 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5948 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5949 HDA_OUTPUT),
5950 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5951 { } /* end */
5952};
5953
5954static struct hda_verb alc260_hp_unsol_verbs[] = {
5955 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5956 {},
5957};
5958
5959static void alc260_hp_automute(struct hda_codec *codec)
5960{
5961 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005962
Wu Fengguang864f92b2009-11-18 12:38:02 +08005963 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005964 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5965}
5966
5967static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5968{
5969 if ((res >> 26) == ALC880_HP_EVENT)
5970 alc260_hp_automute(codec);
5971}
5972
Kailang Yangdf694da2005-12-05 19:42:22 +01005973static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005974 {
5975 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5976 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005977 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005978 .info = snd_ctl_boolean_mono_info,
5979 .get = alc260_hp_master_sw_get,
5980 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005981 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005982 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005983 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5984 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5985 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5986 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5987 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5988 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005989 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5990 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005991 { } /* end */
5992};
5993
Kailang Yang3f878302008-08-26 13:02:23 +02005994static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5995 .ops = &snd_hda_bind_vol,
5996 .values = {
5997 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5998 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5999 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
6000 0
6001 },
6002};
6003
6004static struct hda_bind_ctls alc260_dc7600_bind_switch = {
6005 .ops = &snd_hda_bind_sw,
6006 .values = {
6007 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
6008 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
6009 0
6010 },
6011};
6012
6013static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
6014 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
6015 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
6016 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
6017 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
6018 { } /* end */
6019};
6020
Takashi Iwaibec15c32008-01-28 18:16:30 +01006021static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
6022 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6023 {},
6024};
6025
6026static void alc260_hp_3013_automute(struct hda_codec *codec)
6027{
6028 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006029
Wu Fengguang864f92b2009-11-18 12:38:02 +08006030 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01006031 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01006032}
6033
6034static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
6035 unsigned int res)
6036{
6037 if ((res >> 26) == ALC880_HP_EVENT)
6038 alc260_hp_3013_automute(codec);
6039}
6040
Kailang Yang3f878302008-08-26 13:02:23 +02006041static void alc260_hp_3012_automute(struct hda_codec *codec)
6042{
Wu Fengguang864f92b2009-11-18 12:38:02 +08006043 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02006044
Kailang Yang3f878302008-08-26 13:02:23 +02006045 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6046 bits);
6047 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6048 bits);
6049 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6050 bits);
6051}
6052
6053static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
6054 unsigned int res)
6055{
6056 if ((res >> 26) == ALC880_HP_EVENT)
6057 alc260_hp_3012_automute(codec);
6058}
6059
6060/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006061 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
6062 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006063static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006064 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006065 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006066 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006067 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6068 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6069 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
6070 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006071 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006072 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6073 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006074 { } /* end */
6075};
6076
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006077/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
6078 * versions of the ALC260 don't act on requests to enable mic bias from NID
6079 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
6080 * datasheet doesn't mention this restriction. At this stage it's not clear
6081 * whether this behaviour is intentional or is a hardware bug in chip
6082 * revisions available in early 2006. Therefore for now allow the
6083 * "Headphone Jack Mode" control to span all choices, but if it turns out
6084 * that the lack of mic bias for this NID is intentional we could change the
6085 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6086 *
6087 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
6088 * don't appear to make the mic bias available from the "line" jack, even
6089 * though the NID used for this jack (0x14) can supply it. The theory is
6090 * that perhaps Acer have included blocking capacitors between the ALC260
6091 * and the output jack. If this turns out to be the case for all such
6092 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
6093 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01006094 *
6095 * The C20x Tablet series have a mono internal speaker which is controlled
6096 * via the chip's Mono sum widget and pin complex, so include the necessary
6097 * controls for such models. On models without a "mono speaker" the control
6098 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006099 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006100static struct snd_kcontrol_new alc260_acer_mixer[] = {
6101 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6102 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006103 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006104 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01006105 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006106 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01006107 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006108 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6109 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6110 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6111 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6112 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6113 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6114 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6115 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006116 { } /* end */
6117};
6118
Michael Schwingencc959482009-02-22 18:58:45 +01006119/* Maxdata Favorit 100XS: one output and one input (0x12) jack
6120 */
6121static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
6122 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6123 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
6124 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
6125 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6126 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6127 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6128 { } /* end */
6129};
6130
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006131/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
6132 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
6133 */
6134static struct snd_kcontrol_new alc260_will_mixer[] = {
6135 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6136 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6137 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6138 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6139 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6140 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6141 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6142 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6143 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6144 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006145 { } /* end */
6146};
6147
6148/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
6149 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
6150 */
6151static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
6152 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6153 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6154 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6155 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6156 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6157 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
6158 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
6159 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6160 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6161 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6162 { } /* end */
6163};
6164
Kailang Yangdf694da2005-12-05 19:42:22 +01006165/*
6166 * initialization verbs
6167 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006168static struct hda_verb alc260_init_verbs[] = {
6169 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006170 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006171 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006172 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006173 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006174 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006175 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006176 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006177 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02006178 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006179 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01006180 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006181 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02006182 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006183 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02006184 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006185 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02006186 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6187 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02006188 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006189 /* set connection select to line in (default select for this ADC) */
6190 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02006191 /* mute capture amp left and right */
6192 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6193 /* set connection select to line in (default select for this ADC) */
6194 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02006195 /* set vol=0 Line-Out mixer amp left and right */
6196 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6197 /* unmute pin widget amp left and right (no gain on this amp) */
6198 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6199 /* set vol=0 HP mixer amp left and right */
6200 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6201 /* unmute pin widget amp left and right (no gain on this amp) */
6202 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6203 /* set vol=0 Mono mixer amp left and right */
6204 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6205 /* unmute pin widget amp left and right (no gain on this amp) */
6206 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6207 /* unmute LINE-2 out pin */
6208 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006209 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6210 * Line In 2 = 0x03
6211 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006212 /* mute analog inputs */
6213 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6214 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6215 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6216 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6217 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006218 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006219 /* mute Front out path */
6220 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6221 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6222 /* mute Headphone out path */
6223 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6224 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6225 /* mute Mono out path */
6226 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6227 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006228 { }
6229};
6230
Takashi Iwai474167d2006-05-17 17:17:43 +02006231#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01006232static struct hda_verb alc260_hp_init_verbs[] = {
6233 /* Headphone and output */
6234 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6235 /* mono output */
6236 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6237 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6238 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6239 /* Mic2 (front panel) pin widget for input and vref at 80% */
6240 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6241 /* Line In pin widget for input */
6242 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6243 /* Line-2 pin widget for output */
6244 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6245 /* CD pin widget for input */
6246 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6247 /* unmute amp left and right */
6248 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6249 /* set connection select to line in (default select for this ADC) */
6250 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6251 /* unmute Line-Out mixer amp left and right (volume = 0) */
6252 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6253 /* mute pin widget amp left and right (no gain on this amp) */
6254 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6255 /* unmute HP mixer amp left and right (volume = 0) */
6256 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6257 /* mute pin widget amp left and right (no gain on this amp) */
6258 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006259 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6260 * Line In 2 = 0x03
6261 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006262 /* mute analog inputs */
6263 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6264 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6265 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6266 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6267 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006268 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6269 /* Unmute Front out path */
6270 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6271 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6272 /* Unmute Headphone out path */
6273 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6274 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6275 /* Unmute Mono out path */
6276 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6277 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6278 { }
6279};
Takashi Iwai474167d2006-05-17 17:17:43 +02006280#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006281
6282static struct hda_verb alc260_hp_3013_init_verbs[] = {
6283 /* Line out and output */
6284 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6285 /* mono output */
6286 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6287 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6288 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6289 /* Mic2 (front panel) pin widget for input and vref at 80% */
6290 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6291 /* Line In pin widget for input */
6292 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6293 /* Headphone pin widget for output */
6294 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6295 /* CD pin widget for input */
6296 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6297 /* unmute amp left and right */
6298 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6299 /* set connection select to line in (default select for this ADC) */
6300 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6301 /* unmute Line-Out mixer amp left and right (volume = 0) */
6302 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6303 /* mute pin widget amp left and right (no gain on this amp) */
6304 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6305 /* unmute HP mixer amp left and right (volume = 0) */
6306 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6307 /* mute pin widget amp left and right (no gain on this amp) */
6308 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006309 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6310 * Line In 2 = 0x03
6311 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006312 /* mute analog inputs */
6313 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6314 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6315 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6316 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6317 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006318 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6319 /* Unmute Front out path */
6320 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6321 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6322 /* Unmute Headphone out path */
6323 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6324 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6325 /* Unmute Mono out path */
6326 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6327 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6328 { }
6329};
6330
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006331/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006332 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6333 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006334 */
6335static struct hda_verb alc260_fujitsu_init_verbs[] = {
6336 /* Disable all GPIOs */
6337 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6338 /* Internal speaker is connected to headphone pin */
6339 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6340 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6341 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006342 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6343 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6344 /* Ensure all other unused pins are disabled and muted. */
6345 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6346 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006347 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006348 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006349 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006350 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6351 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6352 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006353
Jonathan Woithef7ace402006-02-28 11:46:14 +01006354 /* Disable digital (SPDIF) pins */
6355 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6356 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006357
Kailang Yangea1fb292008-08-26 12:58:38 +02006358 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006359 * when acting as an output.
6360 */
6361 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6362
6363 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006364 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6365 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6366 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6367 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6368 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6369 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6370 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6371 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6372 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006373
Jonathan Woithef7ace402006-02-28 11:46:14 +01006374 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6375 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6376 /* Unmute Line1 pin widget output buffer since it starts as an output.
6377 * If the pin mode is changed by the user the pin mode control will
6378 * take care of enabling the pin's input/output buffers as needed.
6379 * Therefore there's no need to enable the input buffer at this
6380 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006381 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006382 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006383 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006384 * mixer ctrl)
6385 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006386 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006387
Jonathan Woithef7ace402006-02-28 11:46:14 +01006388 /* Mute capture amp left and right */
6389 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006390 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006391 * in (on mic1 pin)
6392 */
6393 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006394
Jonathan Woithef7ace402006-02-28 11:46:14 +01006395 /* Do the same for the second ADC: mute capture input amp and
6396 * set ADC connection to line in (on mic1 pin)
6397 */
6398 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6399 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006400
Jonathan Woithef7ace402006-02-28 11:46:14 +01006401 /* Mute all inputs to mixer widget (even unconnected ones) */
6402 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6403 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6404 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6405 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6406 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6407 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6408 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6409 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006410
6411 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006412};
6413
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006414/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6415 * similar laptops (adapted from Fujitsu init verbs).
6416 */
6417static struct hda_verb alc260_acer_init_verbs[] = {
6418 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6419 * the headphone jack. Turn this on and rely on the standard mute
6420 * methods whenever the user wants to turn these outputs off.
6421 */
6422 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6423 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6424 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6425 /* Internal speaker/Headphone jack is connected to Line-out pin */
6426 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6427 /* Internal microphone/Mic jack is connected to Mic1 pin */
6428 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6429 /* Line In jack is connected to Line1 pin */
6430 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006431 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6432 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006433 /* Ensure all other unused pins are disabled and muted. */
6434 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6435 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006436 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6437 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6438 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6439 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6440 /* Disable digital (SPDIF) pins */
6441 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6442 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6443
Kailang Yangea1fb292008-08-26 12:58:38 +02006444 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006445 * bus when acting as outputs.
6446 */
6447 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6448 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6449
6450 /* Start with output sum widgets muted and their output gains at min */
6451 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6452 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6453 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6454 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6455 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6456 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6457 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6458 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6459 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6460
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006461 /* Unmute Line-out pin widget amp left and right
6462 * (no equiv mixer ctrl)
6463 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006464 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006465 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6466 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006467 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6468 * inputs. If the pin mode is changed by the user the pin mode control
6469 * will take care of enabling the pin's input/output buffers as needed.
6470 * Therefore there's no need to enable the input buffer at this
6471 * stage.
6472 */
6473 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6474 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6475
6476 /* Mute capture amp left and right */
6477 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6478 /* Set ADC connection select to match default mixer setting - mic
6479 * (on mic1 pin)
6480 */
6481 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6482
6483 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006484 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006485 */
6486 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006487 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006488
6489 /* Mute all inputs to mixer widget (even unconnected ones) */
6490 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6491 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6492 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6493 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6494 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6495 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6496 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6497 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6498
6499 { }
6500};
6501
Michael Schwingencc959482009-02-22 18:58:45 +01006502/* Initialisation sequence for Maxdata Favorit 100XS
6503 * (adapted from Acer init verbs).
6504 */
6505static struct hda_verb alc260_favorit100_init_verbs[] = {
6506 /* GPIO 0 enables the output jack.
6507 * Turn this on and rely on the standard mute
6508 * methods whenever the user wants to turn these outputs off.
6509 */
6510 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6511 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6512 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6513 /* Line/Mic input jack is connected to Mic1 pin */
6514 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6515 /* Ensure all other unused pins are disabled and muted. */
6516 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6517 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6518 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6519 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6520 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6521 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6522 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6523 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6524 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6525 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6526 /* Disable digital (SPDIF) pins */
6527 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6528 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6529
6530 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6531 * bus when acting as outputs.
6532 */
6533 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6534 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6535
6536 /* Start with output sum widgets muted and their output gains at min */
6537 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6538 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6539 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6540 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6541 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6542 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6543 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6544 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6545 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6546
6547 /* Unmute Line-out pin widget amp left and right
6548 * (no equiv mixer ctrl)
6549 */
6550 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6551 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6552 * inputs. If the pin mode is changed by the user the pin mode control
6553 * will take care of enabling the pin's input/output buffers as needed.
6554 * Therefore there's no need to enable the input buffer at this
6555 * stage.
6556 */
6557 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6558
6559 /* Mute capture amp left and right */
6560 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6561 /* Set ADC connection select to match default mixer setting - mic
6562 * (on mic1 pin)
6563 */
6564 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6565
6566 /* Do similar with the second ADC: mute capture input amp and
6567 * set ADC connection to mic to match ALSA's default state.
6568 */
6569 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6570 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6571
6572 /* Mute all inputs to mixer widget (even unconnected ones) */
6573 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6574 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6575 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6576 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6577 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6578 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6579 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6580 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6581
6582 { }
6583};
6584
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006585static struct hda_verb alc260_will_verbs[] = {
6586 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6587 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6588 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6589 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6590 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6591 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6592 {}
6593};
6594
6595static struct hda_verb alc260_replacer_672v_verbs[] = {
6596 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6597 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6598 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6599
6600 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6601 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6602 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6603
6604 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6605 {}
6606};
6607
6608/* toggle speaker-output according to the hp-jack state */
6609static void alc260_replacer_672v_automute(struct hda_codec *codec)
6610{
6611 unsigned int present;
6612
6613 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006614 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006615 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006616 snd_hda_codec_write_cache(codec, 0x01, 0,
6617 AC_VERB_SET_GPIO_DATA, 1);
6618 snd_hda_codec_write_cache(codec, 0x0f, 0,
6619 AC_VERB_SET_PIN_WIDGET_CONTROL,
6620 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006621 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006622 snd_hda_codec_write_cache(codec, 0x01, 0,
6623 AC_VERB_SET_GPIO_DATA, 0);
6624 snd_hda_codec_write_cache(codec, 0x0f, 0,
6625 AC_VERB_SET_PIN_WIDGET_CONTROL,
6626 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006627 }
6628}
6629
6630static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6631 unsigned int res)
6632{
6633 if ((res >> 26) == ALC880_HP_EVENT)
6634 alc260_replacer_672v_automute(codec);
6635}
6636
Kailang Yang3f878302008-08-26 13:02:23 +02006637static struct hda_verb alc260_hp_dc7600_verbs[] = {
6638 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6639 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6640 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6641 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6642 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6643 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6644 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6645 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6646 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6647 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6648 {}
6649};
6650
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006651/* Test configuration for debugging, modelled after the ALC880 test
6652 * configuration.
6653 */
6654#ifdef CONFIG_SND_DEBUG
6655static hda_nid_t alc260_test_dac_nids[1] = {
6656 0x02,
6657};
6658static hda_nid_t alc260_test_adc_nids[2] = {
6659 0x04, 0x05,
6660};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006661/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006662 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006663 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006664 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006665static struct hda_input_mux alc260_test_capture_sources[2] = {
6666 {
6667 .num_items = 7,
6668 .items = {
6669 { "MIC1 pin", 0x0 },
6670 { "MIC2 pin", 0x1 },
6671 { "LINE1 pin", 0x2 },
6672 { "LINE2 pin", 0x3 },
6673 { "CD pin", 0x4 },
6674 { "LINE-OUT pin", 0x5 },
6675 { "HP-OUT pin", 0x6 },
6676 },
6677 },
6678 {
6679 .num_items = 8,
6680 .items = {
6681 { "MIC1 pin", 0x0 },
6682 { "MIC2 pin", 0x1 },
6683 { "LINE1 pin", 0x2 },
6684 { "LINE2 pin", 0x3 },
6685 { "CD pin", 0x4 },
6686 { "Mixer", 0x5 },
6687 { "LINE-OUT pin", 0x6 },
6688 { "HP-OUT pin", 0x7 },
6689 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006690 },
6691};
6692static struct snd_kcontrol_new alc260_test_mixer[] = {
6693 /* Output driver widgets */
6694 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6695 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6696 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6697 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6698 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6699 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6700
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006701 /* Modes for retasking pin widgets
6702 * Note: the ALC260 doesn't seem to act on requests to enable mic
6703 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6704 * mention this restriction. At this stage it's not clear whether
6705 * this behaviour is intentional or is a hardware bug in chip
6706 * revisions available at least up until early 2006. Therefore for
6707 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6708 * choices, but if it turns out that the lack of mic bias for these
6709 * NIDs is intentional we could change their modes from
6710 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6711 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006712 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6713 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6714 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6715 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6716 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6717 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6718
6719 /* Loopback mixer controls */
6720 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6721 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6722 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6723 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6724 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6725 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6726 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6727 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6728 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6729 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006730 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6731 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6732 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6733 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006734
6735 /* Controls for GPIO pins, assuming they are configured as outputs */
6736 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6737 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6738 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6739 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6740
Jonathan Woithe92621f12006-02-28 11:47:47 +01006741 /* Switches to allow the digital IO pins to be enabled. The datasheet
6742 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006743 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006744 */
6745 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6746 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6747
Jonathan Woithef8225f62008-01-08 12:16:54 +01006748 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6749 * this output to turn on an external amplifier.
6750 */
6751 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6752 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6753
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006754 { } /* end */
6755};
6756static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006757 /* Enable all GPIOs as outputs with an initial value of 0 */
6758 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6759 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6760 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6761
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006762 /* Enable retasking pins as output, initially without power amp */
6763 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6764 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6765 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6766 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6767 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6768 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6769
Jonathan Woithe92621f12006-02-28 11:47:47 +01006770 /* Disable digital (SPDIF) pins initially, but users can enable
6771 * them via a mixer switch. In the case of SPDIF-out, this initverb
6772 * payload also sets the generation to 0, output to be in "consumer"
6773 * PCM format, copyright asserted, no pre-emphasis and no validity
6774 * control.
6775 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006776 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6777 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6778
Kailang Yangea1fb292008-08-26 12:58:38 +02006779 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006780 * OUT1 sum bus when acting as an output.
6781 */
6782 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6783 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6784 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6785 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6786
6787 /* Start with output sum widgets muted and their output gains at min */
6788 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6789 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6790 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6791 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6792 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6793 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6794 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6795 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6796 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6797
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006798 /* Unmute retasking pin widget output buffers since the default
6799 * state appears to be output. As the pin mode is changed by the
6800 * user the pin mode control will take care of enabling the pin's
6801 * input/output buffers as needed.
6802 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006803 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6804 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6805 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6806 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6807 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6808 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6809 /* Also unmute the mono-out pin widget */
6810 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6811
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006812 /* Mute capture amp left and right */
6813 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006814 /* Set ADC connection select to match default mixer setting (mic1
6815 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006816 */
6817 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6818
6819 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006820 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006821 */
6822 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6823 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6824
6825 /* Mute all inputs to mixer widget (even unconnected ones) */
6826 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6827 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6828 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6829 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6830 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6831 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6832 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6833 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6834
6835 { }
6836};
6837#endif
6838
Takashi Iwai63300792008-01-24 15:31:36 +01006839#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6840#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006841
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006842#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6843#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6844
Kailang Yangdf694da2005-12-05 19:42:22 +01006845/*
6846 * for BIOS auto-configuration
6847 */
6848
6849static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006850 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006851{
6852 hda_nid_t nid_vol;
6853 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006854 int err;
6855
6856 if (nid >= 0x0f && nid < 0x11) {
6857 nid_vol = nid - 0x7;
6858 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6859 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6860 } else if (nid == 0x11) {
6861 nid_vol = nid - 0x7;
6862 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6863 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6864 } else if (nid >= 0x12 && nid <= 0x15) {
6865 nid_vol = 0x08;
6866 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6867 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6868 } else
6869 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006870
Takashi Iwai863b4512008-10-21 17:01:47 +02006871 if (!(*vol_bits & (1 << nid_vol))) {
6872 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006873 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006874 if (err < 0)
6875 return err;
6876 *vol_bits |= (1 << nid_vol);
6877 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006878 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006879 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006880 return err;
6881 return 1;
6882}
6883
6884/* add playback controls from the parsed DAC table */
6885static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6886 const struct auto_pin_cfg *cfg)
6887{
6888 hda_nid_t nid;
6889 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006890 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006891
6892 spec->multiout.num_dacs = 1;
6893 spec->multiout.dac_nids = spec->private_dac_nids;
6894 spec->multiout.dac_nids[0] = 0x02;
6895
6896 nid = cfg->line_out_pins[0];
6897 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006898 const char *pfx;
6899 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6900 pfx = "Master";
6901 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6902 pfx = "Speaker";
6903 else
6904 pfx = "Front";
6905 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006906 if (err < 0)
6907 return err;
6908 }
6909
Takashi Iwai82bc9552006-03-21 11:24:42 +01006910 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006911 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006912 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006913 if (err < 0)
6914 return err;
6915 }
6916
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006917 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006918 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006919 err = alc260_add_playback_controls(spec, nid, "Headphone",
6920 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006921 if (err < 0)
6922 return err;
6923 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006924 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006925}
6926
6927/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006928static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006929 const struct auto_pin_cfg *cfg)
6930{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006931 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006932}
6933
6934static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6935 hda_nid_t nid, int pin_type,
6936 int sel_idx)
6937{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006938 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006939 /* need the manual connection? */
6940 if (nid >= 0x12) {
6941 int idx = nid - 0x12;
6942 snd_hda_codec_write(codec, idx + 0x0b, 0,
6943 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006944 }
6945}
6946
6947static void alc260_auto_init_multi_out(struct hda_codec *codec)
6948{
6949 struct alc_spec *spec = codec->spec;
6950 hda_nid_t nid;
6951
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006952 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006953 if (nid) {
6954 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6955 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6956 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006957
Takashi Iwai82bc9552006-03-21 11:24:42 +01006958 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006959 if (nid)
6960 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6961
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006962 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006963 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006964 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006965}
Kailang Yangdf694da2005-12-05 19:42:22 +01006966
6967#define ALC260_PIN_CD_NID 0x16
6968static void alc260_auto_init_analog_input(struct hda_codec *codec)
6969{
6970 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006971 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +01006972 int i;
6973
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006974 for (i = 0; i < cfg->num_inputs; i++) {
6975 hda_nid_t nid = cfg->inputs[i].pin;
Kailang Yangdf694da2005-12-05 19:42:22 +01006976 if (nid >= 0x12) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02006977 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006978 if (nid != ALC260_PIN_CD_NID &&
6979 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006980 snd_hda_codec_write(codec, nid, 0,
6981 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006982 AMP_OUT_MUTE);
6983 }
6984 }
6985}
6986
Takashi Iwai7f311a42010-04-09 17:32:23 +02006987#define alc260_auto_init_input_src alc880_auto_init_input_src
6988
Kailang Yangdf694da2005-12-05 19:42:22 +01006989/*
6990 * generic initialization of ADC, input mixers and output mixers
6991 */
6992static struct hda_verb alc260_volume_init_verbs[] = {
6993 /*
6994 * Unmute ADC0-1 and set the default input to mic-in
6995 */
6996 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6997 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6998 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6999 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02007000
Kailang Yangdf694da2005-12-05 19:42:22 +01007001 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7002 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007003 * Note: PASD motherboards uses the Line In 2 as the input for
7004 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007005 */
7006 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007007 /* mute analog inputs */
7008 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7009 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7010 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7011 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7012 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007013
7014 /*
7015 * Set up output mixers (0x08 - 0x0a)
7016 */
7017 /* set vol=0 to output mixers */
7018 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7019 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7020 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7021 /* set up input amps for analog loopback */
7022 /* Amp Indices: DAC = 0, mixer = 1 */
7023 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7024 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7025 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7026 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7027 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7028 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02007029
Kailang Yangdf694da2005-12-05 19:42:22 +01007030 { }
7031};
7032
7033static int alc260_parse_auto_config(struct hda_codec *codec)
7034{
7035 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007036 int err;
7037 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
7038
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007039 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7040 alc260_ignore);
7041 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007042 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007043 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
7044 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01007045 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02007046 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01007047 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02007048 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007049 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007050 return err;
7051
7052 spec->multiout.max_channels = 2;
7053
Takashi Iwai0852d7a2009-02-11 11:35:15 +01007054 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007055 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02007056 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01007057 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01007058
Takashi Iwaid88897e2008-10-31 15:01:37 +01007059 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01007060
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007061 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007062 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007063
Kailang Yang6227cdc2010-02-25 08:36:52 +01007064 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02007065
Kailang Yangdf694da2005-12-05 19:42:22 +01007066 return 1;
7067}
7068
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007069/* additional initialization for auto-configuration model */
7070static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007071{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007072 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007073 alc260_auto_init_multi_out(codec);
7074 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02007075 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02007076 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007077 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007078 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007079}
7080
Takashi Iwaicb53c622007-08-10 17:21:45 +02007081#ifdef CONFIG_SND_HDA_POWER_SAVE
7082static struct hda_amp_list alc260_loopbacks[] = {
7083 { 0x07, HDA_INPUT, 0 },
7084 { 0x07, HDA_INPUT, 1 },
7085 { 0x07, HDA_INPUT, 2 },
7086 { 0x07, HDA_INPUT, 3 },
7087 { 0x07, HDA_INPUT, 4 },
7088 { } /* end */
7089};
7090#endif
7091
Kailang Yangdf694da2005-12-05 19:42:22 +01007092/*
Takashi Iwaifc091762010-08-04 23:53:36 +02007093 * Pin config fixes
7094 */
7095enum {
7096 PINFIX_HP_DC5750,
7097};
7098
Takashi Iwaifc091762010-08-04 23:53:36 +02007099static const struct alc_fixup alc260_fixups[] = {
7100 [PINFIX_HP_DC5750] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007101 .type = ALC_FIXUP_PINS,
7102 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +02007103 { 0x11, 0x90130110 }, /* speaker */
7104 { }
7105 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007106 },
7107};
7108
7109static struct snd_pci_quirk alc260_fixup_tbl[] = {
7110 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
7111 {}
7112};
7113
7114/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007115 * ALC260 configurations
7116 */
Takashi Iwaiea734962011-01-17 11:29:34 +01007117static const char * const alc260_models[ALC260_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007118 [ALC260_BASIC] = "basic",
7119 [ALC260_HP] = "hp",
7120 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02007121 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007122 [ALC260_FUJITSU_S702X] = "fujitsu",
7123 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007124 [ALC260_WILL] = "will",
7125 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01007126 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01007127#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007128 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01007129#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007130 [ALC260_AUTO] = "auto",
7131};
7132
7133static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01007134 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05007135 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007136 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01007137 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01007138 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01007139 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007140 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02007141 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02007142 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007143 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
7144 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
7145 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
7146 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
7147 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
7148 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
7149 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
7150 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
7151 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007152 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007153 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02007154 {}
7155};
7156
Kailang Yangdf694da2005-12-05 19:42:22 +01007157static struct alc_config_preset alc260_presets[] = {
7158 [ALC260_BASIC] = {
7159 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007160 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007161 .init_verbs = { alc260_init_verbs },
7162 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7163 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007164 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01007165 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007166 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7167 .channel_mode = alc260_modes,
7168 .input_mux = &alc260_capture_source,
7169 },
7170 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01007171 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007172 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007173 .init_verbs = { alc260_init_verbs,
7174 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007175 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7176 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007177 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7178 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007179 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7180 .channel_mode = alc260_modes,
7181 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007182 .unsol_event = alc260_hp_unsol_event,
7183 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007184 },
Kailang Yang3f878302008-08-26 13:02:23 +02007185 [ALC260_HP_DC7600] = {
7186 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007187 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02007188 .init_verbs = { alc260_init_verbs,
7189 alc260_hp_dc7600_verbs },
7190 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7191 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007192 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7193 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02007194 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7195 .channel_mode = alc260_modes,
7196 .input_mux = &alc260_capture_source,
7197 .unsol_event = alc260_hp_3012_unsol_event,
7198 .init_hook = alc260_hp_3012_automute,
7199 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007200 [ALC260_HP_3013] = {
7201 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007202 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007203 .init_verbs = { alc260_hp_3013_init_verbs,
7204 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007205 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7206 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007207 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7208 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007209 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7210 .channel_mode = alc260_modes,
7211 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007212 .unsol_event = alc260_hp_3013_unsol_event,
7213 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007214 },
7215 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007216 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007217 .init_verbs = { alc260_fujitsu_init_verbs },
7218 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7219 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01007220 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7221 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007222 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7223 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007224 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
7225 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01007226 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007227 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007228 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007229 .init_verbs = { alc260_acer_init_verbs },
7230 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7231 .dac_nids = alc260_dac_nids,
7232 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7233 .adc_nids = alc260_dual_adc_nids,
7234 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7235 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007236 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
7237 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007238 },
Michael Schwingencc959482009-02-22 18:58:45 +01007239 [ALC260_FAVORIT100] = {
7240 .mixers = { alc260_favorit100_mixer },
7241 .init_verbs = { alc260_favorit100_init_verbs },
7242 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7243 .dac_nids = alc260_dac_nids,
7244 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7245 .adc_nids = alc260_dual_adc_nids,
7246 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7247 .channel_mode = alc260_modes,
7248 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
7249 .input_mux = alc260_favorit100_capture_sources,
7250 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007251 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007252 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007253 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
7254 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7255 .dac_nids = alc260_dac_nids,
7256 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7257 .adc_nids = alc260_adc_nids,
7258 .dig_out_nid = ALC260_DIGOUT_NID,
7259 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7260 .channel_mode = alc260_modes,
7261 .input_mux = &alc260_capture_source,
7262 },
7263 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007264 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007265 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
7266 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7267 .dac_nids = alc260_dac_nids,
7268 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7269 .adc_nids = alc260_adc_nids,
7270 .dig_out_nid = ALC260_DIGOUT_NID,
7271 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7272 .channel_mode = alc260_modes,
7273 .input_mux = &alc260_capture_source,
7274 .unsol_event = alc260_replacer_672v_unsol_event,
7275 .init_hook = alc260_replacer_672v_automute,
7276 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01007277#ifdef CONFIG_SND_DEBUG
7278 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007279 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01007280 .init_verbs = { alc260_test_init_verbs },
7281 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
7282 .dac_nids = alc260_test_dac_nids,
7283 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
7284 .adc_nids = alc260_test_adc_nids,
7285 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7286 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007287 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7288 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01007289 },
7290#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007291};
7292
Linus Torvalds1da177e2005-04-16 15:20:36 -07007293static int patch_alc260(struct hda_codec *codec)
7294{
7295 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007296 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007297
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007298 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007299 if (spec == NULL)
7300 return -ENOMEM;
7301
7302 codec->spec = spec;
7303
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007304 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7305 alc260_models,
7306 alc260_cfg_tbl);
7307 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007308 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007309 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007310 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007311 }
7312
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007313 if (board_config == ALC260_AUTO) {
7314 alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups);
7315 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
7316 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007317
Kailang Yangdf694da2005-12-05 19:42:22 +01007318 if (board_config == ALC260_AUTO) {
7319 /* automatic parse from the BIOS config */
7320 err = alc260_parse_auto_config(codec);
7321 if (err < 0) {
7322 alc_free(codec);
7323 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007324 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007325 printk(KERN_INFO
7326 "hda_codec: Cannot set up configuration "
7327 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007328 board_config = ALC260_BASIC;
7329 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007330 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007331
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007332 err = snd_hda_attach_beep_device(codec, 0x1);
7333 if (err < 0) {
7334 alc_free(codec);
7335 return err;
7336 }
7337
Kailang Yangdf694da2005-12-05 19:42:22 +01007338 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007339 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007340
Linus Torvalds1da177e2005-04-16 15:20:36 -07007341 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7342 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307343 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007344
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007345 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7346 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7347
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007348 if (!spec->adc_nids && spec->input_mux) {
7349 /* check whether NID 0x04 is valid */
7350 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007351 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007352 /* get type */
7353 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7354 spec->adc_nids = alc260_adc_nids_alt;
7355 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7356 } else {
7357 spec->adc_nids = alc260_adc_nids;
7358 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7359 }
7360 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007361 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007362 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007363
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007364 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaifc091762010-08-04 23:53:36 +02007365
Takashi Iwai2134ea42008-01-10 16:53:55 +01007366 spec->vmaster_nid = 0x08;
7367
Linus Torvalds1da177e2005-04-16 15:20:36 -07007368 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007369 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007370 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007371#ifdef CONFIG_SND_HDA_POWER_SAVE
7372 if (!spec->loopback.amplist)
7373 spec->loopback.amplist = alc260_loopbacks;
7374#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007375
7376 return 0;
7377}
7378
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007379
Linus Torvalds1da177e2005-04-16 15:20:36 -07007380/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007381 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007382 *
7383 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7384 * configuration. Each pin widget can choose any input DACs and a mixer.
7385 * Each ADC is connected from a mixer of all inputs. This makes possible
7386 * 6-channel independent captures.
7387 *
7388 * In addition, an independent DAC for the multi-playback (not used in this
7389 * driver yet).
7390 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007391#define ALC882_DIGOUT_NID 0x06
7392#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007393#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7394#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7395#define ALC1200_DIGOUT_NID 0x10
7396
Linus Torvalds1da177e2005-04-16 15:20:36 -07007397
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007398static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007399 { 8, NULL }
7400};
7401
Takashi Iwai4953550a2009-06-30 15:28:30 +02007402/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007403static hda_nid_t alc882_dac_nids[4] = {
7404 /* front, rear, clfe, rear_surr */
7405 0x02, 0x03, 0x04, 0x05
7406};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007407#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007408
Takashi Iwai4953550a2009-06-30 15:28:30 +02007409/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007410#define alc882_adc_nids alc880_adc_nids
7411#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007412#define alc883_adc_nids alc882_adc_nids_alt
7413static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7414static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7415#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007416
Takashi Iwaie1406342008-02-11 18:32:32 +01007417static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7418static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007419#define alc883_capsrc_nids alc882_capsrc_nids_alt
7420static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7421#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007422
Linus Torvalds1da177e2005-04-16 15:20:36 -07007423/* input MUX */
7424/* FIXME: should be a matrix-type input source selection */
7425
7426static struct hda_input_mux alc882_capture_source = {
7427 .num_items = 4,
7428 .items = {
7429 { "Mic", 0x0 },
7430 { "Front Mic", 0x1 },
7431 { "Line", 0x2 },
7432 { "CD", 0x4 },
7433 },
7434};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007435
Takashi Iwai4953550a2009-06-30 15:28:30 +02007436#define alc883_capture_source alc882_capture_source
7437
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007438static struct hda_input_mux alc889_capture_source = {
7439 .num_items = 3,
7440 .items = {
7441 { "Front Mic", 0x0 },
7442 { "Mic", 0x3 },
7443 { "Line", 0x2 },
7444 },
7445};
7446
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007447static struct hda_input_mux mb5_capture_source = {
7448 .num_items = 3,
7449 .items = {
7450 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307451 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007452 { "CD", 0x4 },
7453 },
7454};
7455
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007456static struct hda_input_mux macmini3_capture_source = {
7457 .num_items = 2,
7458 .items = {
7459 { "Line", 0x2 },
7460 { "CD", 0x4 },
7461 },
7462};
7463
Takashi Iwai4953550a2009-06-30 15:28:30 +02007464static struct hda_input_mux alc883_3stack_6ch_intel = {
7465 .num_items = 4,
7466 .items = {
7467 { "Mic", 0x1 },
7468 { "Front Mic", 0x0 },
7469 { "Line", 0x2 },
7470 { "CD", 0x4 },
7471 },
7472};
7473
7474static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7475 .num_items = 2,
7476 .items = {
7477 { "Mic", 0x1 },
7478 { "Line", 0x2 },
7479 },
7480};
7481
7482static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7483 .num_items = 4,
7484 .items = {
7485 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007486 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007487 { "Line", 0x2 },
7488 { "CD", 0x4 },
7489 },
7490};
7491
7492static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7493 .num_items = 2,
7494 .items = {
7495 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007496 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007497 },
7498};
7499
7500static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7501 .num_items = 3,
7502 .items = {
7503 { "Mic", 0x0 },
7504 { "Front Mic", 0x1 },
7505 { "Line", 0x4 },
7506 },
7507};
7508
7509static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7510 .num_items = 2,
7511 .items = {
7512 { "Mic", 0x0 },
7513 { "Line", 0x2 },
7514 },
7515};
7516
7517static struct hda_input_mux alc889A_mb31_capture_source = {
7518 .num_items = 2,
7519 .items = {
7520 { "Mic", 0x0 },
7521 /* Front Mic (0x01) unused */
7522 { "Line", 0x2 },
7523 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007524 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007525 },
7526};
7527
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007528static struct hda_input_mux alc889A_imac91_capture_source = {
7529 .num_items = 2,
7530 .items = {
7531 { "Mic", 0x01 },
7532 { "Line", 0x2 }, /* Not sure! */
7533 },
7534};
7535
Takashi Iwai4953550a2009-06-30 15:28:30 +02007536/*
7537 * 2ch mode
7538 */
7539static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7540 { 2, NULL }
7541};
7542
Kailang Yangdf694da2005-12-05 19:42:22 +01007543/*
Kailang Yang272a5272007-05-14 11:00:38 +02007544 * 2ch mode
7545 */
7546static struct hda_verb alc882_3ST_ch2_init[] = {
7547 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7548 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7549 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7550 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7551 { } /* end */
7552};
7553
7554/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007555 * 4ch mode
7556 */
7557static struct hda_verb alc882_3ST_ch4_init[] = {
7558 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7559 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7560 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7561 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7562 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7563 { } /* end */
7564};
7565
7566/*
Kailang Yang272a5272007-05-14 11:00:38 +02007567 * 6ch mode
7568 */
7569static struct hda_verb alc882_3ST_ch6_init[] = {
7570 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7571 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7572 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7573 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7574 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7575 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7576 { } /* end */
7577};
7578
Takashi Iwai4953550a2009-06-30 15:28:30 +02007579static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007580 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007581 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007582 { 6, alc882_3ST_ch6_init },
7583};
7584
Takashi Iwai4953550a2009-06-30 15:28:30 +02007585#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7586
Kailang Yang272a5272007-05-14 11:00:38 +02007587/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307588 * 2ch mode
7589 */
7590static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7591 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7592 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7593 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7594 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7595 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7596 { } /* end */
7597};
7598
7599/*
7600 * 4ch mode
7601 */
7602static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7603 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7604 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7605 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7606 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7607 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7608 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7609 { } /* end */
7610};
7611
7612/*
7613 * 6ch mode
7614 */
7615static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7616 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7617 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7618 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7619 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7620 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7621 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7622 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7623 { } /* end */
7624};
7625
7626static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7627 { 2, alc883_3ST_ch2_clevo_init },
7628 { 4, alc883_3ST_ch4_clevo_init },
7629 { 6, alc883_3ST_ch6_clevo_init },
7630};
7631
7632
7633/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007634 * 6ch mode
7635 */
7636static struct hda_verb alc882_sixstack_ch6_init[] = {
7637 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7638 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7639 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7640 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7641 { } /* end */
7642};
7643
7644/*
7645 * 8ch mode
7646 */
7647static struct hda_verb alc882_sixstack_ch8_init[] = {
7648 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7649 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7650 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7651 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7652 { } /* end */
7653};
7654
7655static struct hda_channel_mode alc882_sixstack_modes[2] = {
7656 { 6, alc882_sixstack_ch6_init },
7657 { 8, alc882_sixstack_ch8_init },
7658};
7659
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007660
7661/* Macbook Air 2,1 */
7662
7663static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7664 { 2, NULL },
7665};
7666
Takashi Iwai87350ad2007-08-16 18:19:38 +02007667/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007668 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007669 */
7670
7671/*
7672 * 2ch mode
7673 */
7674static struct hda_verb alc885_mbp_ch2_init[] = {
7675 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7676 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7677 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7678 { } /* end */
7679};
7680
7681/*
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007682 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007683 */
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007684static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007685 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7686 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7687 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7688 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7689 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7690 { } /* end */
7691};
7692
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007693static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007694 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007695 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007696};
7697
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007698/*
7699 * 2ch
7700 * Speakers/Woofer/HP = Front
7701 * LineIn = Input
7702 */
7703static struct hda_verb alc885_mb5_ch2_init[] = {
7704 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7705 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7706 { } /* end */
7707};
7708
7709/*
7710 * 6ch mode
7711 * Speakers/HP = Front
7712 * Woofer = LFE
7713 * LineIn = Surround
7714 */
7715static struct hda_verb alc885_mb5_ch6_init[] = {
7716 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7717 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7718 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7719 { } /* end */
7720};
7721
7722static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7723 { 2, alc885_mb5_ch2_init },
7724 { 6, alc885_mb5_ch6_init },
7725};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007726
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007727#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007728
7729/*
7730 * 2ch mode
7731 */
7732static struct hda_verb alc883_4ST_ch2_init[] = {
7733 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7734 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7735 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7736 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7737 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7738 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7739 { } /* end */
7740};
7741
7742/*
7743 * 4ch mode
7744 */
7745static struct hda_verb alc883_4ST_ch4_init[] = {
7746 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7747 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7748 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7749 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7750 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7751 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7752 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7753 { } /* end */
7754};
7755
7756/*
7757 * 6ch mode
7758 */
7759static struct hda_verb alc883_4ST_ch6_init[] = {
7760 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7761 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7762 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7763 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7764 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7765 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7766 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7767 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7768 { } /* end */
7769};
7770
7771/*
7772 * 8ch mode
7773 */
7774static struct hda_verb alc883_4ST_ch8_init[] = {
7775 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7776 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7777 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7778 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7779 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7780 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7781 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7782 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7783 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7784 { } /* end */
7785};
7786
7787static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7788 { 2, alc883_4ST_ch2_init },
7789 { 4, alc883_4ST_ch4_init },
7790 { 6, alc883_4ST_ch6_init },
7791 { 8, alc883_4ST_ch8_init },
7792};
7793
7794
7795/*
7796 * 2ch mode
7797 */
7798static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7799 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7800 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7801 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7802 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7803 { } /* end */
7804};
7805
7806/*
7807 * 4ch mode
7808 */
7809static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7810 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7811 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7812 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7813 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7814 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7815 { } /* end */
7816};
7817
7818/*
7819 * 6ch mode
7820 */
7821static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7822 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7823 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7824 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7825 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7826 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7827 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7828 { } /* end */
7829};
7830
7831static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7832 { 2, alc883_3ST_ch2_intel_init },
7833 { 4, alc883_3ST_ch4_intel_init },
7834 { 6, alc883_3ST_ch6_intel_init },
7835};
7836
7837/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007838 * 2ch mode
7839 */
7840static struct hda_verb alc889_ch2_intel_init[] = {
7841 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7842 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7843 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7844 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7845 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7846 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7847 { } /* end */
7848};
7849
7850/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007851 * 6ch mode
7852 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007853static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007854 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7855 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7856 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7857 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7858 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007859 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7860 { } /* end */
7861};
7862
7863/*
7864 * 8ch mode
7865 */
7866static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007867 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7868 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7869 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7870 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7871 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007872 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7873 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007874 { } /* end */
7875};
7876
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007877static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7878 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007879 { 6, alc889_ch6_intel_init },
7880 { 8, alc889_ch8_intel_init },
7881};
7882
7883/*
7884 * 6ch mode
7885 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007886static struct hda_verb alc883_sixstack_ch6_init[] = {
7887 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7888 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7889 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7890 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7891 { } /* end */
7892};
7893
7894/*
7895 * 8ch mode
7896 */
7897static struct hda_verb alc883_sixstack_ch8_init[] = {
7898 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7899 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7900 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7901 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7902 { } /* end */
7903};
7904
7905static struct hda_channel_mode alc883_sixstack_modes[2] = {
7906 { 6, alc883_sixstack_ch6_init },
7907 { 8, alc883_sixstack_ch8_init },
7908};
7909
7910
Linus Torvalds1da177e2005-04-16 15:20:36 -07007911/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7912 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7913 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007914static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007915 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007916 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007917 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007918 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007919 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7920 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007921 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7922 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007923 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007924 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007925 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7926 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7927 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7928 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7929 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7930 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007931 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007932 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7933 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007934 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007935 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007936 { } /* end */
7937};
7938
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007939/* Macbook Air 2,1 same control for HP and internal Speaker */
7940
7941static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7942 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7943 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7944 { }
7945};
7946
7947
Takashi Iwai87350ad2007-08-16 18:19:38 +02007948static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007949 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7950 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7951 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7952 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7953 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007954 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7955 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007956 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7957 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007958 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
7959 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007960 { } /* end */
7961};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007962
7963static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007964 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7965 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7966 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7967 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7968 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7969 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307970 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7971 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09307972 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7973 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007974 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7975 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007976 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
7977 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0x00, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007978 { } /* end */
7979};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007980
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007981static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7982 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7983 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7984 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7985 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7986 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7987 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7988 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7989 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7990 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7991 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007992 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007993 { } /* end */
7994};
7995
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007996static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007997 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7998 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007999 { } /* end */
8000};
8001
8002
Kailang Yangbdd148a2007-05-08 15:19:08 +02008003static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
8004 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8005 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8006 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8007 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8008 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8009 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8010 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008011 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008012 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008013 { } /* end */
8014};
8015
Kailang Yang272a5272007-05-14 11:00:38 +02008016static struct snd_kcontrol_new alc882_targa_mixer[] = {
8017 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8018 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8019 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8020 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8021 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8022 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8023 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8024 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8025 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008026 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008027 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8028 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008029 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008030 { } /* end */
8031};
8032
8033/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
8034 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
8035 */
8036static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
8037 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8038 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8039 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8040 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8041 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8042 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8043 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8044 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8045 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
8046 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
8047 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8048 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008049 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008050 { } /* end */
8051};
8052
Takashi Iwai914759b2007-09-06 14:52:04 +02008053static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
8054 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8055 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8056 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8057 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8058 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8059 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8060 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8061 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008062 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008063 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008064 { } /* end */
8065};
8066
Kailang Yangdf694da2005-12-05 19:42:22 +01008067static struct snd_kcontrol_new alc882_chmode_mixer[] = {
8068 {
8069 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8070 .name = "Channel Mode",
8071 .info = alc_ch_mode_info,
8072 .get = alc_ch_mode_get,
8073 .put = alc_ch_mode_put,
8074 },
8075 { } /* end */
8076};
8077
Takashi Iwai4953550a2009-06-30 15:28:30 +02008078static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07008079 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008080 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8081 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008082 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008083 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8084 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008085 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008086 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8087 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008088 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008089 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8090 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008091
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008092 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008093 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008094 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008095 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008096 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008097 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008098 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008099 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008100 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008101 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008102 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008103 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008104 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008105 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008106 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008107 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008108 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008109 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008110 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8111 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008112 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008113 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8114 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008115 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008116 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8117 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8118 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8119 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8120 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008121 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008122 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008123
8124 /* FIXME: use matrix-type input source selection */
8125 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008126 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008127 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008128 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008129 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02008130 /* ADC2: mute amp left and right */
8131 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008132 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02008133 /* ADC3: mute amp left and right */
8134 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008135 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008136
8137 { }
8138};
8139
Takashi Iwai4953550a2009-06-30 15:28:30 +02008140static struct hda_verb alc882_adc1_init_verbs[] = {
8141 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8142 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8143 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8144 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8145 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8146 /* ADC1: mute amp left and right */
8147 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8148 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8149 { }
8150};
8151
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008152static struct hda_verb alc882_eapd_verbs[] = {
8153 /* change to EAPD mode */
8154 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008155 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008156 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008157};
8158
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008159static struct hda_verb alc889_eapd_verbs[] = {
8160 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8161 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8162 { }
8163};
8164
Wu Fengguang6732bd02009-07-30 09:19:14 +02008165static struct hda_verb alc_hp15_unsol_verbs[] = {
8166 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8167 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8168 {}
8169};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008170
8171static struct hda_verb alc885_init_verbs[] = {
8172 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01008173 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8174 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008175 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008176 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8177 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008178 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008179 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8180 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008181 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008182 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8183 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008184
8185 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02008186 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008187 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8188 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8189 /* Front Pin: output 0 (0x0c) */
8190 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8191 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8192 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8193 /* Rear Pin: output 1 (0x0d) */
8194 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8195 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8196 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
8197 /* CLFE Pin: output 2 (0x0e) */
8198 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8199 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8200 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8201 /* Side Pin: output 3 (0x0f) */
8202 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8203 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8204 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8205 /* Mic (rear) pin: input vref at 80% */
8206 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8207 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8208 /* Front Mic pin: input vref at 80% */
8209 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8210 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8211 /* Line In pin: input */
8212 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8213 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8214
8215 /* Mixer elements: 0x18, , 0x1a, 0x1b */
8216 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01008217 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008218 /* Input mixer2 */
8219 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008220 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008221 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008222 /* ADC2: mute amp left and right */
8223 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8224 /* ADC3: mute amp left and right */
8225 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8226
8227 { }
8228};
8229
8230static struct hda_verb alc885_init_input_verbs[] = {
8231 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8232 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8233 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8234 { }
8235};
8236
8237
8238/* Unmute Selector 24h and set the default input to front mic */
8239static struct hda_verb alc889_init_input_verbs[] = {
8240 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8241 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8242 { }
8243};
8244
8245
Takashi Iwai4953550a2009-06-30 15:28:30 +02008246#define alc883_init_verbs alc882_base_init_verbs
8247
Tobin Davis9102cd12006-12-15 10:02:12 +01008248/* Mac Pro test */
8249static struct snd_kcontrol_new alc882_macpro_mixer[] = {
8250 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8251 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8252 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
8253 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8254 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008255 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01008256 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
8257 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008258 */
Tobin Davis9102cd12006-12-15 10:02:12 +01008259 { } /* end */
8260};
8261
8262static struct hda_verb alc882_macpro_init_verbs[] = {
8263 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8264 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8265 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8266 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8267 /* Front Pin: output 0 (0x0c) */
8268 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8269 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8270 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8271 /* Front Mic pin: input vref at 80% */
8272 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8273 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8274 /* Speaker: output */
8275 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8276 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8277 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
8278 /* Headphone output (output 0 - 0x0c) */
8279 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8280 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8281 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8282
8283 /* FIXME: use matrix-type input source selection */
8284 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8285 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8286 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8287 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8288 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8289 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8290 /* Input mixer2 */
8291 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8292 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8293 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8294 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8295 /* Input mixer3 */
8296 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8297 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8298 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8299 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8300 /* ADC1: mute amp left and right */
8301 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8302 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8303 /* ADC2: mute amp left and right */
8304 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8305 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8306 /* ADC3: mute amp left and right */
8307 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8308 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8309
8310 { }
8311};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008312
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008313/* Macbook 5,1 */
8314static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008315 /* DACs */
8316 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8317 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8318 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8319 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008320 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008321 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8322 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8323 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008324 /* Surround mixer */
8325 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8326 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8327 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8328 /* LFE mixer */
8329 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8330 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8331 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8332 /* HP mixer */
8333 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8334 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8335 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8336 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008337 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8338 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008339 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8340 /* LFE Pin (0x0e) */
8341 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8342 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8343 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8344 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008345 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8346 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008347 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308348 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008349 /* Front Mic pin: input vref at 80% */
8350 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8351 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8352 /* Line In pin */
8353 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8354 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8355
Alex Murrayb8f171e2010-06-14 12:08:43 +09308356 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8357 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8358 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008359 { }
8360};
8361
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008362/* Macmini 3,1 */
8363static struct hda_verb alc885_macmini3_init_verbs[] = {
8364 /* DACs */
8365 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8366 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8367 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8368 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8369 /* Front mixer */
8370 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8371 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8372 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8373 /* Surround mixer */
8374 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8375 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8376 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8377 /* LFE mixer */
8378 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8379 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8380 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8381 /* HP mixer */
8382 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8383 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8384 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8385 /* Front Pin (0x0c) */
8386 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8387 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8388 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8389 /* LFE Pin (0x0e) */
8390 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8391 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8392 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8393 /* HP Pin (0x0f) */
8394 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8395 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8396 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8397 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8398 /* Line In pin */
8399 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8400 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8401
8402 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8403 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8404 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8405 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8406 { }
8407};
8408
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008409
8410static struct hda_verb alc885_mba21_init_verbs[] = {
8411 /*Internal and HP Speaker Mixer*/
8412 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8413 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8414 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8415 /*Internal Speaker Pin (0x0c)*/
8416 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8417 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8418 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8419 /* HP Pin: output 0 (0x0e) */
8420 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8421 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8422 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8423 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8424 /* Line in (is hp when jack connected)*/
8425 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8426 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8427
8428 { }
8429 };
8430
8431
Takashi Iwai87350ad2007-08-16 18:19:38 +02008432/* Macbook Pro rev3 */
8433static struct hda_verb alc885_mbp3_init_verbs[] = {
8434 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8435 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8436 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8437 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8438 /* Rear mixer */
8439 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8440 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8441 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02008442 /* HP mixer */
8443 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8444 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8445 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008446 /* Front Pin: output 0 (0x0c) */
8447 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8448 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8449 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02008450 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008451 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02008452 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8453 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008454 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8455 /* Mic (rear) pin: input vref at 80% */
8456 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8457 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8458 /* Front Mic pin: input vref at 80% */
8459 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8460 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8461 /* Line In pin: use output 1 when in LineOut mode */
8462 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8463 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8464 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8465
8466 /* FIXME: use matrix-type input source selection */
8467 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8468 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8469 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8470 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8471 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8472 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8473 /* Input mixer2 */
8474 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8475 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8476 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8477 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8478 /* Input mixer3 */
8479 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8480 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8481 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8482 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8483 /* ADC1: mute amp left and right */
8484 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8485 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8486 /* ADC2: mute amp left and right */
8487 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8488 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8489 /* ADC3: mute amp left and right */
8490 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8491 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8492
8493 { }
8494};
8495
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008496/* iMac 9,1 */
8497static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008498 /* Internal Speaker Pin (0x0c) */
8499 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8500 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8501 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8502 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8503 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8504 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8505 /* HP Pin: Rear */
8506 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8507 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8508 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8509 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8510 /* Line in Rear */
8511 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8512 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8513 /* Front Mic pin: input vref at 80% */
8514 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8515 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008516 /* Rear mixer */
8517 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8518 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8519 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008520 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8521 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8522 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8523 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8524 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008525 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8526 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8527 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8528 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008529 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008530 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8531 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8532 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8533 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008534 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008535 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8536 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8537 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8538 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008539 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008540 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8541 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008542 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008543 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8544 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008545 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008546 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8547 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008548 { }
8549};
8550
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008551/* iMac 24 mixer. */
8552static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8553 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8554 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8555 { } /* end */
8556};
8557
8558/* iMac 24 init verbs. */
8559static struct hda_verb alc885_imac24_init_verbs[] = {
8560 /* Internal speakers: output 0 (0x0c) */
8561 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8562 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8563 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8564 /* Internal speakers: output 0 (0x0c) */
8565 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8566 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8567 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8568 /* Headphone: output 0 (0x0c) */
8569 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8570 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8571 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8572 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8573 /* Front Mic: input vref at 80% */
8574 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8575 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8576 { }
8577};
8578
8579/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008580static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008581{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008582 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008583
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008584 spec->autocfg.hp_pins[0] = 0x14;
8585 spec->autocfg.speaker_pins[0] = 0x18;
8586 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008587}
8588
Takashi Iwai9d54f082010-02-22 08:34:40 +01008589#define alc885_mb5_setup alc885_imac24_setup
8590#define alc885_macmini3_setup alc885_imac24_setup
8591
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008592/* Macbook Air 2,1 */
8593static void alc885_mba21_setup(struct hda_codec *codec)
8594{
8595 struct alc_spec *spec = codec->spec;
8596
8597 spec->autocfg.hp_pins[0] = 0x14;
8598 spec->autocfg.speaker_pins[0] = 0x18;
8599}
8600
8601
8602
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008603static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008604{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008605 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008606
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008607 spec->autocfg.hp_pins[0] = 0x15;
8608 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008609}
8610
Takashi Iwai9d54f082010-02-22 08:34:40 +01008611static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308612{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008613 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308614
Takashi Iwai9d54f082010-02-22 08:34:40 +01008615 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008616 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008617 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008618}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008619
Kailang Yang272a5272007-05-14 11:00:38 +02008620static struct hda_verb alc882_targa_verbs[] = {
8621 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8622 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8623
8624 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8625 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008626
Kailang Yang272a5272007-05-14 11:00:38 +02008627 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8628 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8629 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8630
8631 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008632 { } /* end */
8633};
8634
8635/* toggle speaker-output according to the hp-jack state */
8636static void alc882_targa_automute(struct hda_codec *codec)
8637{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008638 struct alc_spec *spec = codec->spec;
8639 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008640 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008641 spec->jack_present ? 1 : 3);
8642}
8643
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008644static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008645{
8646 struct alc_spec *spec = codec->spec;
8647
8648 spec->autocfg.hp_pins[0] = 0x14;
8649 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008650}
8651
8652static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8653{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008654 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008655 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008656}
8657
8658static struct hda_verb alc882_asus_a7j_verbs[] = {
8659 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8660 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8661
8662 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8663 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8664 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008665
Kailang Yang272a5272007-05-14 11:00:38 +02008666 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8667 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8668 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8669
8670 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8671 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8672 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8673 { } /* end */
8674};
8675
Takashi Iwai914759b2007-09-06 14:52:04 +02008676static struct hda_verb alc882_asus_a7m_verbs[] = {
8677 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8678 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8679
8680 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8681 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8682 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008683
Takashi Iwai914759b2007-09-06 14:52:04 +02008684 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8685 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8686 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8687
8688 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8689 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8690 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8691 { } /* end */
8692};
8693
Tobin Davis9102cd12006-12-15 10:02:12 +01008694static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8695{
8696 unsigned int gpiostate, gpiomask, gpiodir;
8697
8698 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8699 AC_VERB_GET_GPIO_DATA, 0);
8700
8701 if (!muted)
8702 gpiostate |= (1 << pin);
8703 else
8704 gpiostate &= ~(1 << pin);
8705
8706 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8707 AC_VERB_GET_GPIO_MASK, 0);
8708 gpiomask |= (1 << pin);
8709
8710 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8711 AC_VERB_GET_GPIO_DIRECTION, 0);
8712 gpiodir |= (1 << pin);
8713
8714
8715 snd_hda_codec_write(codec, codec->afg, 0,
8716 AC_VERB_SET_GPIO_MASK, gpiomask);
8717 snd_hda_codec_write(codec, codec->afg, 0,
8718 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8719
8720 msleep(1);
8721
8722 snd_hda_codec_write(codec, codec->afg, 0,
8723 AC_VERB_SET_GPIO_DATA, gpiostate);
8724}
8725
Takashi Iwai7debbe52007-08-16 15:01:03 +02008726/* set up GPIO at initialization */
8727static void alc885_macpro_init_hook(struct hda_codec *codec)
8728{
8729 alc882_gpio_mute(codec, 0, 0);
8730 alc882_gpio_mute(codec, 1, 0);
8731}
8732
8733/* set up GPIO and update auto-muting at initialization */
8734static void alc885_imac24_init_hook(struct hda_codec *codec)
8735{
8736 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008737 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008738}
8739
Kailang Yangdf694da2005-12-05 19:42:22 +01008740/*
8741 * generic initialization of ADC, input mixers and output mixers
8742 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008743static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008744 /*
8745 * Unmute ADC0-2 and set the default input to mic-in
8746 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008747 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8748 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8749 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8750 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8751
Kailang Yangdf694da2005-12-05 19:42:22 +01008752 /*
8753 * Set up output mixers (0x0c - 0x0f)
8754 */
8755 /* set vol=0 to output mixers */
8756 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8757 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8758 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8759 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8760 /* set up input amps for analog loopback */
8761 /* Amp Indices: DAC = 0, mixer = 1 */
8762 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8763 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8764 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8765 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8766 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8767 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8768 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8769 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8770 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8771 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8772
8773 /* FIXME: use matrix-type input source selection */
8774 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008775 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008776 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008777 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008778 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008779 { }
8780};
8781
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008782/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8783static struct hda_verb alc889A_mb31_ch2_init[] = {
8784 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8785 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8786 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8787 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8788 { } /* end */
8789};
8790
8791/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8792static struct hda_verb alc889A_mb31_ch4_init[] = {
8793 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8794 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8795 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8796 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8797 { } /* end */
8798};
8799
8800/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8801static struct hda_verb alc889A_mb31_ch5_init[] = {
8802 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8803 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8804 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8805 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8806 { } /* end */
8807};
8808
8809/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8810static struct hda_verb alc889A_mb31_ch6_init[] = {
8811 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8812 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8813 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8814 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8815 { } /* end */
8816};
8817
8818static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8819 { 2, alc889A_mb31_ch2_init },
8820 { 4, alc889A_mb31_ch4_init },
8821 { 5, alc889A_mb31_ch5_init },
8822 { 6, alc889A_mb31_ch6_init },
8823};
8824
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008825static struct hda_verb alc883_medion_eapd_verbs[] = {
8826 /* eanable EAPD on medion laptop */
8827 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8828 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8829 { }
8830};
8831
Takashi Iwai4953550a2009-06-30 15:28:30 +02008832#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008833
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008834static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8835 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8836 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8837 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8838 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8839 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8840 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8841 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8842 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008843 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008844 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8845 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008846 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008847 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008848 { } /* end */
8849};
8850
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008851static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008852 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8853 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8854 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8855 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8856 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008857 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008858 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008859 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008860 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008861 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008862 { } /* end */
8863};
8864
Jiang zhefb97dc62008-03-06 11:07:11 +01008865static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8866 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8867 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8868 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8869 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8870 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008871 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008872 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008873 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008874 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008875 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008876 { } /* end */
8877};
8878
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008879static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8880 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8881 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8882 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8883 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8884 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8885 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8886 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8887 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008888 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008889 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8890 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008891 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008892 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008893 { } /* end */
8894};
8895
8896static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8897 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8898 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8899 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8900 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8901 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8902 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8903 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8904 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8905 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8906 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8907 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8908 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8909 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8910 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008911 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008912 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8913 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008914 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008915 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008916 { } /* end */
8917};
8918
Jiang zhe17bba1b2008-06-04 12:11:07 +02008919static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8920 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8921 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8922 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8923 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8924 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8925 HDA_OUTPUT),
8926 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8927 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8928 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8929 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8930 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8931 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8932 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8933 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8934 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008935 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008936 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8937 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008938 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008939 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008940 { } /* end */
8941};
8942
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008943static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8944 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8945 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8946 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8947 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8948 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8949 HDA_OUTPUT),
8950 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8951 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8952 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8953 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8954 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8955 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8956 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8957 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8958 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008959 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008960 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8961 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008962 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008963 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8964 { } /* end */
8965};
8966
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008967static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008968 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008969 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008970 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008971 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008972 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8973 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008974 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8975 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008976 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8977 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8978 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8979 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8980 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8981 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008982 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008983 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8984 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008985 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008986 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008987 { } /* end */
8988};
8989
Sasha Alexandrc2592492009-06-16 14:52:54 -04008990static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008991 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008992 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008993 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008994 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008995 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8996 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8997 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8998 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8999 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9000 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9001 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9002 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9003 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9004 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9005 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009006 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009007 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009008 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009009};
Kailang Yangccc656c2006-10-17 12:32:26 +02009010
Sasha Alexandrc2592492009-06-16 14:52:54 -04009011static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009012 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009013 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009014 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009015 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009016 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9017 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9018 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009019 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009020 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009021 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009022 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009023 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009024 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009025};
Kailang Yangccc656c2006-10-17 12:32:26 +02009026
Takashi Iwaib99dba32009-09-17 18:23:00 +02009027static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
9028 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9029 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009030 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009031 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009032 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009033 { } /* end */
9034};
9035
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009036static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
9037 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9038 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009039 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9040 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009041 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9042 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009043 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009044 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009045 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009046};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009047
Kailang Yang272a5272007-05-14 11:00:38 +02009048static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
9049 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9050 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
9051 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9052 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9053 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9054 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9055 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009056 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9057 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02009058 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02009059};
Kailang Yang272a5272007-05-14 11:00:38 +02009060
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009061static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
9062 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9063 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9064 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9065 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
9066 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
9067 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
9068 { } /* end */
9069};
9070
9071static struct hda_verb alc883_medion_wim2160_verbs[] = {
9072 /* Unmute front mixer */
9073 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9074 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9075
9076 /* Set speaker pin to front mixer */
9077 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9078
9079 /* Init headphone pin */
9080 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9081 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9082 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9083 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9084
9085 { } /* end */
9086};
9087
9088/* toggle speaker-output according to the hp-jack state */
9089static void alc883_medion_wim2160_setup(struct hda_codec *codec)
9090{
9091 struct alc_spec *spec = codec->spec;
9092
9093 spec->autocfg.hp_pins[0] = 0x1a;
9094 spec->autocfg.speaker_pins[0] = 0x15;
9095}
9096
Tobin Davis2880a862007-08-07 11:50:26 +02009097static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02009098 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9099 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009100 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009101 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9102 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009103 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009104 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009105 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009106 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02009107};
Tobin Davis2880a862007-08-07 11:50:26 +02009108
Tony Vroond2fd4b02009-06-21 00:40:10 +01009109static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
9110 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009111 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01009112 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9113 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009114 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9115 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9116 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009117 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009118 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9119 { } /* end */
9120};
9121
Kailang Yange2757d52008-08-26 13:17:46 +02009122static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
9123 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9124 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9125 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9126 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
9127 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
9128 0x0d, 1, 0x0, HDA_OUTPUT),
9129 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
9130 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
9131 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
9132 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9133 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009134 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9135 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9136 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9137 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9138 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009139 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009140 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9141 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009142 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009143 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009144 { } /* end */
9145};
9146
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009147static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
9148 /* Output mixers */
9149 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
9150 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
9151 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
9152 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
9153 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
9154 HDA_OUTPUT),
9155 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
9156 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
9157 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
9158 /* Output switches */
9159 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
9160 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
9161 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
9162 /* Boost mixers */
David Henningsson5f99f862011-01-04 15:24:24 +01009163 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
9164 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009165 /* Input mixers */
9166 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
9167 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
9168 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9169 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9170 { } /* end */
9171};
9172
Guido Günther3e1647c2009-06-05 00:47:26 +02009173static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
9174 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9175 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9176 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9177 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009178 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Guido Günther3e1647c2009-06-05 00:47:26 +02009179 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9180 { } /* end */
9181};
9182
Kailang Yange2757d52008-08-26 13:17:46 +02009183static struct hda_bind_ctls alc883_bind_cap_vol = {
9184 .ops = &snd_hda_bind_vol,
9185 .values = {
9186 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9187 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9188 0
9189 },
9190};
9191
9192static struct hda_bind_ctls alc883_bind_cap_switch = {
9193 .ops = &snd_hda_bind_sw,
9194 .values = {
9195 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9196 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9197 0
9198 },
9199};
9200
9201static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
9202 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9203 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9204 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9205 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9206 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9207 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009208 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009209 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009210 { } /* end */
9211};
9212
9213static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009214 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
9215 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
9216 {
9217 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9218 /* .name = "Capture Source", */
9219 .name = "Input Source",
9220 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009221 .info = alc_mux_enum_info,
9222 .get = alc_mux_enum_get,
9223 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02009224 },
9225 { } /* end */
9226};
9227
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009228static struct snd_kcontrol_new alc883_chmode_mixer[] = {
9229 {
9230 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9231 .name = "Channel Mode",
9232 .info = alc_ch_mode_info,
9233 .get = alc_ch_mode_get,
9234 .put = alc_ch_mode_put,
9235 },
9236 { } /* end */
9237};
9238
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009239/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009240static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009241{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009242 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009243
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009244 spec->autocfg.hp_pins[0] = 0x15;
9245 spec->autocfg.speaker_pins[0] = 0x14;
9246 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009247}
9248
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009249static struct hda_verb alc883_mitac_verbs[] = {
9250 /* HP */
9251 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9252 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9253 /* Subwoofer */
9254 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9255 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9256
9257 /* enable unsolicited event */
9258 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9259 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
9260
9261 { } /* end */
9262};
9263
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309264static struct hda_verb alc883_clevo_m540r_verbs[] = {
9265 /* HP */
9266 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9267 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9268 /* Int speaker */
9269 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9270
9271 /* enable unsolicited event */
9272 /*
9273 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9274 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9275 */
9276
9277 { } /* end */
9278};
9279
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009280static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009281 /* HP */
9282 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9283 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9284 /* Int speaker */
9285 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9286 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9287
9288 /* enable unsolicited event */
9289 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009290 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009291
9292 { } /* end */
9293};
9294
Jiang zhefb97dc62008-03-06 11:07:11 +01009295static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9296 /* HP */
9297 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9298 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9299 /* Subwoofer */
9300 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9301 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9302
9303 /* enable unsolicited event */
9304 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9305
9306 { } /* end */
9307};
9308
Sasha Alexandrc2592492009-06-16 14:52:54 -04009309static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009310 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9311 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9312
9313 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9314 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009315
David Heidelberger64a8be72009-06-08 16:15:18 +02009316/* Connect Line-Out side jack (SPDIF) to Side */
9317 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9318 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9319 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9320/* Connect Mic jack to CLFE */
9321 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9322 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9323 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9324/* Connect Line-in jack to Surround */
9325 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9326 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9327 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9328/* Connect HP out jack to Front */
9329 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9330 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9331 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009332
9333 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009334
9335 { } /* end */
9336};
9337
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009338static struct hda_verb alc883_lenovo_101e_verbs[] = {
9339 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9340 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9341 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9342 { } /* end */
9343};
9344
Kailang Yang272a5272007-05-14 11:00:38 +02009345static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9346 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9347 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9348 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9349 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9350 { } /* end */
9351};
9352
9353static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
9354 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9355 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9356 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9357 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9358 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9359 { } /* end */
9360};
9361
Kailang Yang189609a2007-08-20 11:31:23 +02009362static struct hda_verb alc883_haier_w66_verbs[] = {
9363 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9364 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9365
9366 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9367
9368 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9369 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9370 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9371 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9372 { } /* end */
9373};
9374
Kailang Yange2757d52008-08-26 13:17:46 +02009375static struct hda_verb alc888_lenovo_sky_verbs[] = {
9376 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9377 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9378 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9379 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9380 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9381 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9382 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9383 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9384 { } /* end */
9385};
9386
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009387static struct hda_verb alc888_6st_dell_verbs[] = {
9388 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9389 { }
9390};
9391
Guido Günther3e1647c2009-06-05 00:47:26 +02009392static struct hda_verb alc883_vaiott_verbs[] = {
9393 /* HP */
9394 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9395 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9396
9397 /* enable unsolicited event */
9398 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9399
9400 { } /* end */
9401};
9402
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009403static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009404{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009405 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009406
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009407 spec->autocfg.hp_pins[0] = 0x1b;
9408 spec->autocfg.speaker_pins[0] = 0x14;
9409 spec->autocfg.speaker_pins[1] = 0x16;
9410 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009411}
9412
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009413static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009414 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009415 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9416 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009417 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009418 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009419};
9420
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009421/*
9422 * 2ch mode
9423 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009424static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009425 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9426 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9427 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9428 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009429 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009430};
9431
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009432/*
9433 * 4ch mode
9434 */
9435static struct hda_verb alc888_3st_hp_4ch_init[] = {
9436 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9437 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9438 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9439 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9440 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9441 { } /* end */
9442};
9443
9444/*
9445 * 6ch mode
9446 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009447static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009448 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9449 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009450 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009451 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9452 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009453 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9454 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009455};
9456
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009457static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009458 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009459 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009460 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009461};
9462
Kailang Yang272a5272007-05-14 11:00:38 +02009463/* toggle front-jack and RCA according to the hp-jack state */
9464static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9465{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009466 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02009467
Takashi Iwai47fd8302007-08-10 17:11:07 +02009468 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9469 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9470 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9471 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009472}
9473
9474/* toggle RCA according to the front-jack state */
9475static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9476{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009477 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009478
Takashi Iwai47fd8302007-08-10 17:11:07 +02009479 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9480 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009481}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009482
Kailang Yang272a5272007-05-14 11:00:38 +02009483static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9484 unsigned int res)
9485{
9486 if ((res >> 26) == ALC880_HP_EVENT)
9487 alc888_lenovo_ms7195_front_automute(codec);
9488 if ((res >> 26) == ALC880_FRONT_EVENT)
9489 alc888_lenovo_ms7195_rca_automute(codec);
9490}
9491
Kailang Yang272a5272007-05-14 11:00:38 +02009492/* toggle speaker-output according to the hp-jack state */
Takashi Iwaidc4271702010-11-29 07:42:59 +01009493static void alc883_lenovo_nb0763_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009494{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009495 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009496
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009497 spec->autocfg.hp_pins[0] = 0x14;
9498 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009499}
9500
Kailang Yangccc656c2006-10-17 12:32:26 +02009501/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009502#define alc883_targa_init_hook alc882_targa_init_hook
9503#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009504
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009505static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009506{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009507 struct alc_spec *spec = codec->spec;
9508
9509 spec->autocfg.hp_pins[0] = 0x15;
9510 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009511}
9512
9513static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9514{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009515 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01009516 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009517}
9518
9519static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009520 unsigned int res)
9521{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009522 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009523 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01009524 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009525 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009526 default:
9527 alc_automute_amp_unsol_event(codec, res);
9528 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009529 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009530}
9531
Jiang zhefb97dc62008-03-06 11:07:11 +01009532/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009533static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009534{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009535 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009536
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009537 spec->autocfg.hp_pins[0] = 0x14;
9538 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009539}
9540
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009541static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009542{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009543 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009544
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009545 spec->autocfg.hp_pins[0] = 0x1b;
9546 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009547}
9548
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009549static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9550{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009551 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009552
Takashi Iwai47fd8302007-08-10 17:11:07 +02009553 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9554 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009555}
9556
9557static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9558{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009559 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009560
Takashi Iwai47fd8302007-08-10 17:11:07 +02009561 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9562 HDA_AMP_MUTE, bits);
9563 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9564 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009565}
9566
9567static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9568 unsigned int res)
9569{
9570 if ((res >> 26) == ALC880_HP_EVENT)
9571 alc883_lenovo_101e_all_automute(codec);
9572 if ((res >> 26) == ALC880_FRONT_EVENT)
9573 alc883_lenovo_101e_ispeaker_automute(codec);
9574}
9575
Takashi Iwai676a9b52007-08-16 15:23:35 +02009576/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009577static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009578{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009579 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009580
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009581 spec->autocfg.hp_pins[0] = 0x14;
9582 spec->autocfg.speaker_pins[0] = 0x15;
9583 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009584}
9585
Kailang Yangd1a991a2007-08-15 16:21:59 +02009586static struct hda_verb alc883_acer_eapd_verbs[] = {
9587 /* HP Pin: output 0 (0x0c) */
9588 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9589 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9590 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9591 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009592 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9593 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009594 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009595 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9596 /* eanable EAPD on medion laptop */
9597 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9598 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009599 /* enable unsolicited event */
9600 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009601 { }
9602};
9603
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009604static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009605{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009606 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009607
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009608 spec->autocfg.hp_pins[0] = 0x1b;
9609 spec->autocfg.speaker_pins[0] = 0x14;
9610 spec->autocfg.speaker_pins[1] = 0x15;
9611 spec->autocfg.speaker_pins[2] = 0x16;
9612 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009613}
9614
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009615static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009616{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009617 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009618
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009619 spec->autocfg.hp_pins[0] = 0x1b;
9620 spec->autocfg.speaker_pins[0] = 0x14;
9621 spec->autocfg.speaker_pins[1] = 0x15;
9622 spec->autocfg.speaker_pins[2] = 0x16;
9623 spec->autocfg.speaker_pins[3] = 0x17;
9624 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009625}
9626
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009627static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009628{
9629 struct alc_spec *spec = codec->spec;
9630
9631 spec->autocfg.hp_pins[0] = 0x15;
9632 spec->autocfg.speaker_pins[0] = 0x14;
9633 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009634}
9635
Kailang Yange2757d52008-08-26 13:17:46 +02009636static struct hda_verb alc888_asus_m90v_verbs[] = {
9637 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9638 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9639 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9640 /* enable unsolicited event */
9641 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9642 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9643 { } /* end */
9644};
9645
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009646static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009647{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009648 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009649
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009650 spec->autocfg.hp_pins[0] = 0x1b;
9651 spec->autocfg.speaker_pins[0] = 0x14;
9652 spec->autocfg.speaker_pins[1] = 0x15;
9653 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009654 spec->ext_mic.pin = 0x18;
9655 spec->int_mic.pin = 0x19;
9656 spec->ext_mic.mux_idx = 0;
9657 spec->int_mic.mux_idx = 1;
9658 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009659}
9660
9661static struct hda_verb alc888_asus_eee1601_verbs[] = {
9662 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9663 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9664 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9665 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9666 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9667 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9668 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9669 /* enable unsolicited event */
9670 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9671 { } /* end */
9672};
9673
Kailang Yange2757d52008-08-26 13:17:46 +02009674static void alc883_eee1601_inithook(struct hda_codec *codec)
9675{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009676 struct alc_spec *spec = codec->spec;
9677
9678 spec->autocfg.hp_pins[0] = 0x14;
9679 spec->autocfg.speaker_pins[0] = 0x1b;
9680 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009681}
9682
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009683static struct hda_verb alc889A_mb31_verbs[] = {
9684 /* Init rear pin (used as headphone output) */
9685 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9686 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9687 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9688 /* Init line pin (used as output in 4ch and 6ch mode) */
9689 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9690 /* Init line 2 pin (used as headphone out by default) */
9691 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9692 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9693 { } /* end */
9694};
9695
9696/* Mute speakers according to the headphone jack state */
9697static void alc889A_mb31_automute(struct hda_codec *codec)
9698{
9699 unsigned int present;
9700
9701 /* Mute only in 2ch or 4ch mode */
9702 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9703 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009704 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009705 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9706 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9707 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9708 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9709 }
9710}
9711
9712static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9713{
9714 if ((res >> 26) == ALC880_HP_EVENT)
9715 alc889A_mb31_automute(codec);
9716}
9717
Takashi Iwai4953550a2009-06-30 15:28:30 +02009718
Takashi Iwaicb53c622007-08-10 17:21:45 +02009719#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009720#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009721#endif
9722
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009723/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009724#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9725#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9726#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9727#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9728
9729static hda_nid_t alc883_slave_dig_outs[] = {
9730 ALC1200_DIGOUT_NID, 0,
9731};
9732
9733static hda_nid_t alc1200_slave_dig_outs[] = {
9734 ALC883_DIGOUT_NID, 0,
9735};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009736
9737/*
9738 * configuration and preset
9739 */
Takashi Iwaiea734962011-01-17 11:29:34 +01009740static const char * const alc882_models[ALC882_MODEL_LAST] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009741 [ALC882_3ST_DIG] = "3stack-dig",
9742 [ALC882_6ST_DIG] = "6stack-dig",
9743 [ALC882_ARIMA] = "arima",
9744 [ALC882_W2JC] = "w2jc",
9745 [ALC882_TARGA] = "targa",
9746 [ALC882_ASUS_A7J] = "asus-a7j",
9747 [ALC882_ASUS_A7M] = "asus-a7m",
9748 [ALC885_MACPRO] = "macpro",
9749 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009750 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009751 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009752 [ALC885_MBP3] = "mbp3",
9753 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009754 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009755 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009756 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9757 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009758 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009759 [ALC883_TARGA_DIG] = "targa-dig",
9760 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009761 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009762 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009763 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009764 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009765 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009766 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009767 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009768 [ALC883_MEDION] = "medion",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009769 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009770 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009771 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009772 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9773 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009774 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009775 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009776 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009777 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009778 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309779 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009780 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009781 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009782 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009783 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009784 [ALC889A_INTEL] = "intel-alc889a",
9785 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009786 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009787 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009788 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009789 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009790};
9791
Takashi Iwai4953550a2009-06-30 15:28:30 +02009792static struct snd_pci_quirk alc882_cfg_tbl[] = {
9793 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9794
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009795 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009796 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009797 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009798 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9799 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009800 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009801 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9802 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009803 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009804 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009805 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9806 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009807 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9808 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009809 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9810 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009811 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009812 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009813 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009814 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009815 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9816 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009817 /* default Acer -- disabled as it causes more problems.
9818 * model=auto should work fine now
9819 */
9820 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009821
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009822 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009823
Tobin Davisfebe3372007-06-12 11:27:46 +02009824 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009825 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9826 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009827 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009828 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009829 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009830
9831 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9832 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9833 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009834 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009835 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9836 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9837 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009838 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009839 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009840 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009841 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009842
9843 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009844 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009845 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009846 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009847 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9848 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009849 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009850 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009851 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9852
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009853 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9854 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9855 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009856 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009857 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009858 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009859 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009860 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009861 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9862 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9863 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9864 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9865 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9866 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009867 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009868 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9869 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9870 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009871 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009872 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009873 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9874 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009875 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009876 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009877 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009878 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009879 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009880 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009881 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009882 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009883 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009884
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009885 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009886 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009887 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9888 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309889 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009890 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009891 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009892 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009893 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009894 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009895 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009896 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009897 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009898 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009899 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009900 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9901 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009902 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Takashi Iwai959973b2008-11-05 11:30:56 +01009903 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009904 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009905 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009906
Jiang zhe17bba1b2008-06-04 12:11:07 +02009907 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9908 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009909 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009910 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9911 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9912 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009913 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009914
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009915 {}
9916};
9917
Takashi Iwai4953550a2009-06-30 15:28:30 +02009918/* codec SSID table for Intel Mac */
9919static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9920 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9921 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9922 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9923 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9924 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9925 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9926 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009927 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009928 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009929 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009930 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009931 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9932 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9933 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009934 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009935 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +10009936 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009937 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9938 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009939 */
9940 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009941 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009942 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009943 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009944};
9945
Takashi Iwai4953550a2009-06-30 15:28:30 +02009946static struct alc_config_preset alc882_presets[] = {
9947 [ALC882_3ST_DIG] = {
9948 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009949 .init_verbs = { alc882_base_init_verbs,
9950 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009951 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9952 .dac_nids = alc882_dac_nids,
9953 .dig_out_nid = ALC882_DIGOUT_NID,
9954 .dig_in_nid = ALC882_DIGIN_NID,
9955 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9956 .channel_mode = alc882_ch_modes,
9957 .need_dac_fix = 1,
9958 .input_mux = &alc882_capture_source,
9959 },
9960 [ALC882_6ST_DIG] = {
9961 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009962 .init_verbs = { alc882_base_init_verbs,
9963 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009964 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9965 .dac_nids = alc882_dac_nids,
9966 .dig_out_nid = ALC882_DIGOUT_NID,
9967 .dig_in_nid = ALC882_DIGIN_NID,
9968 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9969 .channel_mode = alc882_sixstack_modes,
9970 .input_mux = &alc882_capture_source,
9971 },
9972 [ALC882_ARIMA] = {
9973 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009974 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9975 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009976 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9977 .dac_nids = alc882_dac_nids,
9978 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9979 .channel_mode = alc882_sixstack_modes,
9980 .input_mux = &alc882_capture_source,
9981 },
9982 [ALC882_W2JC] = {
9983 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009984 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9985 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009986 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9987 .dac_nids = alc882_dac_nids,
9988 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9989 .channel_mode = alc880_threestack_modes,
9990 .need_dac_fix = 1,
9991 .input_mux = &alc882_capture_source,
9992 .dig_out_nid = ALC882_DIGOUT_NID,
9993 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009994 [ALC885_MBA21] = {
9995 .mixers = { alc885_mba21_mixer },
9996 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9997 .num_dacs = 2,
9998 .dac_nids = alc882_dac_nids,
9999 .channel_mode = alc885_mba21_ch_modes,
10000 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10001 .input_mux = &alc882_capture_source,
10002 .unsol_event = alc_automute_amp_unsol_event,
10003 .setup = alc885_mba21_setup,
10004 .init_hook = alc_automute_amp,
10005 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010006 [ALC885_MBP3] = {
10007 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
10008 .init_verbs = { alc885_mbp3_init_verbs,
10009 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010010 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010011 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010012 .hp_nid = 0x04,
10013 .channel_mode = alc885_mbp_4ch_modes,
10014 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010015 .input_mux = &alc882_capture_source,
10016 .dig_out_nid = ALC882_DIGOUT_NID,
10017 .dig_in_nid = ALC882_DIGIN_NID,
10018 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010019 .setup = alc885_mbp3_setup,
10020 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010021 },
10022 [ALC885_MB5] = {
10023 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
10024 .init_verbs = { alc885_mb5_init_verbs,
10025 alc880_gpio1_init_verbs },
10026 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10027 .dac_nids = alc882_dac_nids,
10028 .channel_mode = alc885_mb5_6ch_modes,
10029 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
10030 .input_mux = &mb5_capture_source,
10031 .dig_out_nid = ALC882_DIGOUT_NID,
10032 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010033 .unsol_event = alc_automute_amp_unsol_event,
10034 .setup = alc885_mb5_setup,
10035 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010036 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010037 [ALC885_MACMINI3] = {
10038 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
10039 .init_verbs = { alc885_macmini3_init_verbs,
10040 alc880_gpio1_init_verbs },
10041 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10042 .dac_nids = alc882_dac_nids,
10043 .channel_mode = alc885_macmini3_6ch_modes,
10044 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
10045 .input_mux = &macmini3_capture_source,
10046 .dig_out_nid = ALC882_DIGOUT_NID,
10047 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010048 .unsol_event = alc_automute_amp_unsol_event,
10049 .setup = alc885_macmini3_setup,
10050 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010051 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010052 [ALC885_MACPRO] = {
10053 .mixers = { alc882_macpro_mixer },
10054 .init_verbs = { alc882_macpro_init_verbs },
10055 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10056 .dac_nids = alc882_dac_nids,
10057 .dig_out_nid = ALC882_DIGOUT_NID,
10058 .dig_in_nid = ALC882_DIGIN_NID,
10059 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10060 .channel_mode = alc882_ch_modes,
10061 .input_mux = &alc882_capture_source,
10062 .init_hook = alc885_macpro_init_hook,
10063 },
10064 [ALC885_IMAC24] = {
10065 .mixers = { alc885_imac24_mixer },
10066 .init_verbs = { alc885_imac24_init_verbs },
10067 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10068 .dac_nids = alc882_dac_nids,
10069 .dig_out_nid = ALC882_DIGOUT_NID,
10070 .dig_in_nid = ALC882_DIGIN_NID,
10071 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10072 .channel_mode = alc882_ch_modes,
10073 .input_mux = &alc882_capture_source,
10074 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010075 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010076 .init_hook = alc885_imac24_init_hook,
10077 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010078 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010079 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010080 .init_verbs = { alc885_imac91_init_verbs,
10081 alc880_gpio1_init_verbs },
10082 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10083 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010084 .channel_mode = alc885_mba21_ch_modes,
10085 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10086 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010087 .dig_out_nid = ALC882_DIGOUT_NID,
10088 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010089 .unsol_event = alc_automute_amp_unsol_event,
10090 .setup = alc885_imac91_setup,
10091 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010092 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010093 [ALC882_TARGA] = {
10094 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010095 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +020010096 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010097 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10098 .dac_nids = alc882_dac_nids,
10099 .dig_out_nid = ALC882_DIGOUT_NID,
10100 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10101 .adc_nids = alc882_adc_nids,
10102 .capsrc_nids = alc882_capsrc_nids,
10103 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10104 .channel_mode = alc882_3ST_6ch_modes,
10105 .need_dac_fix = 1,
10106 .input_mux = &alc882_capture_source,
10107 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010108 .setup = alc882_targa_setup,
10109 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010110 },
10111 [ALC882_ASUS_A7J] = {
10112 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010113 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10114 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010115 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10116 .dac_nids = alc882_dac_nids,
10117 .dig_out_nid = ALC882_DIGOUT_NID,
10118 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10119 .adc_nids = alc882_adc_nids,
10120 .capsrc_nids = alc882_capsrc_nids,
10121 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10122 .channel_mode = alc882_3ST_6ch_modes,
10123 .need_dac_fix = 1,
10124 .input_mux = &alc882_capture_source,
10125 },
10126 [ALC882_ASUS_A7M] = {
10127 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010128 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10129 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010130 alc882_asus_a7m_verbs },
10131 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10132 .dac_nids = alc882_dac_nids,
10133 .dig_out_nid = ALC882_DIGOUT_NID,
10134 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10135 .channel_mode = alc880_threestack_modes,
10136 .need_dac_fix = 1,
10137 .input_mux = &alc882_capture_source,
10138 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010139 [ALC883_3ST_2ch_DIG] = {
10140 .mixers = { alc883_3ST_2ch_mixer },
10141 .init_verbs = { alc883_init_verbs },
10142 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10143 .dac_nids = alc883_dac_nids,
10144 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010145 .dig_in_nid = ALC883_DIGIN_NID,
10146 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10147 .channel_mode = alc883_3ST_2ch_modes,
10148 .input_mux = &alc883_capture_source,
10149 },
10150 [ALC883_3ST_6ch_DIG] = {
10151 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10152 .init_verbs = { alc883_init_verbs },
10153 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10154 .dac_nids = alc883_dac_nids,
10155 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010156 .dig_in_nid = ALC883_DIGIN_NID,
10157 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10158 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010159 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010160 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010161 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010162 [ALC883_3ST_6ch] = {
10163 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10164 .init_verbs = { alc883_init_verbs },
10165 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10166 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010167 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10168 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010169 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010170 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010171 },
Jiang zhe17bba1b2008-06-04 12:11:07 +020010172 [ALC883_3ST_6ch_INTEL] = {
10173 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
10174 .init_verbs = { alc883_init_verbs },
10175 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10176 .dac_nids = alc883_dac_nids,
10177 .dig_out_nid = ALC883_DIGOUT_NID,
10178 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010179 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +020010180 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
10181 .channel_mode = alc883_3ST_6ch_intel_modes,
10182 .need_dac_fix = 1,
10183 .input_mux = &alc883_3stack_6ch_intel,
10184 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010185 [ALC889A_INTEL] = {
10186 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020010187 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
10188 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010189 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10190 .dac_nids = alc883_dac_nids,
10191 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10192 .adc_nids = alc889_adc_nids,
10193 .dig_out_nid = ALC883_DIGOUT_NID,
10194 .dig_in_nid = ALC883_DIGIN_NID,
10195 .slave_dig_outs = alc883_slave_dig_outs,
10196 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10197 .channel_mode = alc889_8ch_intel_modes,
10198 .capsrc_nids = alc889_capsrc_nids,
10199 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010200 .setup = alc889_automute_setup,
10201 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010202 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010203 .need_dac_fix = 1,
10204 },
10205 [ALC889_INTEL] = {
10206 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
10207 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010208 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010209 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10210 .dac_nids = alc883_dac_nids,
10211 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10212 .adc_nids = alc889_adc_nids,
10213 .dig_out_nid = ALC883_DIGOUT_NID,
10214 .dig_in_nid = ALC883_DIGIN_NID,
10215 .slave_dig_outs = alc883_slave_dig_outs,
10216 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10217 .channel_mode = alc889_8ch_intel_modes,
10218 .capsrc_nids = alc889_capsrc_nids,
10219 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010220 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010221 .init_hook = alc889_intel_init_hook,
10222 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010223 .need_dac_fix = 1,
10224 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010225 [ALC883_6ST_DIG] = {
10226 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10227 .init_verbs = { alc883_init_verbs },
10228 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10229 .dac_nids = alc883_dac_nids,
10230 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010231 .dig_in_nid = ALC883_DIGIN_NID,
10232 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10233 .channel_mode = alc883_sixstack_modes,
10234 .input_mux = &alc883_capture_source,
10235 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010236 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010237 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010238 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10239 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010240 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10241 .dac_nids = alc883_dac_nids,
10242 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010243 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10244 .channel_mode = alc883_3ST_6ch_modes,
10245 .need_dac_fix = 1,
10246 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010247 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010248 .setup = alc882_targa_setup,
10249 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010250 },
10251 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010252 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010253 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10254 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010255 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10256 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010257 .adc_nids = alc883_adc_nids_alt,
10258 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010259 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010260 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010261 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10262 .channel_mode = alc883_3ST_2ch_modes,
10263 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010264 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010265 .setup = alc882_targa_setup,
10266 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010267 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010268 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010269 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10270 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010271 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010272 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010273 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10274 .dac_nids = alc883_dac_nids,
10275 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10276 .adc_nids = alc883_adc_nids_rev,
10277 .capsrc_nids = alc883_capsrc_nids_rev,
10278 .dig_out_nid = ALC883_DIGOUT_NID,
10279 .dig_in_nid = ALC883_DIGIN_NID,
10280 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10281 .channel_mode = alc883_4ST_8ch_modes,
10282 .need_dac_fix = 1,
10283 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010284 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010285 .setup = alc882_targa_setup,
10286 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010287 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +020010288 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010289 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +020010290 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10291 * and the headphone jack. Turn this on and rely on the
10292 * standard mute methods whenever the user wants to turn
10293 * these outputs off.
10294 */
10295 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10296 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10297 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +020010298 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10299 .channel_mode = alc883_3ST_2ch_modes,
10300 .input_mux = &alc883_capture_source,
10301 },
Tobin Davis2880a862007-08-07 11:50:26 +020010302 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010303 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010304 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010305 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10306 .dac_nids = alc883_dac_nids,
10307 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010308 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10309 .channel_mode = alc883_3ST_2ch_modes,
10310 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010311 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010312 .setup = alc883_acer_aspire_setup,
10313 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010314 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010315 [ALC888_ACER_ASPIRE_4930G] = {
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +010010316 .mixers = { alc888_acer_aspire_4930g_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010317 alc883_chmode_mixer },
10318 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10319 alc888_acer_aspire_4930g_verbs },
10320 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10321 .dac_nids = alc883_dac_nids,
10322 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10323 .adc_nids = alc883_adc_nids_rev,
10324 .capsrc_nids = alc883_capsrc_nids_rev,
10325 .dig_out_nid = ALC883_DIGOUT_NID,
10326 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10327 .channel_mode = alc883_3ST_6ch_modes,
10328 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010329 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010330 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010331 ARRAY_SIZE(alc888_2_capture_sources),
10332 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010333 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010334 .setup = alc888_acer_aspire_4930g_setup,
10335 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010336 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010337 [ALC888_ACER_ASPIRE_6530G] = {
10338 .mixers = { alc888_acer_aspire_6530_mixer },
10339 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10340 alc888_acer_aspire_6530g_verbs },
10341 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10342 .dac_nids = alc883_dac_nids,
10343 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10344 .adc_nids = alc883_adc_nids_rev,
10345 .capsrc_nids = alc883_capsrc_nids_rev,
10346 .dig_out_nid = ALC883_DIGOUT_NID,
10347 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10348 .channel_mode = alc883_3ST_2ch_modes,
10349 .num_mux_defs =
10350 ARRAY_SIZE(alc888_2_capture_sources),
10351 .input_mux = alc888_acer_aspire_6530_sources,
10352 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010353 .setup = alc888_acer_aspire_6530g_setup,
10354 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010355 },
Hector Martin3b315d72009-06-02 10:54:19 +020010356 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010357 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010358 alc883_chmode_mixer },
10359 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010360 alc889_acer_aspire_8930g_verbs,
10361 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010362 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10363 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010364 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10365 .adc_nids = alc889_adc_nids,
10366 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010367 .dig_out_nid = ALC883_DIGOUT_NID,
10368 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10369 .channel_mode = alc883_3ST_6ch_modes,
10370 .need_dac_fix = 1,
10371 .const_channel_count = 6,
10372 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010373 ARRAY_SIZE(alc889_capture_sources),
10374 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +020010375 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010376 .setup = alc889_acer_aspire_8930g_setup,
10377 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +010010378#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010379 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010380#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010381 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010382 [ALC888_ACER_ASPIRE_7730G] = {
10383 .mixers = { alc883_3ST_6ch_mixer,
10384 alc883_chmode_mixer },
10385 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10386 alc888_acer_aspire_7730G_verbs },
10387 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10388 .dac_nids = alc883_dac_nids,
10389 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10390 .adc_nids = alc883_adc_nids_rev,
10391 .capsrc_nids = alc883_capsrc_nids_rev,
10392 .dig_out_nid = ALC883_DIGOUT_NID,
10393 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10394 .channel_mode = alc883_3ST_6ch_modes,
10395 .need_dac_fix = 1,
10396 .const_channel_count = 6,
10397 .input_mux = &alc883_capture_source,
10398 .unsol_event = alc_automute_amp_unsol_event,
Denis Kuplyakovd9477202010-11-24 06:01:09 +010010399 .setup = alc888_acer_aspire_7730g_setup,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010400 .init_hook = alc_automute_amp,
10401 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010402 [ALC883_MEDION] = {
10403 .mixers = { alc883_fivestack_mixer,
10404 alc883_chmode_mixer },
10405 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010406 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010407 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10408 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010409 .adc_nids = alc883_adc_nids_alt,
10410 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010411 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010412 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10413 .channel_mode = alc883_sixstack_modes,
10414 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010415 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010416 [ALC883_MEDION_WIM2160] = {
10417 .mixers = { alc883_medion_wim2160_mixer },
10418 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10419 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10420 .dac_nids = alc883_dac_nids,
10421 .dig_out_nid = ALC883_DIGOUT_NID,
10422 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10423 .adc_nids = alc883_adc_nids,
10424 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10425 .channel_mode = alc883_3ST_2ch_modes,
10426 .input_mux = &alc883_capture_source,
10427 .unsol_event = alc_automute_amp_unsol_event,
10428 .setup = alc883_medion_wim2160_setup,
10429 .init_hook = alc_automute_amp,
10430 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010431 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010432 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010433 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10434 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10435 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010436 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10437 .channel_mode = alc883_3ST_2ch_modes,
10438 .input_mux = &alc883_capture_source,
10439 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010440 [ALC883_CLEVO_M540R] = {
10441 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10442 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10443 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10444 .dac_nids = alc883_dac_nids,
10445 .dig_out_nid = ALC883_DIGOUT_NID,
10446 .dig_in_nid = ALC883_DIGIN_NID,
10447 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10448 .channel_mode = alc883_3ST_6ch_clevo_modes,
10449 .need_dac_fix = 1,
10450 .input_mux = &alc883_capture_source,
10451 /* This machine has the hardware HP auto-muting, thus
10452 * we need no software mute via unsol event
10453 */
10454 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010455 [ALC883_CLEVO_M720] = {
10456 .mixers = { alc883_clevo_m720_mixer },
10457 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010458 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10459 .dac_nids = alc883_dac_nids,
10460 .dig_out_nid = ALC883_DIGOUT_NID,
10461 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10462 .channel_mode = alc883_3ST_2ch_modes,
10463 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010464 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010465 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010466 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010467 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010468 [ALC883_LENOVO_101E_2ch] = {
10469 .mixers = { alc883_lenovo_101e_2ch_mixer},
10470 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10471 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10472 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010473 .adc_nids = alc883_adc_nids_alt,
10474 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010475 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010476 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10477 .channel_mode = alc883_3ST_2ch_modes,
10478 .input_mux = &alc883_lenovo_101e_capture_source,
10479 .unsol_event = alc883_lenovo_101e_unsol_event,
10480 .init_hook = alc883_lenovo_101e_all_automute,
10481 },
Kailang Yang272a5272007-05-14 11:00:38 +020010482 [ALC883_LENOVO_NB0763] = {
10483 .mixers = { alc883_lenovo_nb0763_mixer },
10484 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10485 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10486 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010487 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10488 .channel_mode = alc883_3ST_2ch_modes,
10489 .need_dac_fix = 1,
10490 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010491 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwaidc4271702010-11-29 07:42:59 +010010492 .setup = alc883_lenovo_nb0763_setup,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010493 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010494 },
10495 [ALC888_LENOVO_MS7195_DIG] = {
10496 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10497 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10498 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10499 .dac_nids = alc883_dac_nids,
10500 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010501 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10502 .channel_mode = alc883_3ST_6ch_modes,
10503 .need_dac_fix = 1,
10504 .input_mux = &alc883_capture_source,
10505 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10506 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010507 },
10508 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010509 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010510 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10511 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10512 .dac_nids = alc883_dac_nids,
10513 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010514 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10515 .channel_mode = alc883_3ST_2ch_modes,
10516 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010517 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010518 .setup = alc883_haier_w66_setup,
10519 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010520 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010521 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010522 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010523 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010524 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10525 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010526 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10527 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010528 .need_dac_fix = 1,
10529 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010530 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010531 .setup = alc888_3st_hp_setup,
10532 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010533 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010534 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010535 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010536 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10537 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10538 .dac_nids = alc883_dac_nids,
10539 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010540 .dig_in_nid = ALC883_DIGIN_NID,
10541 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10542 .channel_mode = alc883_sixstack_modes,
10543 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010544 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010545 .setup = alc888_6st_dell_setup,
10546 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010547 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010548 [ALC883_MITAC] = {
10549 .mixers = { alc883_mitac_mixer },
10550 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10551 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10552 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010553 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10554 .channel_mode = alc883_3ST_2ch_modes,
10555 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010556 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010557 .setup = alc883_mitac_setup,
10558 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010559 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010560 [ALC883_FUJITSU_PI2515] = {
10561 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10562 .init_verbs = { alc883_init_verbs,
10563 alc883_2ch_fujitsu_pi2515_verbs},
10564 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10565 .dac_nids = alc883_dac_nids,
10566 .dig_out_nid = ALC883_DIGOUT_NID,
10567 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10568 .channel_mode = alc883_3ST_2ch_modes,
10569 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010570 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010571 .setup = alc883_2ch_fujitsu_pi2515_setup,
10572 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010573 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010574 [ALC888_FUJITSU_XA3530] = {
10575 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10576 .init_verbs = { alc883_init_verbs,
10577 alc888_fujitsu_xa3530_verbs },
10578 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10579 .dac_nids = alc883_dac_nids,
10580 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10581 .adc_nids = alc883_adc_nids_rev,
10582 .capsrc_nids = alc883_capsrc_nids_rev,
10583 .dig_out_nid = ALC883_DIGOUT_NID,
10584 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10585 .channel_mode = alc888_4ST_8ch_intel_modes,
10586 .num_mux_defs =
10587 ARRAY_SIZE(alc888_2_capture_sources),
10588 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010589 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010590 .setup = alc888_fujitsu_xa3530_setup,
10591 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010592 },
Kailang Yange2757d52008-08-26 13:17:46 +020010593 [ALC888_LENOVO_SKY] = {
10594 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10595 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10596 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10597 .dac_nids = alc883_dac_nids,
10598 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010599 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10600 .channel_mode = alc883_sixstack_modes,
10601 .need_dac_fix = 1,
10602 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010603 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010604 .setup = alc888_lenovo_sky_setup,
10605 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010606 },
10607 [ALC888_ASUS_M90V] = {
10608 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10609 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10610 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10611 .dac_nids = alc883_dac_nids,
10612 .dig_out_nid = ALC883_DIGOUT_NID,
10613 .dig_in_nid = ALC883_DIGIN_NID,
10614 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10615 .channel_mode = alc883_3ST_6ch_modes,
10616 .need_dac_fix = 1,
10617 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010618 .unsol_event = alc_sku_unsol_event,
10619 .setup = alc883_mode2_setup,
10620 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010621 },
10622 [ALC888_ASUS_EEE1601] = {
10623 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010624 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010625 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10626 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10627 .dac_nids = alc883_dac_nids,
10628 .dig_out_nid = ALC883_DIGOUT_NID,
10629 .dig_in_nid = ALC883_DIGIN_NID,
10630 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10631 .channel_mode = alc883_3ST_2ch_modes,
10632 .need_dac_fix = 1,
10633 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010634 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010635 .init_hook = alc883_eee1601_inithook,
10636 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010637 [ALC1200_ASUS_P5Q] = {
10638 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10639 .init_verbs = { alc883_init_verbs },
10640 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10641 .dac_nids = alc883_dac_nids,
10642 .dig_out_nid = ALC1200_DIGOUT_NID,
10643 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010644 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010645 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10646 .channel_mode = alc883_sixstack_modes,
10647 .input_mux = &alc883_capture_source,
10648 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010649 [ALC889A_MB31] = {
10650 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10651 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10652 alc880_gpio1_init_verbs },
10653 .adc_nids = alc883_adc_nids,
10654 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010655 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010656 .dac_nids = alc883_dac_nids,
10657 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10658 .channel_mode = alc889A_mb31_6ch_modes,
10659 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10660 .input_mux = &alc889A_mb31_capture_source,
10661 .dig_out_nid = ALC883_DIGOUT_NID,
10662 .unsol_event = alc889A_mb31_unsol_event,
10663 .init_hook = alc889A_mb31_automute,
10664 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010665 [ALC883_SONY_VAIO_TT] = {
10666 .mixers = { alc883_vaiott_mixer },
10667 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10668 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10669 .dac_nids = alc883_dac_nids,
10670 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10671 .channel_mode = alc883_3ST_2ch_modes,
10672 .input_mux = &alc883_capture_source,
10673 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010674 .setup = alc883_vaiott_setup,
10675 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010676 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010677};
10678
10679
10680/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010681 * Pin config fixes
10682 */
10683enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010684 PINFIX_ABIT_AW9D_MAX,
David Henningsson32eea382011-03-04 13:37:50 +010010685 PINFIX_LENOVO_Y530,
Takashi Iwai954a29c2010-07-30 10:55:44 +020010686 PINFIX_PB_M5210,
David Henningssonc3d226a2010-10-14 15:42:08 +020010687 PINFIX_ACER_ASPIRE_7736,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010688};
10689
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010690static const struct alc_fixup alc882_fixups[] = {
10691 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010692 .type = ALC_FIXUP_PINS,
10693 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020010694 { 0x15, 0x01080104 }, /* side */
10695 { 0x16, 0x01011012 }, /* rear */
10696 { 0x17, 0x01016011 }, /* clfe */
10697 { }
10698 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010699 },
David Henningsson32eea382011-03-04 13:37:50 +010010700 [PINFIX_LENOVO_Y530] = {
10701 .type = ALC_FIXUP_PINS,
10702 .v.pins = (const struct alc_pincfg[]) {
10703 { 0x15, 0x99130112 }, /* rear int speakers */
10704 { 0x16, 0x99130111 }, /* subwoofer */
10705 { }
10706 }
10707 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010708 [PINFIX_PB_M5210] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010709 .type = ALC_FIXUP_VERBS,
10710 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020010711 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10712 {}
10713 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020010714 },
David Henningssonc3d226a2010-10-14 15:42:08 +020010715 [PINFIX_ACER_ASPIRE_7736] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010716 .type = ALC_FIXUP_SKU,
10717 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonc3d226a2010-10-14 15:42:08 +020010718 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010719};
10720
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010721static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010722 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
David Henningsson32eea382011-03-04 13:37:50 +010010723 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", PINFIX_LENOVO_Y530),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010724 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
David Henningssonc3d226a2010-10-14 15:42:08 +020010725 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010726 {}
10727};
10728
10729/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010730 * BIOS auto configuration
10731 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010732static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10733 const struct auto_pin_cfg *cfg)
10734{
10735 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10736}
10737
Takashi Iwai4953550a2009-06-30 15:28:30 +020010738static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010739 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010740 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010741{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010742 int idx;
10743
Takashi Iwai489008c2010-04-07 09:06:00 +020010744 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010745 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010746
Takashi Iwai489008c2010-04-07 09:06:00 +020010747 if (dac == 0x25)
10748 idx = 4;
10749 else if (dac >= 0x02 && dac <= 0x05)
10750 idx = dac - 2;
10751 else
10752 return;
10753 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010754}
10755
Takashi Iwai4953550a2009-06-30 15:28:30 +020010756static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010757{
10758 struct alc_spec *spec = codec->spec;
10759 int i;
10760
10761 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010762 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010763 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010764 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010765 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010766 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010767 }
10768}
10769
Takashi Iwai4953550a2009-06-30 15:28:30 +020010770static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010771{
10772 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010773 hda_nid_t pin, dac;
Takashi Iwai5855fb82010-09-16 18:24:02 +020010774 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010775
David Henningsson0a3fabe2011-03-04 16:54:52 +010010776 if (spec->autocfg.line_out_type != AUTO_PIN_HP_OUT) {
10777 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
10778 pin = spec->autocfg.hp_pins[i];
10779 if (!pin)
10780 break;
10781 dac = spec->multiout.hp_nid;
10782 if (!dac)
10783 dac = spec->multiout.dac_nids[0]; /* to front */
10784 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10785 }
Takashi Iwai489008c2010-04-07 09:06:00 +020010786 }
David Henningsson0a3fabe2011-03-04 16:54:52 +010010787
10788 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT) {
10789 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
10790 pin = spec->autocfg.speaker_pins[i];
10791 if (!pin)
10792 break;
10793 dac = spec->multiout.extra_out_nid[0];
10794 if (!dac)
10795 dac = spec->multiout.dac_nids[0]; /* to front */
10796 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10797 }
Takashi Iwai489008c2010-04-07 09:06:00 +020010798 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010799}
10800
Takashi Iwai4953550a2009-06-30 15:28:30 +020010801static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010802{
10803 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010804 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010805 int i;
10806
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010807 for (i = 0; i < cfg->num_inputs; i++) {
10808 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai30ea0982010-09-16 18:47:56 +020010809 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010810 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10811 snd_hda_codec_write(codec, nid, 0,
10812 AC_VERB_SET_AMP_GAIN_MUTE,
10813 AMP_OUT_MUTE);
10814 }
10815}
10816
10817static void alc882_auto_init_input_src(struct hda_codec *codec)
10818{
10819 struct alc_spec *spec = codec->spec;
10820 int c;
10821
10822 for (c = 0; c < spec->num_adc_nids; c++) {
10823 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10824 hda_nid_t nid = spec->capsrc_nids[c];
10825 unsigned int mux_idx;
10826 const struct hda_input_mux *imux;
10827 int conns, mute, idx, item;
10828
10829 conns = snd_hda_get_connections(codec, nid, conn_list,
10830 ARRAY_SIZE(conn_list));
10831 if (conns < 0)
10832 continue;
10833 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10834 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010835 if (!imux->num_items && mux_idx > 0)
10836 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010837 for (idx = 0; idx < conns; idx++) {
10838 /* if the current connection is the selected one,
10839 * unmute it as default - otherwise mute it
10840 */
10841 mute = AMP_IN_MUTE(idx);
10842 for (item = 0; item < imux->num_items; item++) {
10843 if (imux->items[item].index == idx) {
10844 if (spec->cur_mux[c] == item)
10845 mute = AMP_IN_UNMUTE(idx);
10846 break;
10847 }
10848 }
10849 /* check if we have a selector or mixer
10850 * we could check for the widget type instead, but
10851 * just check for Amp-In presence (in case of mixer
10852 * without amp-in there is something wrong, this
10853 * function shouldn't be used or capsrc nid is wrong)
10854 */
10855 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010856 snd_hda_codec_write(codec, nid, 0,
10857 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010858 mute);
10859 else if (mute != AMP_IN_MUTE(idx))
10860 snd_hda_codec_write(codec, nid, 0,
10861 AC_VERB_SET_CONNECT_SEL,
10862 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010863 }
10864 }
10865}
10866
Takashi Iwai4953550a2009-06-30 15:28:30 +020010867/* add mic boosts if needed */
10868static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010869{
10870 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010871 struct auto_pin_cfg *cfg = &spec->autocfg;
David Henningsson5322bf22011-01-05 11:03:56 +010010872 int i, err;
Takashi Iwai53e8c322010-12-17 15:23:41 +010010873 int type_idx = 0;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010874 hda_nid_t nid;
David Henningsson5322bf22011-01-05 11:03:56 +010010875 const char *prev_label = NULL;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010876
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010877 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020010878 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010879 break;
10880 nid = cfg->inputs[i].pin;
10881 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
David Henningsson5322bf22011-01-05 11:03:56 +010010882 const char *label;
10883 char boost_label[32];
10884
10885 label = hda_get_autocfg_input_label(codec, cfg, i);
10886 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai53e8c322010-12-17 15:23:41 +010010887 type_idx++;
10888 else
10889 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +010010890 prev_label = label;
10891
10892 snprintf(boost_label, sizeof(boost_label),
10893 "%s Boost Volume", label);
10894 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10895 boost_label, type_idx,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010896 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010897 if (err < 0)
10898 return err;
10899 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010900 }
10901 return 0;
10902}
10903
10904/* almost identical with ALC880 parser... */
10905static int alc882_parse_auto_config(struct hda_codec *codec)
10906{
10907 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010908 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020010909 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010910
Takashi Iwai05f5f472009-08-25 13:10:18 +020010911 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10912 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010913 if (err < 0)
10914 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010915 if (!spec->autocfg.line_outs)
10916 return 0; /* can't find valid BIOS pin config */
10917
10918 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10919 if (err < 0)
10920 return err;
Takashi Iwai569ed342011-01-19 10:14:46 +010010921 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010922 if (err < 0)
10923 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010924 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10925 "Headphone");
10926 if (err < 0)
10927 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010928 err = alc880_auto_create_extra_out(spec,
10929 spec->autocfg.speaker_pins[0],
10930 "Speaker");
10931 if (err < 0)
10932 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010933 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10934 if (err < 0)
10935 return err;
10936
10937 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10938
Takashi Iwai757899a2010-07-30 10:48:14 +020010939 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010940
10941 if (spec->kctls.list)
10942 add_mixer(spec, spec->kctls.list);
10943
10944 add_verb(spec, alc883_auto_init_verbs);
10945 /* if ADC 0x07 is available, initialize it, too */
10946 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10947 add_verb(spec, alc882_adc1_init_verbs);
10948
10949 spec->num_mux_defs = 1;
10950 spec->input_mux = &spec->private_imux[0];
10951
Kailang Yang6227cdc2010-02-25 08:36:52 +010010952 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010953
10954 err = alc_auto_add_mic_boost(codec);
10955 if (err < 0)
10956 return err;
10957
Takashi Iwai776e1842007-08-29 15:07:11 +020010958 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010959}
10960
10961/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010962static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010963{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010964 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010965 alc882_auto_init_multi_out(codec);
10966 alc882_auto_init_hp_out(codec);
10967 alc882_auto_init_analog_input(codec);
10968 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020010969 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010970 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010971 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010972}
10973
Takashi Iwai4953550a2009-06-30 15:28:30 +020010974static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010975{
10976 struct alc_spec *spec;
10977 int err, board_config;
10978
10979 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10980 if (spec == NULL)
10981 return -ENOMEM;
10982
10983 codec->spec = spec;
10984
Takashi Iwai4953550a2009-06-30 15:28:30 +020010985 switch (codec->vendor_id) {
10986 case 0x10ec0882:
10987 case 0x10ec0885:
10988 break;
10989 default:
10990 /* ALC883 and variants */
10991 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10992 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010993 }
10994
Takashi Iwai4953550a2009-06-30 15:28:30 +020010995 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10996 alc882_models,
10997 alc882_cfg_tbl);
10998
10999 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
11000 board_config = snd_hda_check_board_codec_sid_config(codec,
11001 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
11002
11003 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011004 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020011005 codec->chip_name);
11006 board_config = ALC882_AUTO;
11007 }
11008
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011009 if (board_config == ALC882_AUTO) {
11010 alc_pick_fixup(codec, NULL, alc882_fixup_tbl, alc882_fixups);
11011 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
11012 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011013
David Henningsson90622912010-10-14 14:50:18 +020011014 alc_auto_parse_customize_define(codec);
11015
Takashi Iwai4953550a2009-06-30 15:28:30 +020011016 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011017 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020011018 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011019 if (err < 0) {
11020 alc_free(codec);
11021 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011022 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011023 printk(KERN_INFO
11024 "hda_codec: Cannot set up configuration "
11025 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020011026 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011027 }
11028 }
11029
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011030 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020011031 err = snd_hda_attach_beep_device(codec, 0x1);
11032 if (err < 0) {
11033 alc_free(codec);
11034 return err;
11035 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011036 }
11037
Takashi Iwai4953550a2009-06-30 15:28:30 +020011038 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011039 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011040
Takashi Iwai4953550a2009-06-30 15:28:30 +020011041 spec->stream_analog_playback = &alc882_pcm_analog_playback;
11042 spec->stream_analog_capture = &alc882_pcm_analog_capture;
11043 /* FIXME: setup DAC5 */
11044 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
11045 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
11046
11047 spec->stream_digital_playback = &alc882_pcm_digital_playback;
11048 spec->stream_digital_capture = &alc882_pcm_digital_capture;
11049
Takashi Iwai4953550a2009-06-30 15:28:30 +020011050 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011051 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011052 spec->num_adc_nids = 0;
11053 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011054 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011055 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011056 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020011057 hda_nid_t nid = alc882_adc_nids[i];
11058 unsigned int wcap = get_wcaps(codec, nid);
11059 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011060 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020011061 if (wcap != AC_WID_AUD_IN)
11062 continue;
11063 spec->private_adc_nids[spec->num_adc_nids] = nid;
11064 err = snd_hda_get_connections(codec, nid, &cap, 1);
11065 if (err < 0)
11066 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011067 err = snd_hda_get_connections(codec, cap, items,
11068 ARRAY_SIZE(items));
11069 if (err < 0)
11070 continue;
11071 for (j = 0; j < imux->num_items; j++)
11072 if (imux->items[j].index >= err)
11073 break;
11074 if (j < imux->num_items)
11075 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011076 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
11077 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011078 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011079 spec->adc_nids = spec->private_adc_nids;
11080 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020011081 }
11082
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011083 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010011084
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011085 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010011086 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011087
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011088 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020011089
Takashi Iwai2134ea42008-01-10 16:53:55 +010011090 spec->vmaster_nid = 0x0c;
11091
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011092 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011093 if (board_config == ALC882_AUTO)
11094 spec->init_hook = alc882_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020011095
11096 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020011097#ifdef CONFIG_SND_HDA_POWER_SAVE
11098 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020011099 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011100#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011101
11102 return 0;
11103}
11104
Takashi Iwai4953550a2009-06-30 15:28:30 +020011105
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011106/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011107 * ALC262 support
11108 */
11109
11110#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
11111#define ALC262_DIGIN_NID ALC880_DIGIN_NID
11112
11113#define alc262_dac_nids alc260_dac_nids
11114#define alc262_adc_nids alc882_adc_nids
11115#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010011116#define alc262_capsrc_nids alc882_capsrc_nids
11117#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010011118
11119#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010011120#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010011121
Kailang Yang4e555fe2008-08-26 13:05:55 +020011122static hda_nid_t alc262_dmic_adc_nids[1] = {
11123 /* ADC0 */
11124 0x09
11125};
11126
11127static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
11128
Kailang Yangdf694da2005-12-05 19:42:22 +010011129static struct snd_kcontrol_new alc262_base_mixer[] = {
11130 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11131 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11132 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11133 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11134 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11135 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11136 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11137 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011138 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011139 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11140 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011141 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011142 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
11143 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11144 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
11145 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011146 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010011147};
11148
Takashi Iwaice875f02008-01-28 18:17:43 +010011149/* update HP, line and mono-out pins according to the master switch */
11150static void alc262_hp_master_update(struct hda_codec *codec)
11151{
11152 struct alc_spec *spec = codec->spec;
11153 int val = spec->master_sw;
11154
11155 /* HP & line-out */
11156 snd_hda_codec_write_cache(codec, 0x1b, 0,
11157 AC_VERB_SET_PIN_WIDGET_CONTROL,
11158 val ? PIN_HP : 0);
11159 snd_hda_codec_write_cache(codec, 0x15, 0,
11160 AC_VERB_SET_PIN_WIDGET_CONTROL,
11161 val ? PIN_HP : 0);
11162 /* mono (speaker) depending on the HP jack sense */
11163 val = val && !spec->jack_present;
11164 snd_hda_codec_write_cache(codec, 0x16, 0,
11165 AC_VERB_SET_PIN_WIDGET_CONTROL,
11166 val ? PIN_OUT : 0);
11167}
11168
11169static void alc262_hp_bpc_automute(struct hda_codec *codec)
11170{
11171 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011172
11173 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010011174 alc262_hp_master_update(codec);
11175}
11176
11177static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
11178{
11179 if ((res >> 26) != ALC880_HP_EVENT)
11180 return;
11181 alc262_hp_bpc_automute(codec);
11182}
11183
11184static void alc262_hp_wildwest_automute(struct hda_codec *codec)
11185{
11186 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011187
11188 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010011189 alc262_hp_master_update(codec);
11190}
11191
11192static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
11193 unsigned int res)
11194{
11195 if ((res >> 26) != ALC880_HP_EVENT)
11196 return;
11197 alc262_hp_wildwest_automute(codec);
11198}
11199
Takashi Iwaib72519b2009-05-08 14:31:55 +020011200#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010011201
11202static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
11203 struct snd_ctl_elem_value *ucontrol)
11204{
11205 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11206 struct alc_spec *spec = codec->spec;
11207 int val = !!*ucontrol->value.integer.value;
11208
11209 if (val == spec->master_sw)
11210 return 0;
11211 spec->master_sw = val;
11212 alc262_hp_master_update(codec);
11213 return 1;
11214}
11215
Takashi Iwaib72519b2009-05-08 14:31:55 +020011216#define ALC262_HP_MASTER_SWITCH \
11217 { \
11218 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11219 .name = "Master Playback Switch", \
11220 .info = snd_ctl_boolean_mono_info, \
11221 .get = alc262_hp_master_sw_get, \
11222 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011223 }, \
11224 { \
11225 .iface = NID_MAPPING, \
11226 .name = "Master Playback Switch", \
11227 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020011228 }
11229
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011230
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011231static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011232 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011233 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11234 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11235 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011236 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11237 HDA_OUTPUT),
11238 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11239 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011240 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11241 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011242 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011243 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11244 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011245 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011246 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11247 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11248 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11249 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011250 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
11251 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
11252 { } /* end */
11253};
11254
Kailang Yangcd7509a2007-01-26 18:33:17 +010011255static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011256 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010011257 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11258 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11259 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11260 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011261 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11262 HDA_OUTPUT),
11263 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11264 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011265 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11266 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011267 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011268 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11269 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11270 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11271 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011272 { } /* end */
11273};
11274
11275static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11276 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11277 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011278 HDA_CODEC_VOLUME("Rear Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011279 { } /* end */
11280};
11281
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011282/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011283static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011284{
11285 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011286
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011287 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011288 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011289}
11290
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011291static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011292 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11293 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011294 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11295 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11296 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11297 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011298 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011299 { } /* end */
11300};
11301
11302static struct hda_verb alc262_hp_t5735_verbs[] = {
11303 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11304 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11305
11306 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11307 { }
11308};
11309
Kailang Yang8c427222008-01-10 13:03:59 +010011310static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011311 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11312 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011313 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11314 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011315 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11316 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11317 { } /* end */
11318};
11319
11320static struct hda_verb alc262_hp_rp5700_verbs[] = {
11321 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11322 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11323 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11324 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11325 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11326 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11327 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11328 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11329 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11330 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11331 {}
11332};
11333
11334static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11335 .num_items = 1,
11336 .items = {
11337 { "Line", 0x1 },
11338 },
11339};
11340
Takashi Iwai42171c12009-05-08 14:11:43 +020011341/* bind hp and internal speaker mute (with plug check) as master switch */
11342static void alc262_hippo_master_update(struct hda_codec *codec)
11343{
11344 struct alc_spec *spec = codec->spec;
11345 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11346 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11347 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11348 unsigned int mute;
11349
11350 /* HP */
11351 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11352 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11353 HDA_AMP_MUTE, mute);
11354 /* mute internal speaker per jack sense */
11355 if (spec->jack_present)
11356 mute = HDA_AMP_MUTE;
11357 if (line_nid)
11358 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11359 HDA_AMP_MUTE, mute);
11360 if (speaker_nid && speaker_nid != line_nid)
11361 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11362 HDA_AMP_MUTE, mute);
11363}
11364
11365#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
11366
11367static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11368 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020011369{
11370 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020011371 struct alc_spec *spec = codec->spec;
11372 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011373
Takashi Iwai42171c12009-05-08 14:11:43 +020011374 if (val == spec->master_sw)
11375 return 0;
11376 spec->master_sw = val;
11377 alc262_hippo_master_update(codec);
11378 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011379}
Takashi Iwai5b319542007-07-26 11:49:22 +020011380
Takashi Iwai42171c12009-05-08 14:11:43 +020011381#define ALC262_HIPPO_MASTER_SWITCH \
11382 { \
11383 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11384 .name = "Master Playback Switch", \
11385 .info = snd_ctl_boolean_mono_info, \
11386 .get = alc262_hippo_master_sw_get, \
11387 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011388 }, \
11389 { \
11390 .iface = NID_MAPPING, \
11391 .name = "Master Playback Switch", \
11392 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11393 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011394 }
11395
11396static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11397 ALC262_HIPPO_MASTER_SWITCH,
11398 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11399 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11400 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11401 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11402 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11403 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11404 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011405 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011406 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11407 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011408 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011409 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11410 { } /* end */
11411};
11412
11413static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11414 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11415 ALC262_HIPPO_MASTER_SWITCH,
11416 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11417 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11418 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11419 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11420 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11421 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011422 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011423 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11424 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011425 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011426 { } /* end */
11427};
11428
11429/* mute/unmute internal speaker according to the hp jack and mute state */
11430static void alc262_hippo_automute(struct hda_codec *codec)
11431{
11432 struct alc_spec *spec = codec->spec;
11433 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020011434
Wu Fengguang864f92b2009-11-18 12:38:02 +080011435 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020011436 alc262_hippo_master_update(codec);
11437}
11438
11439static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11440{
11441 if ((res >> 26) != ALC880_HP_EVENT)
11442 return;
11443 alc262_hippo_automute(codec);
11444}
11445
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011446static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011447{
11448 struct alc_spec *spec = codec->spec;
11449
11450 spec->autocfg.hp_pins[0] = 0x15;
11451 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011452}
11453
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011454static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011455{
11456 struct alc_spec *spec = codec->spec;
11457
11458 spec->autocfg.hp_pins[0] = 0x1b;
11459 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011460}
11461
11462
Kailang Yang272a5272007-05-14 11:00:38 +020011463static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011464 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011465 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011466 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11467 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11468 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11469 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11470 { } /* end */
11471};
11472
Kailang Yang83c34212007-07-05 11:43:05 +020011473static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011474 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11475 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011476 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11477 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11478 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11479 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11480 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11481 { } /* end */
11482};
Kailang Yang272a5272007-05-14 11:00:38 +020011483
Tony Vroonba340e82009-02-02 19:01:30 +000011484static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11485 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11486 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11487 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11488 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11489 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11490 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11491 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11492 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011493 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011494 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11495 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011496 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011497 { } /* end */
11498};
11499
11500static struct hda_verb alc262_tyan_verbs[] = {
11501 /* Headphone automute */
11502 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11503 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11504 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11505
11506 /* P11 AUX_IN, white 4-pin connector */
11507 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11508 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11509 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11510 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11511
11512 {}
11513};
11514
11515/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011516static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011517{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011518 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011519
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011520 spec->autocfg.hp_pins[0] = 0x1b;
11521 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011522}
11523
Tony Vroonba340e82009-02-02 19:01:30 +000011524
Kailang Yangdf694da2005-12-05 19:42:22 +010011525#define alc262_capture_mixer alc882_capture_mixer
11526#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11527
11528/*
11529 * generic initialization of ADC, input mixers and output mixers
11530 */
11531static struct hda_verb alc262_init_verbs[] = {
11532 /*
11533 * Unmute ADC0-2 and set the default input to mic-in
11534 */
11535 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11536 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11537 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11538 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11539 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11540 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11541
Takashi Iwaicb53c622007-08-10 17:21:45 +020011542 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011543 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011544 * Note: PASD motherboards uses the Line In 2 as the input for
11545 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011546 */
11547 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011548 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11549 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11550 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11551 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11552 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011553
11554 /*
11555 * Set up output mixers (0x0c - 0x0e)
11556 */
11557 /* set vol=0 to output mixers */
11558 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11559 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11560 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11561 /* set up input amps for analog loopback */
11562 /* Amp Indices: DAC = 0, mixer = 1 */
11563 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11564 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11565 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11566 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11567 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11568 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11569
11570 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11571 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11572 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11573 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11574 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11575 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11576
11577 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11578 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11579 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11580 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11581 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011582
Kailang Yangdf694da2005-12-05 19:42:22 +010011583 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11584 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011585
Kailang Yangdf694da2005-12-05 19:42:22 +010011586 /* FIXME: use matrix-type input source selection */
11587 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11588 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11589 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11590 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11591 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11592 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11593 /* Input mixer2 */
11594 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11595 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11596 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11597 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11598 /* Input mixer3 */
11599 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11600 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11601 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011602 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011603
11604 { }
11605};
11606
Kailang Yang4e555fe2008-08-26 13:05:55 +020011607static struct hda_verb alc262_eapd_verbs[] = {
11608 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11609 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11610 { }
11611};
11612
Kailang Yangccc656c2006-10-17 12:32:26 +020011613static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11614 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11615 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11616 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11617
11618 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11619 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11620 {}
11621};
11622
Kailang Yang272a5272007-05-14 11:00:38 +020011623static struct hda_verb alc262_sony_unsol_verbs[] = {
11624 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11625 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11626 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11627
11628 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11629 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011630 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011631};
11632
Kailang Yang4e555fe2008-08-26 13:05:55 +020011633static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11634 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11635 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11636 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11637 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11638 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011639 { } /* end */
11640};
11641
11642static struct hda_verb alc262_toshiba_s06_verbs[] = {
11643 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11644 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11645 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11646 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11647 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11648 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11649 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11650 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11651 {}
11652};
11653
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011654static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011655{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011656 struct alc_spec *spec = codec->spec;
11657
11658 spec->autocfg.hp_pins[0] = 0x15;
11659 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011660 spec->ext_mic.pin = 0x18;
11661 spec->ext_mic.mux_idx = 0;
11662 spec->int_mic.pin = 0x12;
11663 spec->int_mic.mux_idx = 9;
11664 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011665}
11666
Takashi Iwai834be882006-03-01 14:16:17 +010011667/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011668 * nec model
11669 * 0x15 = headphone
11670 * 0x16 = internal speaker
11671 * 0x18 = external mic
11672 */
11673
11674static struct snd_kcontrol_new alc262_nec_mixer[] = {
11675 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11676 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11677
11678 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11679 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011680 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011681
11682 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11683 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11684 { } /* end */
11685};
11686
11687static struct hda_verb alc262_nec_verbs[] = {
11688 /* Unmute Speaker */
11689 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11690
11691 /* Headphone */
11692 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11693 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11694
11695 /* External mic to headphone */
11696 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11697 /* External mic to speaker */
11698 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11699 {}
11700};
11701
11702/*
Takashi Iwai834be882006-03-01 14:16:17 +010011703 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011704 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11705 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011706 */
11707
11708#define ALC_HP_EVENT 0x37
11709
11710static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11711 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11712 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011713 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11714 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011715 {}
11716};
11717
Jiang zhe0e31daf2008-03-20 12:12:39 +010011718static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11719 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11720 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11721 {}
11722};
11723
Daniel T Chene2595322009-12-19 18:19:02 -050011724static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11725 /* Front Mic pin: input vref at 50% */
11726 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11727 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11728 {}
11729};
11730
Takashi Iwai834be882006-03-01 14:16:17 +010011731static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011732 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011733 .items = {
11734 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010011735 { "Internal Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011736 { "CD", 0x4 },
11737 },
11738};
11739
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011740static struct hda_input_mux alc262_HP_capture_source = {
11741 .num_items = 5,
11742 .items = {
11743 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011744 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011745 { "Line", 0x2 },
11746 { "CD", 0x4 },
11747 { "AUX IN", 0x6 },
11748 },
11749};
11750
zhejiangaccbe492007-08-31 12:36:05 +020011751static struct hda_input_mux alc262_HP_D7000_capture_source = {
11752 .num_items = 4,
11753 .items = {
11754 { "Mic", 0x0 },
11755 { "Front Mic", 0x2 },
11756 { "Line", 0x1 },
11757 { "CD", 0x4 },
11758 },
11759};
11760
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011761/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011762static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11763{
11764 struct alc_spec *spec = codec->spec;
11765 unsigned int mute;
11766
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011767 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011768 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11769 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011770 spec->sense_updated = 1;
11771 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011772 /* unmute internal speaker only if both HPs are unplugged and
11773 * master switch is on
11774 */
11775 if (spec->jack_present)
11776 mute = HDA_AMP_MUTE;
11777 else
Takashi Iwai834be882006-03-01 14:16:17 +010011778 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011779 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11780 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011781}
11782
11783/* unsolicited event for HP jack sensing */
11784static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11785 unsigned int res)
11786{
11787 if ((res >> 26) != ALC_HP_EVENT)
11788 return;
11789 alc262_fujitsu_automute(codec, 1);
11790}
11791
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011792static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11793{
11794 alc262_fujitsu_automute(codec, 1);
11795}
11796
Takashi Iwai834be882006-03-01 14:16:17 +010011797/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011798static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11799 .ops = &snd_hda_bind_vol,
11800 .values = {
11801 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11802 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11803 0
11804 },
11805};
Takashi Iwai834be882006-03-01 14:16:17 +010011806
Jiang zhe0e31daf2008-03-20 12:12:39 +010011807/* mute/unmute internal speaker according to the hp jack and mute state */
11808static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11809{
11810 struct alc_spec *spec = codec->spec;
11811 unsigned int mute;
11812
11813 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011814 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011815 spec->sense_updated = 1;
11816 }
11817 if (spec->jack_present) {
11818 /* mute internal speaker */
11819 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11820 HDA_AMP_MUTE, HDA_AMP_MUTE);
11821 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11822 HDA_AMP_MUTE, HDA_AMP_MUTE);
11823 } else {
11824 /* unmute internal speaker if necessary */
11825 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11826 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11827 HDA_AMP_MUTE, mute);
11828 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11829 HDA_AMP_MUTE, mute);
11830 }
11831}
11832
11833/* unsolicited event for HP jack sensing */
11834static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11835 unsigned int res)
11836{
11837 if ((res >> 26) != ALC_HP_EVENT)
11838 return;
11839 alc262_lenovo_3000_automute(codec, 1);
11840}
11841
Takashi Iwai8de56b72009-07-24 16:51:47 +020011842static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11843 int dir, int idx, long *valp)
11844{
11845 int i, change = 0;
11846
11847 for (i = 0; i < 2; i++, valp++)
11848 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11849 HDA_AMP_MUTE,
11850 *valp ? 0 : HDA_AMP_MUTE);
11851 return change;
11852}
11853
Takashi Iwai834be882006-03-01 14:16:17 +010011854/* bind hp and internal speaker mute (with plug check) */
11855static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11856 struct snd_ctl_elem_value *ucontrol)
11857{
11858 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11859 long *valp = ucontrol->value.integer.value;
11860 int change;
11861
Takashi Iwai8de56b72009-07-24 16:51:47 +020011862 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11863 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011864 if (change)
11865 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011866 return change;
11867}
11868
11869static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011870 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011871 {
11872 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11873 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011874 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011875 .info = snd_hda_mixer_amp_switch_info,
11876 .get = snd_hda_mixer_amp_switch_get,
11877 .put = alc262_fujitsu_master_sw_put,
11878 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11879 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011880 {
11881 .iface = NID_MAPPING,
11882 .name = "Master Playback Switch",
11883 .private_value = 0x1b,
11884 },
Takashi Iwai834be882006-03-01 14:16:17 +010011885 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11886 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011887 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011888 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11889 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011890 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010011891 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11892 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011893 { } /* end */
11894};
11895
Jiang zhe0e31daf2008-03-20 12:12:39 +010011896/* bind hp and internal speaker mute (with plug check) */
11897static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11898 struct snd_ctl_elem_value *ucontrol)
11899{
11900 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11901 long *valp = ucontrol->value.integer.value;
11902 int change;
11903
Takashi Iwai8de56b72009-07-24 16:51:47 +020011904 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011905 if (change)
11906 alc262_lenovo_3000_automute(codec, 0);
11907 return change;
11908}
11909
11910static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11911 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11912 {
11913 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11914 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011915 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011916 .info = snd_hda_mixer_amp_switch_info,
11917 .get = snd_hda_mixer_amp_switch_get,
11918 .put = alc262_lenovo_3000_master_sw_put,
11919 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11920 },
11921 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11922 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011923 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011924 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11925 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011926 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010011927 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11928 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011929 { } /* end */
11930};
11931
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011932static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11933 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011934 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11936 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011937 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011938 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11939 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011940 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011941 { } /* end */
11942};
11943
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011944/* additional init verbs for Benq laptops */
11945static struct hda_verb alc262_EAPD_verbs[] = {
11946 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11947 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11948 {}
11949};
11950
Kailang Yang83c34212007-07-05 11:43:05 +020011951static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11952 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11953 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11954
11955 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11956 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11957 {}
11958};
11959
Tobin Davisf651b502007-10-26 12:40:47 +020011960/* Samsung Q1 Ultra Vista model setup */
11961static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011962 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11963 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011964 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11965 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011966 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
11967 HDA_CODEC_VOLUME("Headphone Mic Boost Volume", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011968 { } /* end */
11969};
11970
11971static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011972 /* output mixer */
11973 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11974 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11975 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11976 /* speaker */
11977 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11978 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11979 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11980 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11981 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011982 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011983 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11984 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11985 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11986 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11987 /* internal mic */
11988 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11989 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11990 /* ADC, choose mic */
11991 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11992 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11993 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11994 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11995 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11996 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11997 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11998 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11999 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
12000 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020012001 {}
12002};
12003
Tobin Davisf651b502007-10-26 12:40:47 +020012004/* mute/unmute internal speaker according to the hp jack and mute state */
12005static void alc262_ultra_automute(struct hda_codec *codec)
12006{
12007 struct alc_spec *spec = codec->spec;
12008 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020012009
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012010 mute = 0;
12011 /* auto-mute only when HP is used as HP */
12012 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012013 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012014 if (spec->jack_present)
12015 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020012016 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012017 /* mute/unmute internal speaker */
12018 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12019 HDA_AMP_MUTE, mute);
12020 /* mute/unmute HP */
12021 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12022 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020012023}
12024
12025/* unsolicited event for HP jack sensing */
12026static void alc262_ultra_unsol_event(struct hda_codec *codec,
12027 unsigned int res)
12028{
12029 if ((res >> 26) != ALC880_HP_EVENT)
12030 return;
12031 alc262_ultra_automute(codec);
12032}
12033
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012034static struct hda_input_mux alc262_ultra_capture_source = {
12035 .num_items = 2,
12036 .items = {
12037 { "Mic", 0x1 },
12038 { "Headphone", 0x7 },
12039 },
12040};
12041
12042static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
12043 struct snd_ctl_elem_value *ucontrol)
12044{
12045 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12046 struct alc_spec *spec = codec->spec;
12047 int ret;
12048
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012049 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012050 if (!ret)
12051 return 0;
12052 /* reprogram the HP pin as mic or HP according to the input source */
12053 snd_hda_codec_write_cache(codec, 0x15, 0,
12054 AC_VERB_SET_PIN_WIDGET_CONTROL,
12055 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
12056 alc262_ultra_automute(codec); /* mute/unmute HP */
12057 return ret;
12058}
12059
12060static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
12061 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
12062 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
12063 {
12064 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12065 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012066 .info = alc_mux_enum_info,
12067 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012068 .put = alc262_ultra_mux_enum_put,
12069 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010012070 {
12071 .iface = NID_MAPPING,
12072 .name = "Capture Source",
12073 .private_value = 0x15,
12074 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012075 { } /* end */
12076};
12077
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012078/* We use two mixers depending on the output pin; 0x16 is a mono output
12079 * and thus it's bound with a different mixer.
12080 * This function returns which mixer amp should be used.
12081 */
12082static int alc262_check_volbit(hda_nid_t nid)
12083{
12084 if (!nid)
12085 return 0;
12086 else if (nid == 0x16)
12087 return 2;
12088 else
12089 return 1;
12090}
12091
12092static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012093 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012094{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012095 unsigned long val;
12096 int vbit;
12097
12098 vbit = alc262_check_volbit(nid);
12099 if (!vbit)
12100 return 0;
12101 if (*vbits & vbit) /* a volume control for this mixer already there */
12102 return 0;
12103 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012104 if (vbit == 2)
12105 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
12106 else
12107 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012108 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012109}
12110
12111static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012112 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012113{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012114 unsigned long val;
12115
12116 if (!nid)
12117 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012118 if (nid == 0x16)
12119 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
12120 else
12121 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012122 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012123}
12124
Kailang Yangdf694da2005-12-05 19:42:22 +010012125/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012126static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
12127 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012128{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012129 const char *pfx;
12130 int vbits;
Takashi Iwai033688a2010-09-08 15:47:09 +020012131 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010012132
12133 spec->multiout.num_dacs = 1; /* only use one dac */
12134 spec->multiout.dac_nids = spec->private_dac_nids;
12135 spec->multiout.dac_nids[0] = 2;
12136
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010012137 pfx = alc_get_line_out_pfx(cfg, true);
12138 if (!pfx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012139 pfx = "Front";
Takashi Iwai033688a2010-09-08 15:47:09 +020012140 for (i = 0; i < 2; i++) {
12141 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
12142 if (err < 0)
12143 return err;
12144 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12145 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
12146 "Speaker", i);
12147 if (err < 0)
12148 return err;
12149 }
12150 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12151 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
12152 "Headphone", i);
12153 if (err < 0)
12154 return err;
12155 }
12156 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012157
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012158 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
12159 alc262_check_volbit(cfg->speaker_pins[0]) |
12160 alc262_check_volbit(cfg->hp_pins[0]);
12161 if (vbits == 1 || vbits == 2)
12162 pfx = "Master"; /* only one mixer is used */
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012163 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020012164 for (i = 0; i < 2; i++) {
12165 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
12166 &vbits, i);
12167 if (err < 0)
12168 return err;
12169 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12170 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
12171 "Speaker", &vbits, i);
12172 if (err < 0)
12173 return err;
12174 }
12175 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12176 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
12177 "Headphone", &vbits, i);
12178 if (err < 0)
12179 return err;
12180 }
12181 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012182 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010012183}
12184
Takashi Iwai05f5f472009-08-25 13:10:18 +020012185#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010012186 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010012187
12188/*
12189 * generic initialization of ADC, input mixers and output mixers
12190 */
12191static struct hda_verb alc262_volume_init_verbs[] = {
12192 /*
12193 * Unmute ADC0-2 and set the default input to mic-in
12194 */
12195 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12196 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12197 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12198 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12199 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12200 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12201
Takashi Iwaicb53c622007-08-10 17:21:45 +020012202 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010012203 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012204 * Note: PASD motherboards uses the Line In 2 as the input for
12205 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010012206 */
12207 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012208 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12209 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12210 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12211 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12212 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012213
12214 /*
12215 * Set up output mixers (0x0c - 0x0f)
12216 */
12217 /* set vol=0 to output mixers */
12218 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12219 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12220 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020012221
Kailang Yangdf694da2005-12-05 19:42:22 +010012222 /* set up input amps for analog loopback */
12223 /* Amp Indices: DAC = 0, mixer = 1 */
12224 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12225 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12226 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12227 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12228 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12229 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12230
12231 /* FIXME: use matrix-type input source selection */
12232 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12233 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12234 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12235 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12236 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12237 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12238 /* Input mixer2 */
12239 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12240 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12241 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12242 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12243 /* Input mixer3 */
12244 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12245 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12246 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12247 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12248
12249 { }
12250};
12251
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012252static struct hda_verb alc262_HP_BPC_init_verbs[] = {
12253 /*
12254 * Unmute ADC0-2 and set the default input to mic-in
12255 */
12256 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12257 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12258 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12259 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12260 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12261 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12262
Takashi Iwaicb53c622007-08-10 17:21:45 +020012263 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012264 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012265 * Note: PASD motherboards uses the Line In 2 as the input for
12266 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012267 */
12268 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012269 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12270 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12271 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12272 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12273 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12274 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12275 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012276
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012277 /*
12278 * Set up output mixers (0x0c - 0x0e)
12279 */
12280 /* set vol=0 to output mixers */
12281 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12282 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12283 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12284
12285 /* set up input amps for analog loopback */
12286 /* Amp Indices: DAC = 0, mixer = 1 */
12287 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12288 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12289 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12290 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12291 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12292 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12293
Takashi Iwaice875f02008-01-28 18:17:43 +010012294 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012295 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12296 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12297
12298 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12299 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12300
12301 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12302 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12303
12304 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12305 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12306 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12307 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12308 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12309
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012310 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012311 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12312 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012313 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012314 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12315 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12316
12317
12318 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012319 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12320 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012321 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012322 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12323 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12324 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12325 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12326 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12327 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12328 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12329 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012330 /* Input mixer2 */
12331 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012332 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12333 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12334 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12335 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12336 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12337 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12338 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12339 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012340 /* Input mixer3 */
12341 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012342 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12343 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12344 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12345 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12346 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12347 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12348 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12349 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012350
Takashi Iwaice875f02008-01-28 18:17:43 +010012351 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12352
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012353 { }
12354};
12355
Kailang Yangcd7509a2007-01-26 18:33:17 +010012356static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12357 /*
12358 * Unmute ADC0-2 and set the default input to mic-in
12359 */
12360 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12361 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12362 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12363 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12364 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12365 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12366
Takashi Iwaicb53c622007-08-10 17:21:45 +020012367 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012368 * mixer widget
12369 * Note: PASD motherboards uses the Line In 2 as the input for front
12370 * panel mic (mic 2)
12371 */
12372 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012373 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12374 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12375 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12376 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12377 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12378 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12379 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12380 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012381 /*
12382 * Set up output mixers (0x0c - 0x0e)
12383 */
12384 /* set vol=0 to output mixers */
12385 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12386 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12387 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12388
12389 /* set up input amps for analog loopback */
12390 /* Amp Indices: DAC = 0, mixer = 1 */
12391 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12392 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12393 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12394 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12395 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12396 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12397
12398
12399 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12400 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12401 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12402 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12403 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12404 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12405 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12406
12407 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12408 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12409
12410 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12411 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12412
12413 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12414 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12415 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12416 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12417 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12418 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12419
12420 /* FIXME: use matrix-type input source selection */
12421 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12422 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12423 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12424 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12425 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12426 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12427 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12428 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12429 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12430 /* Input mixer2 */
12431 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12432 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12433 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12434 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12435 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12436 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12437 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12438 /* Input mixer3 */
12439 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12440 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12441 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12442 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12443 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12444 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12445 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12446
Takashi Iwaice875f02008-01-28 18:17:43 +010012447 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12448
Kailang Yangcd7509a2007-01-26 18:33:17 +010012449 { }
12450};
12451
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012452static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12453
12454 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12455 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12456 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12457
12458 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12459 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12460 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12461 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12462
12463 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12464 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12465 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12466 {}
12467};
12468
Takashi Iwai18675e42010-09-08 15:55:44 +020012469/*
12470 * Pin config fixes
12471 */
12472enum {
12473 PINFIX_FSC_H270,
12474};
12475
12476static const struct alc_fixup alc262_fixups[] = {
12477 [PINFIX_FSC_H270] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012478 .type = ALC_FIXUP_PINS,
12479 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai18675e42010-09-08 15:55:44 +020012480 { 0x14, 0x99130110 }, /* speaker */
12481 { 0x15, 0x0221142f }, /* front HP */
12482 { 0x1b, 0x0121141f }, /* rear HP */
12483 { }
12484 }
12485 },
Takashi Iwai18675e42010-09-08 15:55:44 +020012486};
12487
12488static struct snd_pci_quirk alc262_fixup_tbl[] = {
12489 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12490 {}
12491};
12492
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012493
Takashi Iwaicb53c622007-08-10 17:21:45 +020012494#ifdef CONFIG_SND_HDA_POWER_SAVE
12495#define alc262_loopbacks alc880_loopbacks
12496#endif
12497
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012498/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012499#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12500#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12501#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12502#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12503
12504/*
12505 * BIOS auto configuration
12506 */
12507static int alc262_parse_auto_config(struct hda_codec *codec)
12508{
12509 struct alc_spec *spec = codec->spec;
12510 int err;
12511 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12512
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012513 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12514 alc262_ignore);
12515 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012516 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012517 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012518 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012519 spec->multiout.max_channels = 2;
12520 spec->no_analog = 1;
12521 goto dig_only;
12522 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012523 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012524 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012525 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12526 if (err < 0)
12527 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012528 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012529 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012530 return err;
12531
12532 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12533
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012534 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012535 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012536
Takashi Iwai603c4012008-07-30 15:01:44 +020012537 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012538 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012539
Takashi Iwaid88897e2008-10-31 15:01:37 +010012540 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012541 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012542 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012543
Takashi Iwai776e1842007-08-29 15:07:11 +020012544 err = alc_auto_add_mic_boost(codec);
12545 if (err < 0)
12546 return err;
12547
Kailang Yang6227cdc2010-02-25 08:36:52 +010012548 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012549
Kailang Yangdf694da2005-12-05 19:42:22 +010012550 return 1;
12551}
12552
12553#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12554#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12555#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012556#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012557
12558
12559/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012560static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012561{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012562 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012563 alc262_auto_init_multi_out(codec);
12564 alc262_auto_init_hp_out(codec);
12565 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012566 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012567 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012568 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012569 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012570}
12571
12572/*
12573 * configuration and preset
12574 */
Takashi Iwaiea734962011-01-17 11:29:34 +010012575static const char * const alc262_models[ALC262_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012576 [ALC262_BASIC] = "basic",
12577 [ALC262_HIPPO] = "hippo",
12578 [ALC262_HIPPO_1] = "hippo_1",
12579 [ALC262_FUJITSU] = "fujitsu",
12580 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012581 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012582 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012583 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012584 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012585 [ALC262_BENQ_T31] = "benq-t31",
12586 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012587 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012588 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012589 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012590 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012591 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012592 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012593 [ALC262_AUTO] = "auto",
12594};
12595
12596static struct snd_pci_quirk alc262_cfg_tbl[] = {
12597 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012598 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012599 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12600 ALC262_HP_BPC),
12601 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12602 ALC262_HP_BPC),
Takashi Iwai5734a072011-01-19 17:07:12 +010012603 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1500, "HP z series",
12604 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012605 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12606 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012607 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012608 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012609 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012610 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012611 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012612 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012613 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012614 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012615 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12616 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12617 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012618 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12619 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012620 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012621 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012622 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012623 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012624 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012625 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012626 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012627 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012628#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012629 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12630 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012631#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012632 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012633 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012634 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012635 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012636 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012637 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012638 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12639 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012640 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012641 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012642 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012643 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012644 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012645 {}
12646};
12647
12648static struct alc_config_preset alc262_presets[] = {
12649 [ALC262_BASIC] = {
12650 .mixers = { alc262_base_mixer },
12651 .init_verbs = { alc262_init_verbs },
12652 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12653 .dac_nids = alc262_dac_nids,
12654 .hp_nid = 0x03,
12655 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12656 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012657 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012658 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012659 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012660 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012661 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012662 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12663 .dac_nids = alc262_dac_nids,
12664 .hp_nid = 0x03,
12665 .dig_out_nid = ALC262_DIGOUT_NID,
12666 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12667 .channel_mode = alc262_modes,
12668 .input_mux = &alc262_capture_source,
12669 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012670 .setup = alc262_hippo_setup,
12671 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012672 },
12673 [ALC262_HIPPO_1] = {
12674 .mixers = { alc262_hippo1_mixer },
12675 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12676 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12677 .dac_nids = alc262_dac_nids,
12678 .hp_nid = 0x02,
12679 .dig_out_nid = ALC262_DIGOUT_NID,
12680 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12681 .channel_mode = alc262_modes,
12682 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012683 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012684 .setup = alc262_hippo1_setup,
12685 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012686 },
Takashi Iwai834be882006-03-01 14:16:17 +010012687 [ALC262_FUJITSU] = {
12688 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012689 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12690 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012691 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12692 .dac_nids = alc262_dac_nids,
12693 .hp_nid = 0x03,
12694 .dig_out_nid = ALC262_DIGOUT_NID,
12695 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12696 .channel_mode = alc262_modes,
12697 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012698 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012699 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012700 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012701 [ALC262_HP_BPC] = {
12702 .mixers = { alc262_HP_BPC_mixer },
12703 .init_verbs = { alc262_HP_BPC_init_verbs },
12704 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12705 .dac_nids = alc262_dac_nids,
12706 .hp_nid = 0x03,
12707 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12708 .channel_mode = alc262_modes,
12709 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012710 .unsol_event = alc262_hp_bpc_unsol_event,
12711 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012712 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012713 [ALC262_HP_BPC_D7000_WF] = {
12714 .mixers = { alc262_HP_BPC_WildWest_mixer },
12715 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12716 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12717 .dac_nids = alc262_dac_nids,
12718 .hp_nid = 0x03,
12719 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12720 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012721 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012722 .unsol_event = alc262_hp_wildwest_unsol_event,
12723 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012724 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012725 [ALC262_HP_BPC_D7000_WL] = {
12726 .mixers = { alc262_HP_BPC_WildWest_mixer,
12727 alc262_HP_BPC_WildWest_option_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 Yang66d2a9d2007-11-14 12:06:21 +010012738 [ALC262_HP_TC_T5735] = {
12739 .mixers = { alc262_hp_t5735_mixer },
12740 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12741 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12742 .dac_nids = alc262_dac_nids,
12743 .hp_nid = 0x03,
12744 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12745 .channel_mode = alc262_modes,
12746 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012747 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012748 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012749 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012750 },
12751 [ALC262_HP_RP5700] = {
12752 .mixers = { alc262_hp_rp5700_mixer },
12753 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12754 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12755 .dac_nids = alc262_dac_nids,
12756 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12757 .channel_mode = alc262_modes,
12758 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012759 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012760 [ALC262_BENQ_ED8] = {
12761 .mixers = { alc262_base_mixer },
12762 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12763 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12764 .dac_nids = alc262_dac_nids,
12765 .hp_nid = 0x03,
12766 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12767 .channel_mode = alc262_modes,
12768 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012769 },
Kailang Yang272a5272007-05-14 11:00:38 +020012770 [ALC262_SONY_ASSAMD] = {
12771 .mixers = { alc262_sony_mixer },
12772 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12773 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12774 .dac_nids = alc262_dac_nids,
12775 .hp_nid = 0x02,
12776 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12777 .channel_mode = alc262_modes,
12778 .input_mux = &alc262_capture_source,
12779 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012780 .setup = alc262_hippo_setup,
12781 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012782 },
12783 [ALC262_BENQ_T31] = {
12784 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012785 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12786 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012787 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12788 .dac_nids = alc262_dac_nids,
12789 .hp_nid = 0x03,
12790 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12791 .channel_mode = alc262_modes,
12792 .input_mux = &alc262_capture_source,
12793 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012794 .setup = alc262_hippo_setup,
12795 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012796 },
Tobin Davisf651b502007-10-26 12:40:47 +020012797 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012798 .mixers = { alc262_ultra_mixer },
12799 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012800 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012801 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12802 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012803 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12804 .channel_mode = alc262_modes,
12805 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012806 .adc_nids = alc262_adc_nids, /* ADC0 */
12807 .capsrc_nids = alc262_capsrc_nids,
12808 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012809 .unsol_event = alc262_ultra_unsol_event,
12810 .init_hook = alc262_ultra_automute,
12811 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012812 [ALC262_LENOVO_3000] = {
12813 .mixers = { alc262_lenovo_3000_mixer },
12814 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012815 alc262_lenovo_3000_unsol_verbs,
12816 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012817 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12818 .dac_nids = alc262_dac_nids,
12819 .hp_nid = 0x03,
12820 .dig_out_nid = ALC262_DIGOUT_NID,
12821 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12822 .channel_mode = alc262_modes,
12823 .input_mux = &alc262_fujitsu_capture_source,
12824 .unsol_event = alc262_lenovo_3000_unsol_event,
12825 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012826 [ALC262_NEC] = {
12827 .mixers = { alc262_nec_mixer },
12828 .init_verbs = { alc262_nec_verbs },
12829 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12830 .dac_nids = alc262_dac_nids,
12831 .hp_nid = 0x03,
12832 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12833 .channel_mode = alc262_modes,
12834 .input_mux = &alc262_capture_source,
12835 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012836 [ALC262_TOSHIBA_S06] = {
12837 .mixers = { alc262_toshiba_s06_mixer },
12838 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12839 alc262_eapd_verbs },
12840 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12841 .capsrc_nids = alc262_dmic_capsrc_nids,
12842 .dac_nids = alc262_dac_nids,
12843 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012844 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012845 .dig_out_nid = ALC262_DIGOUT_NID,
12846 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12847 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012848 .unsol_event = alc_sku_unsol_event,
12849 .setup = alc262_toshiba_s06_setup,
12850 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012851 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012852 [ALC262_TOSHIBA_RX1] = {
12853 .mixers = { alc262_toshiba_rx1_mixer },
12854 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12855 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12856 .dac_nids = alc262_dac_nids,
12857 .hp_nid = 0x03,
12858 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12859 .channel_mode = alc262_modes,
12860 .input_mux = &alc262_capture_source,
12861 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012862 .setup = alc262_hippo_setup,
12863 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012864 },
Tony Vroonba340e82009-02-02 19:01:30 +000012865 [ALC262_TYAN] = {
12866 .mixers = { alc262_tyan_mixer },
12867 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12868 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12869 .dac_nids = alc262_dac_nids,
12870 .hp_nid = 0x02,
12871 .dig_out_nid = ALC262_DIGOUT_NID,
12872 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12873 .channel_mode = alc262_modes,
12874 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012875 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012876 .setup = alc262_tyan_setup,
12877 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012878 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012879};
12880
12881static int patch_alc262(struct hda_codec *codec)
12882{
12883 struct alc_spec *spec;
12884 int board_config;
12885 int err;
12886
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012887 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012888 if (spec == NULL)
12889 return -ENOMEM;
12890
12891 codec->spec = spec;
12892#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012893 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12894 * under-run
12895 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012896 {
12897 int tmp;
12898 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12899 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12900 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12901 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12902 }
12903#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012904 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012905
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012906 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12907
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012908 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12909 alc262_models,
12910 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012911
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012912 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012913 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12914 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012915 board_config = ALC262_AUTO;
12916 }
12917
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012918 if (board_config == ALC262_AUTO) {
12919 alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups);
12920 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
12921 }
Takashi Iwai18675e42010-09-08 15:55:44 +020012922
Kailang Yangdf694da2005-12-05 19:42:22 +010012923 if (board_config == ALC262_AUTO) {
12924 /* automatic parse from the BIOS config */
12925 err = alc262_parse_auto_config(codec);
12926 if (err < 0) {
12927 alc_free(codec);
12928 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012929 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012930 printk(KERN_INFO
12931 "hda_codec: Cannot set up configuration "
12932 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012933 board_config = ALC262_BASIC;
12934 }
12935 }
12936
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012937 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012938 err = snd_hda_attach_beep_device(codec, 0x1);
12939 if (err < 0) {
12940 alc_free(codec);
12941 return err;
12942 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012943 }
12944
Kailang Yangdf694da2005-12-05 19:42:22 +010012945 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012946 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012947
Kailang Yangdf694da2005-12-05 19:42:22 +010012948 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12949 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012950
Kailang Yangdf694da2005-12-05 19:42:22 +010012951 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12952 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12953
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012954 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012955 int i;
12956 /* check whether the digital-mic has to be supported */
12957 for (i = 0; i < spec->input_mux->num_items; i++) {
12958 if (spec->input_mux->items[i].index >= 9)
12959 break;
12960 }
12961 if (i < spec->input_mux->num_items) {
12962 /* use only ADC0 */
12963 spec->adc_nids = alc262_dmic_adc_nids;
12964 spec->num_adc_nids = 1;
12965 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012966 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012967 /* all analog inputs */
12968 /* check whether NID 0x07 is valid */
12969 unsigned int wcap = get_wcaps(codec, 0x07);
12970
12971 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012972 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012973 if (wcap != AC_WID_AUD_IN) {
12974 spec->adc_nids = alc262_adc_nids_alt;
12975 spec->num_adc_nids =
12976 ARRAY_SIZE(alc262_adc_nids_alt);
12977 spec->capsrc_nids = alc262_capsrc_nids_alt;
12978 } else {
12979 spec->adc_nids = alc262_adc_nids;
12980 spec->num_adc_nids =
12981 ARRAY_SIZE(alc262_adc_nids);
12982 spec->capsrc_nids = alc262_capsrc_nids;
12983 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012984 }
12985 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012986 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012987 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012988 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010012989 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012990
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012991 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai18675e42010-09-08 15:55:44 +020012992
Takashi Iwai2134ea42008-01-10 16:53:55 +010012993 spec->vmaster_nid = 0x0c;
12994
Kailang Yangdf694da2005-12-05 19:42:22 +010012995 codec->patch_ops = alc_patch_ops;
12996 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012997 spec->init_hook = alc262_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020012998
12999 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020013000#ifdef CONFIG_SND_HDA_POWER_SAVE
13001 if (!spec->loopback.amplist)
13002 spec->loopback.amplist = alc262_loopbacks;
13003#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020013004
Kailang Yangdf694da2005-12-05 19:42:22 +010013005 return 0;
13006}
13007
Kailang Yangdf694da2005-12-05 19:42:22 +010013008/*
Kailang Yanga361d842007-06-05 12:30:55 +020013009 * ALC268 channel source setting (2 channel)
13010 */
13011#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
13012#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020013013
Kailang Yanga361d842007-06-05 12:30:55 +020013014static hda_nid_t alc268_dac_nids[2] = {
13015 /* front, hp */
13016 0x02, 0x03
13017};
13018
13019static hda_nid_t alc268_adc_nids[2] = {
13020 /* ADC0-1 */
13021 0x08, 0x07
13022};
13023
13024static hda_nid_t alc268_adc_nids_alt[1] = {
13025 /* ADC0 */
13026 0x08
13027};
13028
Takashi Iwaie1406342008-02-11 18:32:32 +010013029static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
13030
Kailang Yanga361d842007-06-05 12:30:55 +020013031static struct snd_kcontrol_new alc268_base_mixer[] = {
13032 /* output mixer control */
13033 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13034 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13035 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13036 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013037 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13038 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13039 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020013040 { }
13041};
13042
Takashi Iwai42171c12009-05-08 14:11:43 +020013043static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
13044 /* output mixer control */
13045 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13046 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13047 ALC262_HIPPO_MASTER_SWITCH,
David Henningsson5f99f862011-01-04 15:24:24 +010013048 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13049 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13050 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020013051 { }
13052};
13053
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013054/* bind Beep switches of both NID 0x0f and 0x10 */
13055static struct hda_bind_ctls alc268_bind_beep_sw = {
13056 .ops = &snd_hda_bind_sw,
13057 .values = {
13058 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
13059 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
13060 0
13061 },
13062};
13063
13064static struct snd_kcontrol_new alc268_beep_mixer[] = {
13065 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
13066 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
13067 { }
13068};
13069
Kailang Yangd1a991a2007-08-15 16:21:59 +020013070static struct hda_verb alc268_eapd_verbs[] = {
13071 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13072 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13073 { }
13074};
13075
Takashi Iwaid2738092007-08-16 14:59:45 +020013076/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020013077static struct hda_verb alc268_toshiba_verbs[] = {
13078 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13079 { } /* end */
13080};
13081
13082/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020013083/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020013084static struct hda_bind_ctls alc268_acer_bind_master_vol = {
13085 .ops = &snd_hda_bind_vol,
13086 .values = {
13087 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
13088 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
13089 0
13090 },
13091};
13092
Takashi Iwai889c4392007-08-23 18:56:52 +020013093/* mute/unmute internal speaker according to the hp jack and mute state */
13094static void alc268_acer_automute(struct hda_codec *codec, int force)
13095{
13096 struct alc_spec *spec = codec->spec;
13097 unsigned int mute;
13098
13099 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080013100 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020013101 spec->sense_updated = 1;
13102 }
13103 if (spec->jack_present)
13104 mute = HDA_AMP_MUTE; /* mute internal speaker */
13105 else /* unmute internal speaker if necessary */
13106 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13107 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13108 HDA_AMP_MUTE, mute);
13109}
13110
13111
13112/* bind hp and internal speaker mute (with plug check) */
13113static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
13114 struct snd_ctl_elem_value *ucontrol)
13115{
13116 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
13117 long *valp = ucontrol->value.integer.value;
13118 int change;
13119
Takashi Iwai8de56b72009-07-24 16:51:47 +020013120 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020013121 if (change)
13122 alc268_acer_automute(codec, 0);
13123 return change;
13124}
Takashi Iwaid2738092007-08-16 14:59:45 +020013125
Kailang Yang8ef355d2008-08-26 13:10:22 +020013126static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
13127 /* output mixer control */
13128 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13129 {
13130 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13131 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013132 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013133 .info = snd_hda_mixer_amp_switch_info,
13134 .get = snd_hda_mixer_amp_switch_get,
13135 .put = alc268_acer_master_sw_put,
13136 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13137 },
13138 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
13139 { }
13140};
13141
Takashi Iwaid2738092007-08-16 14:59:45 +020013142static struct snd_kcontrol_new alc268_acer_mixer[] = {
13143 /* output mixer control */
13144 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13145 {
13146 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13147 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013148 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020013149 .info = snd_hda_mixer_amp_switch_info,
13150 .get = snd_hda_mixer_amp_switch_get,
13151 .put = alc268_acer_master_sw_put,
13152 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13153 },
David Henningsson5f99f862011-01-04 15:24:24 +010013154 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13155 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
13156 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020013157 { }
13158};
13159
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013160static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
13161 /* output mixer control */
13162 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13163 {
13164 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13165 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013166 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013167 .info = snd_hda_mixer_amp_switch_info,
13168 .get = snd_hda_mixer_amp_switch_get,
13169 .put = alc268_acer_master_sw_put,
13170 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13171 },
David Henningsson5f99f862011-01-04 15:24:24 +010013172 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13173 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013174 { }
13175};
13176
Kailang Yang8ef355d2008-08-26 13:10:22 +020013177static struct hda_verb alc268_acer_aspire_one_verbs[] = {
13178 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13179 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13180 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13181 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13182 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
13183 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
13184 { }
13185};
13186
Takashi Iwaid2738092007-08-16 14:59:45 +020013187static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013188 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
13189 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020013190 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13191 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013192 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13193 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020013194 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13195 { }
13196};
13197
13198/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020013199#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013200#define alc268_toshiba_setup alc262_hippo_setup
13201#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020013202
13203static void alc268_acer_unsol_event(struct hda_codec *codec,
13204 unsigned int res)
13205{
Takashi Iwai889c4392007-08-23 18:56:52 +020013206 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020013207 return;
13208 alc268_acer_automute(codec, 1);
13209}
13210
Takashi Iwai889c4392007-08-23 18:56:52 +020013211static void alc268_acer_init_hook(struct hda_codec *codec)
13212{
13213 alc268_acer_automute(codec, 1);
13214}
13215
Kailang Yang8ef355d2008-08-26 13:10:22 +020013216/* toggle speaker-output according to the hp-jack state */
13217static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
13218{
13219 unsigned int present;
13220 unsigned char bits;
13221
Wu Fengguang864f92b2009-11-18 12:38:02 +080013222 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013223 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013224 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013225 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013226 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013227 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013228}
13229
Kailang Yang8ef355d2008-08-26 13:10:22 +020013230static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
13231 unsigned int res)
13232{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013233 switch (res >> 26) {
13234 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020013235 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013236 break;
13237 case ALC880_MIC_EVENT:
13238 alc_mic_automute(codec);
13239 break;
13240 }
13241}
13242
13243static void alc268_acer_lc_setup(struct hda_codec *codec)
13244{
13245 struct alc_spec *spec = codec->spec;
13246 spec->ext_mic.pin = 0x18;
13247 spec->ext_mic.mux_idx = 0;
13248 spec->int_mic.pin = 0x12;
13249 spec->int_mic.mux_idx = 6;
13250 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013251}
13252
13253static void alc268_acer_lc_init_hook(struct hda_codec *codec)
13254{
13255 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013256 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013257}
13258
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013259static struct snd_kcontrol_new alc268_dell_mixer[] = {
13260 /* output mixer control */
13261 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13262 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13263 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13264 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013265 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13266 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013267 { }
13268};
13269
13270static struct hda_verb alc268_dell_verbs[] = {
13271 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13272 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13273 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013274 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013275 { }
13276};
13277
13278/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013279static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013280{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013281 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013282
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013283 spec->autocfg.hp_pins[0] = 0x15;
13284 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013285 spec->ext_mic.pin = 0x18;
13286 spec->ext_mic.mux_idx = 0;
13287 spec->int_mic.pin = 0x19;
13288 spec->int_mic.mux_idx = 1;
13289 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013290}
13291
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013292static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
13293 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13294 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13295 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13296 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13297 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13298 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013299 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13300 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013301 { }
13302};
13303
13304static struct hda_verb alc267_quanta_il1_verbs[] = {
13305 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13306 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13307 { }
13308};
13309
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013310static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013311{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013312 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013313 spec->autocfg.hp_pins[0] = 0x15;
13314 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013315 spec->ext_mic.pin = 0x18;
13316 spec->ext_mic.mux_idx = 0;
13317 spec->int_mic.pin = 0x19;
13318 spec->int_mic.mux_idx = 1;
13319 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013320}
13321
Kailang Yanga361d842007-06-05 12:30:55 +020013322/*
13323 * generic initialization of ADC, input mixers and output mixers
13324 */
13325static struct hda_verb alc268_base_init_verbs[] = {
13326 /* Unmute DAC0-1 and set vol = 0 */
13327 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013328 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013329
13330 /*
13331 * Set up output mixers (0x0c - 0x0e)
13332 */
13333 /* set vol=0 to output mixers */
13334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013335 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13336
13337 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13338 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13339
13340 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13341 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13342 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13343 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13344 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13345 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13346 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13347 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13348
13349 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13350 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13351 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13352 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013353 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013354
13355 /* set PCBEEP vol = 0, mute connections */
13356 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13357 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13358 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013359
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013360 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013361
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013362 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13363 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13364 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13365 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013366
Kailang Yanga361d842007-06-05 12:30:55 +020013367 { }
13368};
13369
13370/*
13371 * generic initialization of ADC, input mixers and output mixers
13372 */
13373static struct hda_verb alc268_volume_init_verbs[] = {
13374 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013375 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13376 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013377
13378 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13379 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13380 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13381 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13382 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13383
Kailang Yanga361d842007-06-05 12:30:55 +020013384 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013385 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13386 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13387
13388 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013389 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013390
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013391 /* set PCBEEP vol = 0, mute connections */
13392 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13393 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13394 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013395
13396 { }
13397};
13398
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013399static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13400 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13401 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13402 { } /* end */
13403};
13404
Kailang Yanga361d842007-06-05 12:30:55 +020013405static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13406 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13407 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013408 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013409 { } /* end */
13410};
13411
13412static struct snd_kcontrol_new alc268_capture_mixer[] = {
13413 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13414 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13415 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13416 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013417 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013418 { } /* end */
13419};
13420
13421static struct hda_input_mux alc268_capture_source = {
13422 .num_items = 4,
13423 .items = {
13424 { "Mic", 0x0 },
13425 { "Front Mic", 0x1 },
13426 { "Line", 0x2 },
13427 { "CD", 0x3 },
13428 },
13429};
13430
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013431static struct hda_input_mux alc268_acer_capture_source = {
13432 .num_items = 3,
13433 .items = {
13434 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013435 { "Internal Mic", 0x1 },
13436 { "Line", 0x2 },
13437 },
13438};
13439
13440static struct hda_input_mux alc268_acer_dmic_capture_source = {
13441 .num_items = 3,
13442 .items = {
13443 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013444 { "Internal Mic", 0x6 },
13445 { "Line", 0x2 },
13446 },
13447};
13448
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013449#ifdef CONFIG_SND_DEBUG
13450static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013451 /* Volume widgets */
13452 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13453 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13454 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13455 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13456 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13457 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13458 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13459 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13460 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13461 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13462 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13463 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13464 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013465 /* The below appears problematic on some hardwares */
13466 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013467 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13468 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13469 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13470 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13471
13472 /* Modes for retasking pin widgets */
13473 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13474 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13475 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13476 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13477
13478 /* Controls for GPIO pins, assuming they are configured as outputs */
13479 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13480 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13481 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13482 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13483
13484 /* Switches to allow the digital SPDIF output pin to be enabled.
13485 * The ALC268 does not have an SPDIF input.
13486 */
13487 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13488
13489 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13490 * this output to turn on an external amplifier.
13491 */
13492 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13493 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13494
13495 { } /* end */
13496};
13497#endif
13498
Kailang Yanga361d842007-06-05 12:30:55 +020013499/* create input playback/capture controls for the given pin */
13500static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13501 const char *ctlname, int idx)
13502{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013503 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013504 int err;
13505
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013506 switch (nid) {
13507 case 0x14:
13508 case 0x16:
13509 dac = 0x02;
13510 break;
13511 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013512 case 0x1a: /* ALC259/269 only */
13513 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013514 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013515 dac = 0x03;
13516 break;
13517 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013518 snd_printd(KERN_WARNING "hda_codec: "
13519 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013520 return 0;
13521 }
13522 if (spec->multiout.dac_nids[0] != dac &&
13523 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013524 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013525 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013526 HDA_OUTPUT));
13527 if (err < 0)
13528 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013529 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13530 }
13531
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013532 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013533 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013534 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013535 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013536 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013537 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013538 if (err < 0)
13539 return err;
13540 return 0;
13541}
13542
13543/* add playback controls from the parsed DAC table */
13544static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13545 const struct auto_pin_cfg *cfg)
13546{
13547 hda_nid_t nid;
13548 int err;
13549
Kailang Yanga361d842007-06-05 12:30:55 +020013550 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013551
13552 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013553 if (nid) {
13554 const char *name;
13555 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13556 name = "Speaker";
13557 else
13558 name = "Front";
13559 err = alc268_new_analog_output(spec, nid, name, 0);
13560 if (err < 0)
13561 return err;
13562 }
Kailang Yanga361d842007-06-05 12:30:55 +020013563
13564 nid = cfg->speaker_pins[0];
13565 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013566 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013567 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13568 if (err < 0)
13569 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013570 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013571 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13572 if (err < 0)
13573 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013574 }
13575 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013576 if (nid) {
13577 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13578 if (err < 0)
13579 return err;
13580 }
Kailang Yanga361d842007-06-05 12:30:55 +020013581
13582 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13583 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013584 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013585 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013586 if (err < 0)
13587 return err;
13588 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013589 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013590}
13591
13592/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013593static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013594 const struct auto_pin_cfg *cfg)
13595{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013596 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013597}
13598
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013599static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13600 hda_nid_t nid, int pin_type)
13601{
13602 int idx;
13603
13604 alc_set_pin_output(codec, nid, pin_type);
13605 if (nid == 0x14 || nid == 0x16)
13606 idx = 0;
13607 else
13608 idx = 1;
13609 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13610}
13611
13612static void alc268_auto_init_multi_out(struct hda_codec *codec)
13613{
13614 struct alc_spec *spec = codec->spec;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013615 int i;
13616
13617 for (i = 0; i < spec->autocfg.line_outs; i++) {
13618 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013619 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13620 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13621 }
13622}
13623
13624static void alc268_auto_init_hp_out(struct hda_codec *codec)
13625{
13626 struct alc_spec *spec = codec->spec;
13627 hda_nid_t pin;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013628 int i;
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013629
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013630 for (i = 0; i < spec->autocfg.hp_outs; i++) {
13631 pin = spec->autocfg.hp_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013632 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013633 }
13634 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
13635 pin = spec->autocfg.speaker_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013636 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013637 }
13638 if (spec->autocfg.mono_out_pin)
13639 snd_hda_codec_write(codec, spec->autocfg.mono_out_pin, 0,
13640 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013641}
13642
Kailang Yanga361d842007-06-05 12:30:55 +020013643static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13644{
13645 struct alc_spec *spec = codec->spec;
13646 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13647 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13648 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13649 unsigned int dac_vol1, dac_vol2;
13650
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013651 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013652 snd_hda_codec_write(codec, speaker_nid, 0,
13653 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013654 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013655 snd_hda_codec_write(codec, 0x0f, 0,
13656 AC_VERB_SET_AMP_GAIN_MUTE,
13657 AMP_IN_UNMUTE(1));
13658 snd_hda_codec_write(codec, 0x10, 0,
13659 AC_VERB_SET_AMP_GAIN_MUTE,
13660 AMP_IN_UNMUTE(1));
13661 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013662 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013663 snd_hda_codec_write(codec, 0x0f, 0,
13664 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13665 snd_hda_codec_write(codec, 0x10, 0,
13666 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13667 }
13668
13669 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013670 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013671 dac_vol2 = AMP_OUT_ZERO;
13672 else if (line_nid == 0x15)
13673 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013674 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013675 dac_vol2 = AMP_OUT_ZERO;
13676 else if (hp_nid == 0x15)
13677 dac_vol1 = AMP_OUT_ZERO;
13678 if (line_nid != 0x16 || hp_nid != 0x16 ||
13679 spec->autocfg.line_out_pins[1] != 0x16 ||
13680 spec->autocfg.line_out_pins[2] != 0x16)
13681 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13682
13683 snd_hda_codec_write(codec, 0x02, 0,
13684 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13685 snd_hda_codec_write(codec, 0x03, 0,
13686 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13687}
13688
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013689/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013690#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13691#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013692#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013693#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13694
13695/*
13696 * BIOS auto configuration
13697 */
13698static int alc268_parse_auto_config(struct hda_codec *codec)
13699{
13700 struct alc_spec *spec = codec->spec;
13701 int err;
13702 static hda_nid_t alc268_ignore[] = { 0 };
13703
13704 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13705 alc268_ignore);
13706 if (err < 0)
13707 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013708 if (!spec->autocfg.line_outs) {
13709 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13710 spec->multiout.max_channels = 2;
13711 spec->no_analog = 1;
13712 goto dig_only;
13713 }
Kailang Yanga361d842007-06-05 12:30:55 +020013714 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013715 }
Kailang Yanga361d842007-06-05 12:30:55 +020013716 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13717 if (err < 0)
13718 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013719 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013720 if (err < 0)
13721 return err;
13722
13723 spec->multiout.max_channels = 2;
13724
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013725 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013726 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013727 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013728 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013729 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013730
Takashi Iwai892981f2009-03-02 08:04:35 +010013731 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013732 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013733
Takashi Iwaid88897e2008-10-31 15:01:37 +010013734 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013735 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013736 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013737
Takashi Iwai776e1842007-08-29 15:07:11 +020013738 err = alc_auto_add_mic_boost(codec);
13739 if (err < 0)
13740 return err;
13741
Kailang Yang6227cdc2010-02-25 08:36:52 +010013742 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013743
Kailang Yanga361d842007-06-05 12:30:55 +020013744 return 1;
13745}
13746
Kailang Yanga361d842007-06-05 12:30:55 +020013747#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13748
13749/* init callback for auto-configuration model -- overriding the default init */
13750static void alc268_auto_init(struct hda_codec *codec)
13751{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013752 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013753 alc268_auto_init_multi_out(codec);
13754 alc268_auto_init_hp_out(codec);
13755 alc268_auto_init_mono_speaker_out(codec);
13756 alc268_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013757 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013758 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013759 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013760}
13761
13762/*
13763 * configuration and preset
13764 */
Takashi Iwaiea734962011-01-17 11:29:34 +010013765static const char * const alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013766 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013767 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013768 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013769 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013770 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013771 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013772 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013773 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013774#ifdef CONFIG_SND_DEBUG
13775 [ALC268_TEST] = "test",
13776#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013777 [ALC268_AUTO] = "auto",
13778};
13779
13780static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013781 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013782 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013783 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013784 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013785 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013786 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13787 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013788 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013789 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13790 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013791 /* almost compatible with toshiba but with optional digital outs;
13792 * auto-probing seems working fine
13793 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013794 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013795 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013796 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013797 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013798 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013799 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013800 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013801 {}
13802};
13803
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013804/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13805static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13806 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13807 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13808 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13809 ALC268_TOSHIBA),
13810 {}
13811};
13812
Kailang Yanga361d842007-06-05 12:30:55 +020013813static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013814 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013815 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13816 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013817 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13818 alc267_quanta_il1_verbs },
13819 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13820 .dac_nids = alc268_dac_nids,
13821 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13822 .adc_nids = alc268_adc_nids_alt,
13823 .hp_nid = 0x03,
13824 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13825 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013826 .unsol_event = alc_sku_unsol_event,
13827 .setup = alc267_quanta_il1_setup,
13828 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013829 },
Kailang Yanga361d842007-06-05 12:30:55 +020013830 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013831 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13832 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013833 .init_verbs = { alc268_base_init_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,
Takashi Iwaie1406342008-02-11 18:32:32 +010013838 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013839 .hp_nid = 0x03,
13840 .dig_out_nid = ALC268_DIGOUT_NID,
13841 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13842 .channel_mode = alc268_modes,
13843 .input_mux = &alc268_capture_source,
13844 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013845 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013846 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013847 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013848 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13849 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013850 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13851 .dac_nids = alc268_dac_nids,
13852 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13853 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013854 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013855 .hp_nid = 0x03,
13856 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13857 .channel_mode = alc268_modes,
13858 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013859 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013860 .setup = alc268_toshiba_setup,
13861 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013862 },
13863 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013864 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013865 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013866 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13867 alc268_acer_verbs },
13868 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13869 .dac_nids = alc268_dac_nids,
13870 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13871 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013872 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013873 .hp_nid = 0x02,
13874 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13875 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013876 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013877 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013878 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013879 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013880 [ALC268_ACER_DMIC] = {
13881 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13882 alc268_beep_mixer },
13883 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13884 alc268_acer_verbs },
13885 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13886 .dac_nids = alc268_dac_nids,
13887 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13888 .adc_nids = alc268_adc_nids_alt,
13889 .capsrc_nids = alc268_capsrc_nids,
13890 .hp_nid = 0x02,
13891 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13892 .channel_mode = alc268_modes,
13893 .input_mux = &alc268_acer_dmic_capture_source,
13894 .unsol_event = alc268_acer_unsol_event,
13895 .init_hook = alc268_acer_init_hook,
13896 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013897 [ALC268_ACER_ASPIRE_ONE] = {
13898 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013899 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013900 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013901 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13902 alc268_acer_aspire_one_verbs },
13903 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13904 .dac_nids = alc268_dac_nids,
13905 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13906 .adc_nids = alc268_adc_nids_alt,
13907 .capsrc_nids = alc268_capsrc_nids,
13908 .hp_nid = 0x03,
13909 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13910 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013911 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013912 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013913 .init_hook = alc268_acer_lc_init_hook,
13914 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013915 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013916 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13917 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013918 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13919 alc268_dell_verbs },
13920 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13921 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013922 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13923 .adc_nids = alc268_adc_nids_alt,
13924 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013925 .hp_nid = 0x02,
13926 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13927 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013928 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013929 .setup = alc268_dell_setup,
13930 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013931 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013932 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013933 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13934 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013935 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13936 alc268_toshiba_verbs },
13937 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13938 .dac_nids = alc268_dac_nids,
13939 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13940 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013941 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013942 .hp_nid = 0x03,
13943 .dig_out_nid = ALC268_DIGOUT_NID,
13944 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13945 .channel_mode = alc268_modes,
13946 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013947 .setup = alc268_toshiba_setup,
13948 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013949 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013950#ifdef CONFIG_SND_DEBUG
13951 [ALC268_TEST] = {
13952 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13953 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13954 alc268_volume_init_verbs },
13955 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13956 .dac_nids = alc268_dac_nids,
13957 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13958 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013959 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013960 .hp_nid = 0x03,
13961 .dig_out_nid = ALC268_DIGOUT_NID,
13962 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13963 .channel_mode = alc268_modes,
13964 .input_mux = &alc268_capture_source,
13965 },
13966#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013967};
13968
13969static int patch_alc268(struct hda_codec *codec)
13970{
13971 struct alc_spec *spec;
13972 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013973 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013974
Julia Lawallef86f582009-12-19 08:18:03 +010013975 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013976 if (spec == NULL)
13977 return -ENOMEM;
13978
13979 codec->spec = spec;
13980
13981 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13982 alc268_models,
13983 alc268_cfg_tbl);
13984
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013985 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13986 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013987 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013988
Kailang Yanga361d842007-06-05 12:30:55 +020013989 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013990 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13991 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013992 board_config = ALC268_AUTO;
13993 }
13994
13995 if (board_config == ALC268_AUTO) {
13996 /* automatic parse from the BIOS config */
13997 err = alc268_parse_auto_config(codec);
13998 if (err < 0) {
13999 alc_free(codec);
14000 return err;
14001 } else if (!err) {
14002 printk(KERN_INFO
14003 "hda_codec: Cannot set up configuration "
14004 "from BIOS. Using base mode...\n");
14005 board_config = ALC268_3ST;
14006 }
14007 }
14008
14009 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014010 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020014011
Kailang Yanga361d842007-06-05 12:30:55 +020014012 spec->stream_analog_playback = &alc268_pcm_analog_playback;
14013 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010014014 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020014015
Kailang Yanga361d842007-06-05 12:30:55 +020014016 spec->stream_digital_playback = &alc268_pcm_digital_playback;
14017
Takashi Iwai22971e32009-02-10 11:56:44 +010014018 has_beep = 0;
14019 for (i = 0; i < spec->num_mixers; i++) {
14020 if (spec->mixers[i] == alc268_beep_mixer) {
14021 has_beep = 1;
14022 break;
14023 }
14024 }
14025
14026 if (has_beep) {
14027 err = snd_hda_attach_beep_device(codec, 0x1);
14028 if (err < 0) {
14029 alc_free(codec);
14030 return err;
14031 }
14032 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
14033 /* override the amp caps for beep generator */
14034 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014035 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
14036 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
14037 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
14038 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010014039 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014040
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014041 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014042 /* check whether NID 0x07 is valid */
14043 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010014044 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020014045
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014046 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014047 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020014048 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014049 if (spec->auto_mic ||
14050 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014051 spec->adc_nids = alc268_adc_nids_alt;
14052 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014053 if (spec->auto_mic)
14054 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014055 if (spec->auto_mic || spec->input_mux->num_items == 1)
14056 add_mixer(spec, alc268_capture_nosrc_mixer);
14057 else
14058 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014059 } else {
14060 spec->adc_nids = alc268_adc_nids;
14061 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010014062 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020014063 }
Takashi Iwai85860c02008-02-19 15:00:15 +010014064 /* set default input source */
14065 for (i = 0; i < spec->num_adc_nids; i++)
14066 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
14067 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030014068 i < spec->num_mux_defs ?
14069 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010014070 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020014071 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010014072
14073 spec->vmaster_nid = 0x02;
14074
Kailang Yanga361d842007-06-05 12:30:55 +020014075 codec->patch_ops = alc_patch_ops;
14076 if (board_config == ALC268_AUTO)
14077 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020014078
Kailang Yangbf1b0222010-10-21 08:49:56 +020014079 alc_init_jacks(codec);
14080
Kailang Yanga361d842007-06-05 12:30:55 +020014081 return 0;
14082}
14083
14084/*
Kailang Yangf6a92242007-12-13 16:52:54 +010014085 * ALC269 channel source setting (2 channel)
14086 */
14087#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
14088
14089#define alc269_dac_nids alc260_dac_nids
14090
14091static hda_nid_t alc269_adc_nids[1] = {
14092 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020014093 0x08,
14094};
14095
Takashi Iwaie01bf502008-08-21 16:25:07 +020014096static hda_nid_t alc269_capsrc_nids[1] = {
14097 0x23,
14098};
14099
Kailang Yang84898e82010-02-04 14:16:14 +010014100static hda_nid_t alc269vb_adc_nids[1] = {
14101 /* ADC1 */
14102 0x09,
14103};
14104
14105static hda_nid_t alc269vb_capsrc_nids[1] = {
14106 0x22,
14107};
14108
Takashi Iwai66946352010-03-29 17:21:45 +020014109static hda_nid_t alc269_adc_candidates[] = {
14110 0x08, 0x09, 0x07,
14111};
Takashi Iwaie01bf502008-08-21 16:25:07 +020014112
Kailang Yangf6a92242007-12-13 16:52:54 +010014113#define alc269_modes alc260_modes
14114#define alc269_capture_source alc880_lg_lw_capture_source
14115
14116static struct snd_kcontrol_new alc269_base_mixer[] = {
14117 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14118 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14119 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14120 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14121 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14122 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014123 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014124 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14125 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014126 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014127 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14128 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
14129 { } /* end */
14130};
14131
Kailang Yang60db6b52008-08-26 13:13:00 +020014132static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
14133 /* output mixer control */
14134 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14135 {
14136 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14137 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014138 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020014139 .info = snd_hda_mixer_amp_switch_info,
14140 .get = snd_hda_mixer_amp_switch_get,
14141 .put = alc268_acer_master_sw_put,
14142 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14143 },
14144 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14145 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014146 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014147 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14148 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014149 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014150 { }
14151};
14152
Tony Vroon64154832008-11-06 15:08:49 +000014153static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
14154 /* output mixer control */
14155 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14156 {
14157 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14158 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014159 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000014160 .info = snd_hda_mixer_amp_switch_info,
14161 .get = snd_hda_mixer_amp_switch_get,
14162 .put = alc268_acer_master_sw_put,
14163 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14164 },
14165 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14166 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014167 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014168 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14169 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014170 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014171 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
14172 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014173 HDA_CODEC_VOLUME("Dock Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014174 { }
14175};
14176
Kailang Yang84898e82010-02-04 14:16:14 +010014177static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020014178 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014179 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020014180 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014181 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020014182 { } /* end */
14183};
14184
Kailang Yang84898e82010-02-04 14:16:14 +010014185static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
14186 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14187 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14188 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14189 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14190 { } /* end */
14191};
14192
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014193static struct snd_kcontrol_new alc269_asus_mixer[] = {
14194 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14195 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
14196 { } /* end */
14197};
14198
Kailang Yangf6a92242007-12-13 16:52:54 +010014199/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010014200static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
14201 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14202 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014203 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14204 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014205 { } /* end */
14206};
14207
14208static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020014209 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),
Takashi Iwai26f5df22008-11-03 17:39:46 +010014212 { } /* end */
14213};
14214
Kailang Yang84898e82010-02-04 14:16:14 +010014215static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
14216 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14217 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014218 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14219 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014220 { } /* end */
14221};
14222
14223static struct snd_kcontrol_new alc269vb_laptop_digital_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),
Kailang Yang84898e82010-02-04 14:16:14 +010014227 { } /* end */
14228};
14229
Takashi Iwai26f5df22008-11-03 17:39:46 +010014230/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010014231#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020014232
Kailang Yang60db6b52008-08-26 13:13:00 +020014233static struct hda_verb alc269_quanta_fl1_verbs[] = {
14234 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14235 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14236 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14237 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14238 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14239 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14240 { }
14241};
14242
Tony Vroon64154832008-11-06 15:08:49 +000014243static struct hda_verb alc269_lifebook_verbs[] = {
14244 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14245 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
14246 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14247 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14248 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14249 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14250 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14251 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14252 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14253 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14254 { }
14255};
14256
Kailang Yang60db6b52008-08-26 13:13:00 +020014257/* toggle speaker-output according to the hp-jack state */
14258static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
14259{
14260 unsigned int present;
14261 unsigned char bits;
14262
Wu Fengguang864f92b2009-11-18 12:38:02 +080014263 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014264 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014265 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014266 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014267 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014268 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014269
14270 snd_hda_codec_write(codec, 0x20, 0,
14271 AC_VERB_SET_COEF_INDEX, 0x0c);
14272 snd_hda_codec_write(codec, 0x20, 0,
14273 AC_VERB_SET_PROC_COEF, 0x680);
14274
14275 snd_hda_codec_write(codec, 0x20, 0,
14276 AC_VERB_SET_COEF_INDEX, 0x0c);
14277 snd_hda_codec_write(codec, 0x20, 0,
14278 AC_VERB_SET_PROC_COEF, 0x480);
14279}
14280
Tony Vroon64154832008-11-06 15:08:49 +000014281/* toggle speaker-output according to the hp-jacks state */
14282static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
14283{
14284 unsigned int present;
14285 unsigned char bits;
14286
14287 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014288 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000014289
14290 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014291 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000014292
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014293 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000014294 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014295 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014296 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014297 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014298
14299 snd_hda_codec_write(codec, 0x20, 0,
14300 AC_VERB_SET_COEF_INDEX, 0x0c);
14301 snd_hda_codec_write(codec, 0x20, 0,
14302 AC_VERB_SET_PROC_COEF, 0x680);
14303
14304 snd_hda_codec_write(codec, 0x20, 0,
14305 AC_VERB_SET_COEF_INDEX, 0x0c);
14306 snd_hda_codec_write(codec, 0x20, 0,
14307 AC_VERB_SET_PROC_COEF, 0x480);
14308}
14309
Tony Vroon64154832008-11-06 15:08:49 +000014310static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14311{
14312 unsigned int present_laptop;
14313 unsigned int present_dock;
14314
Wu Fengguang864f92b2009-11-18 12:38:02 +080014315 present_laptop = snd_hda_jack_detect(codec, 0x18);
14316 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014317
14318 /* Laptop mic port overrides dock mic port, design decision */
14319 if (present_dock)
14320 snd_hda_codec_write(codec, 0x23, 0,
14321 AC_VERB_SET_CONNECT_SEL, 0x3);
14322 if (present_laptop)
14323 snd_hda_codec_write(codec, 0x23, 0,
14324 AC_VERB_SET_CONNECT_SEL, 0x0);
14325 if (!present_dock && !present_laptop)
14326 snd_hda_codec_write(codec, 0x23, 0,
14327 AC_VERB_SET_CONNECT_SEL, 0x1);
14328}
14329
Kailang Yang60db6b52008-08-26 13:13:00 +020014330static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14331 unsigned int res)
14332{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014333 switch (res >> 26) {
14334 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014335 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014336 break;
14337 case ALC880_MIC_EVENT:
14338 alc_mic_automute(codec);
14339 break;
14340 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014341}
14342
Tony Vroon64154832008-11-06 15:08:49 +000014343static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14344 unsigned int res)
14345{
14346 if ((res >> 26) == ALC880_HP_EVENT)
14347 alc269_lifebook_speaker_automute(codec);
14348 if ((res >> 26) == ALC880_MIC_EVENT)
14349 alc269_lifebook_mic_autoswitch(codec);
14350}
14351
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014352static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14353{
14354 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014355 spec->autocfg.hp_pins[0] = 0x15;
14356 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014357 spec->ext_mic.pin = 0x18;
14358 spec->ext_mic.mux_idx = 0;
14359 spec->int_mic.pin = 0x19;
14360 spec->int_mic.mux_idx = 1;
14361 spec->auto_mic = 1;
14362}
14363
Kailang Yang60db6b52008-08-26 13:13:00 +020014364static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14365{
14366 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014367 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014368}
14369
Tony Vroon64154832008-11-06 15:08:49 +000014370static void alc269_lifebook_init_hook(struct hda_codec *codec)
14371{
14372 alc269_lifebook_speaker_automute(codec);
14373 alc269_lifebook_mic_autoswitch(codec);
14374}
14375
Kailang Yang84898e82010-02-04 14:16:14 +010014376static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014377 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14378 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14379 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14380 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14381 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14382 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14383 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14384 {}
14385};
14386
Kailang Yang84898e82010-02-04 14:16:14 +010014387static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014388 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14389 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14390 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14391 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14392 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14393 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14394 {}
14395};
14396
Kailang Yang84898e82010-02-04 14:16:14 +010014397static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14398 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14399 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14400 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14401 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14402 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14403 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14404 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14405 {}
14406};
14407
14408static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14409 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14410 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14411 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14412 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14413 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14414 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14415 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14416 {}
14417};
14418
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014419static struct hda_verb alc271_acer_dmic_verbs[] = {
14420 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14421 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14422 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14423 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14424 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14425 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14426 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14427 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14428 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14429 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14430 { }
14431};
14432
Kailang Yang60db6b52008-08-26 13:13:00 +020014433/* toggle speaker-output according to the hp-jack state */
14434static void alc269_speaker_automute(struct hda_codec *codec)
14435{
Kailang Yangebb83ee2009-12-17 12:23:00 +010014436 struct alc_spec *spec = codec->spec;
14437 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020014438 unsigned int present;
14439 unsigned char bits;
14440
Kailang Yangebb83ee2009-12-17 12:23:00 +010014441 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014442 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014443 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014444 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014445 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014446 HDA_AMP_MUTE, bits);
Takashi Iwaicd372fb2011-03-03 14:40:14 +010014447 snd_hda_input_jack_report(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020014448}
14449
Kailang Yang60db6b52008-08-26 13:13:00 +020014450/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010014451static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020014452 unsigned int res)
14453{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014454 switch (res >> 26) {
14455 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014456 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014457 break;
14458 case ALC880_MIC_EVENT:
14459 alc_mic_automute(codec);
14460 break;
14461 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014462}
14463
Kailang Yang226b1ec2010-04-09 11:01:20 +020014464static void alc269_laptop_amic_setup(struct hda_codec *codec)
14465{
14466 struct alc_spec *spec = codec->spec;
14467 spec->autocfg.hp_pins[0] = 0x15;
14468 spec->autocfg.speaker_pins[0] = 0x14;
14469 spec->ext_mic.pin = 0x18;
14470 spec->ext_mic.mux_idx = 0;
14471 spec->int_mic.pin = 0x19;
14472 spec->int_mic.mux_idx = 1;
14473 spec->auto_mic = 1;
14474}
14475
Kailang Yang84898e82010-02-04 14:16:14 +010014476static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014477{
14478 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014479 spec->autocfg.hp_pins[0] = 0x15;
14480 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014481 spec->ext_mic.pin = 0x18;
14482 spec->ext_mic.mux_idx = 0;
14483 spec->int_mic.pin = 0x12;
14484 spec->int_mic.mux_idx = 5;
14485 spec->auto_mic = 1;
14486}
14487
Kailang Yang226b1ec2010-04-09 11:01:20 +020014488static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014489{
14490 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014491 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014492 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014493 spec->ext_mic.pin = 0x18;
14494 spec->ext_mic.mux_idx = 0;
14495 spec->int_mic.pin = 0x19;
14496 spec->int_mic.mux_idx = 1;
14497 spec->auto_mic = 1;
14498}
14499
Kailang Yang226b1ec2010-04-09 11:01:20 +020014500static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14501{
14502 struct alc_spec *spec = codec->spec;
14503 spec->autocfg.hp_pins[0] = 0x21;
14504 spec->autocfg.speaker_pins[0] = 0x14;
14505 spec->ext_mic.pin = 0x18;
14506 spec->ext_mic.mux_idx = 0;
14507 spec->int_mic.pin = 0x12;
14508 spec->int_mic.mux_idx = 6;
14509 spec->auto_mic = 1;
14510}
14511
Kailang Yang84898e82010-02-04 14:16:14 +010014512static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020014513{
14514 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014515 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014516}
14517
Kailang Yangf6a92242007-12-13 16:52:54 +010014518/*
14519 * generic initialization of ADC, input mixers and output mixers
14520 */
14521static struct hda_verb alc269_init_verbs[] = {
14522 /*
14523 * Unmute ADC0 and set the default input to mic-in
14524 */
Kailang Yang84898e82010-02-04 14:16:14 +010014525 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014526
14527 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014528 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014529 */
14530 /* set vol=0 to output mixers */
14531 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14532 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14533
14534 /* set up input amps for analog loopback */
14535 /* Amp Indices: DAC = 0, mixer = 1 */
14536 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14537 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14538 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14539 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14540 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14541 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14542
14543 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14544 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14545 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14546 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14547 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14548 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14549 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14550
14551 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14552 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014553
Kailang Yang84898e82010-02-04 14:16:14 +010014554 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014555 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14556 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014557 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014558
14559 /* set EAPD */
14560 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014561 { }
14562};
14563
14564static struct hda_verb alc269vb_init_verbs[] = {
14565 /*
14566 * Unmute ADC0 and set the default input to mic-in
14567 */
14568 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14569
14570 /*
14571 * Set up output mixers (0x02 - 0x03)
14572 */
14573 /* set vol=0 to output mixers */
14574 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14575 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14576
14577 /* set up input amps for analog loopback */
14578 /* Amp Indices: DAC = 0, mixer = 1 */
14579 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14580 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14581 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14582 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14583 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14584 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14585
14586 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14587 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14588 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14589 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14590 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14591 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14592 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14593
14594 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14595 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14596
14597 /* FIXME: use Mux-type input source selection */
14598 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14599 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14600 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14601
14602 /* set EAPD */
14603 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014604 { }
14605};
14606
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014607#define alc269_auto_create_multi_out_ctls \
14608 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014609#define alc269_auto_create_input_ctls \
14610 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014611
14612#ifdef CONFIG_SND_HDA_POWER_SAVE
14613#define alc269_loopbacks alc880_loopbacks
14614#endif
14615
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014616/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014617#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14618#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14619#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14620#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14621
Takashi Iwaif03d3112009-03-05 14:18:16 +010014622static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14623 .substreams = 1,
14624 .channels_min = 2,
14625 .channels_max = 8,
14626 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14627 /* NID is set in alc_build_pcms */
14628 .ops = {
14629 .open = alc880_playback_pcm_open,
14630 .prepare = alc880_playback_pcm_prepare,
14631 .cleanup = alc880_playback_pcm_cleanup
14632 },
14633};
14634
14635static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14636 .substreams = 1,
14637 .channels_min = 2,
14638 .channels_max = 2,
14639 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14640 /* NID is set in alc_build_pcms */
14641};
14642
Takashi Iwaiad358792010-03-30 18:00:59 +020014643#ifdef CONFIG_SND_HDA_POWER_SAVE
14644static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14645{
14646 switch (codec->subsystem_id) {
14647 case 0x103c1586:
14648 return 1;
14649 }
14650 return 0;
14651}
14652
14653static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14654{
14655 /* update mute-LED according to the speaker mute state */
14656 if (nid == 0x01 || nid == 0x14) {
14657 int pinval;
14658 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14659 HDA_AMP_MUTE)
14660 pinval = 0x24;
14661 else
14662 pinval = 0x20;
14663 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a52010-03-30 18:03:44 +020014664 snd_hda_codec_update_cache(codec, 0x19, 0,
14665 AC_VERB_SET_PIN_WIDGET_CONTROL,
14666 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014667 }
14668 return alc_check_power_status(codec, nid);
14669}
14670#endif /* CONFIG_SND_HDA_POWER_SAVE */
14671
Takashi Iwai840b64c2010-07-13 22:49:01 +020014672static int alc275_setup_dual_adc(struct hda_codec *codec)
14673{
14674 struct alc_spec *spec = codec->spec;
14675
14676 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14677 return 0;
14678 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14679 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14680 if (spec->ext_mic.pin <= 0x12) {
14681 spec->private_adc_nids[0] = 0x08;
14682 spec->private_adc_nids[1] = 0x11;
14683 spec->private_capsrc_nids[0] = 0x23;
14684 spec->private_capsrc_nids[1] = 0x22;
14685 } else {
14686 spec->private_adc_nids[0] = 0x11;
14687 spec->private_adc_nids[1] = 0x08;
14688 spec->private_capsrc_nids[0] = 0x22;
14689 spec->private_capsrc_nids[1] = 0x23;
14690 }
14691 spec->adc_nids = spec->private_adc_nids;
14692 spec->capsrc_nids = spec->private_capsrc_nids;
14693 spec->num_adc_nids = 2;
14694 spec->dual_adc_switch = 1;
14695 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14696 spec->adc_nids[0], spec->adc_nids[1]);
14697 return 1;
14698 }
14699 return 0;
14700}
14701
Takashi Iwaid433a672010-09-20 15:11:54 +020014702/* different alc269-variants */
14703enum {
14704 ALC269_TYPE_NORMAL,
Kailang Yang48c88e82010-11-23 08:56:16 +010014705 ALC269_TYPE_ALC258,
Takashi Iwaid433a672010-09-20 15:11:54 +020014706 ALC269_TYPE_ALC259,
Kailang Yang48c88e82010-11-23 08:56:16 +010014707 ALC269_TYPE_ALC269VB,
14708 ALC269_TYPE_ALC270,
Takashi Iwaid433a672010-09-20 15:11:54 +020014709 ALC269_TYPE_ALC271X,
14710};
14711
Kailang Yangf6a92242007-12-13 16:52:54 +010014712/*
14713 * BIOS auto configuration
14714 */
14715static int alc269_parse_auto_config(struct hda_codec *codec)
14716{
14717 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014718 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014719 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14720
14721 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14722 alc269_ignore);
14723 if (err < 0)
14724 return err;
14725
14726 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14727 if (err < 0)
14728 return err;
Takashi Iwaif3550d12010-09-20 15:09:03 +020014729 if (spec->codec_variant == ALC269_TYPE_NORMAL)
14730 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
14731 else
14732 err = alc_auto_create_input_ctls(codec, &spec->autocfg, 0,
14733 0x22, 0);
Kailang Yangf6a92242007-12-13 16:52:54 +010014734 if (err < 0)
14735 return err;
14736
14737 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14738
Takashi Iwai757899a2010-07-30 10:48:14 +020014739 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014740
Takashi Iwai603c4012008-07-30 15:01:44 +020014741 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014742 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014743
Takashi Iwaid433a672010-09-20 15:11:54 +020014744 if (spec->codec_variant != ALC269_TYPE_NORMAL) {
Kailang Yang84898e82010-02-04 14:16:14 +010014745 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014746 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014747 } else {
14748 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014749 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014750 }
14751
Kailang Yangf6a92242007-12-13 16:52:54 +010014752 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014753 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014754
14755 if (!alc275_setup_dual_adc(codec))
14756 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14757 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014758
Takashi Iwaie01bf502008-08-21 16:25:07 +020014759 /* set default input source */
Takashi Iwai840b64c2010-07-13 22:49:01 +020014760 if (!spec->dual_adc_switch)
Takashi Iwai748cce42010-08-04 07:37:39 +020014761 select_or_unmute_capsrc(codec, spec->capsrc_nids[0],
14762 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014763
14764 err = alc_auto_add_mic_boost(codec);
14765 if (err < 0)
14766 return err;
14767
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014768 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014769 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014770
Kailang Yangf6a92242007-12-13 16:52:54 +010014771 return 1;
14772}
14773
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014774#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14775#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014776#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14777
14778
14779/* init callback for auto-configuration model -- overriding the default init */
14780static void alc269_auto_init(struct hda_codec *codec)
14781{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014782 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014783 alc269_auto_init_multi_out(codec);
14784 alc269_auto_init_hp_out(codec);
14785 alc269_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014786 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014787 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014788 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014789}
14790
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014791#ifdef SND_HDA_NEEDS_RESUME
14792static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
14793{
14794 int val = alc_read_coef_idx(codec, 0x04);
14795 if (power_up)
14796 val |= 1 << 11;
14797 else
14798 val &= ~(1 << 11);
14799 alc_write_coef_idx(codec, 0x04, val);
14800}
14801
Kailang Yang977ddd62010-09-15 10:02:29 +020014802#ifdef CONFIG_SND_HDA_POWER_SAVE
14803static int alc269_suspend(struct hda_codec *codec, pm_message_t state)
14804{
14805 struct alc_spec *spec = codec->spec;
Kailang Yang977ddd62010-09-15 10:02:29 +020014806
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014807 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017)
14808 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014809 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014810 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014811 msleep(150);
14812 }
14813
14814 alc_shutup(codec);
14815 if (spec && spec->power_hook)
14816 spec->power_hook(codec);
14817 return 0;
14818}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014819#endif /* CONFIG_SND_HDA_POWER_SAVE */
14820
Kailang Yang977ddd62010-09-15 10:02:29 +020014821static int alc269_resume(struct hda_codec *codec)
14822{
Kailang Yang977ddd62010-09-15 10:02:29 +020014823 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014824 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014825 msleep(150);
14826 }
14827
14828 codec->patch_ops.init(codec);
14829
14830 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014831 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014832 msleep(200);
14833 }
14834
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014835 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018)
14836 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014837
14838 snd_hda_codec_resume_amp(codec);
14839 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +020014840 hda_call_check_power_status(codec, 0x01);
Kailang Yang977ddd62010-09-15 10:02:29 +020014841 return 0;
14842}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014843#endif /* SND_HDA_NEEDS_RESUME */
Kailang Yang977ddd62010-09-15 10:02:29 +020014844
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014845static void alc269_fixup_hweq(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014846 const struct alc_fixup *fix, int action)
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014847{
14848 int coef;
14849
Takashi Iwai58701122011-01-13 15:41:45 +010014850 if (action != ALC_FIXUP_ACT_INIT)
Takashi Iwai9fb1ef22011-01-13 14:40:43 +010014851 return;
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014852 coef = alc_read_coef_idx(codec, 0x1e);
14853 alc_write_coef_idx(codec, 0x1e, coef | 0x80);
14854}
14855
Takashi Iwaiff818c22010-04-12 08:59:25 +020014856enum {
14857 ALC269_FIXUP_SONY_VAIO,
Takashi Iwai74dc8902011-01-13 14:14:41 +010014858 ALC275_FIXUP_SONY_VAIO_GPIO2,
David Henningsson145a9022010-09-16 10:07:53 +020014859 ALC269_FIXUP_DELL_M101Z,
David Henningsson022c92b2010-12-17 20:43:04 +010014860 ALC269_FIXUP_SKU_IGNORE,
David Henningssonac612402010-12-15 09:18:18 +010014861 ALC269_FIXUP_ASUS_G73JW,
Kailang Yang357f9152011-01-12 08:12:52 +010014862 ALC269_FIXUP_LENOVO_EAPD,
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014863 ALC275_FIXUP_SONY_HWEQ,
Takashi Iwaiff818c22010-04-12 08:59:25 +020014864};
14865
Takashi Iwaiff818c22010-04-12 08:59:25 +020014866static const struct alc_fixup alc269_fixups[] = {
14867 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014868 .type = ALC_FIXUP_VERBS,
14869 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020014870 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14871 {}
14872 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014873 },
Takashi Iwai74dc8902011-01-13 14:14:41 +010014874 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014875 .type = ALC_FIXUP_VERBS,
14876 .v.verbs = (const struct hda_verb[]) {
Kailang Yang27855912010-12-21 09:09:53 +010014877 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
14878 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
14879 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
14880 { }
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014881 },
14882 .chained = true,
14883 .chain_id = ALC269_FIXUP_SONY_VAIO
Kailang Yang27855912010-12-21 09:09:53 +010014884 },
David Henningsson145a9022010-09-16 10:07:53 +020014885 [ALC269_FIXUP_DELL_M101Z] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014886 .type = ALC_FIXUP_VERBS,
14887 .v.verbs = (const struct hda_verb[]) {
David Henningsson145a9022010-09-16 10:07:53 +020014888 /* Enables internal speaker */
14889 {0x20, AC_VERB_SET_COEF_INDEX, 13},
14890 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
14891 {}
14892 }
14893 },
David Henningsson022c92b2010-12-17 20:43:04 +010014894 [ALC269_FIXUP_SKU_IGNORE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014895 .type = ALC_FIXUP_SKU,
14896 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonfe67b242010-12-15 08:01:46 +010014897 },
David Henningssonac612402010-12-15 09:18:18 +010014898 [ALC269_FIXUP_ASUS_G73JW] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014899 .type = ALC_FIXUP_PINS,
14900 .v.pins = (const struct alc_pincfg[]) {
David Henningssonac612402010-12-15 09:18:18 +010014901 { 0x17, 0x99130111 }, /* subwoofer */
14902 { }
14903 }
14904 },
Kailang Yang357f9152011-01-12 08:12:52 +010014905 [ALC269_FIXUP_LENOVO_EAPD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014906 .type = ALC_FIXUP_VERBS,
14907 .v.verbs = (const struct hda_verb[]) {
Kailang Yang357f9152011-01-12 08:12:52 +010014908 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
14909 {}
14910 }
14911 },
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014912 [ALC275_FIXUP_SONY_HWEQ] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014913 .type = ALC_FIXUP_FUNC,
14914 .v.func = alc269_fixup_hweq,
14915 .chained = true,
14916 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014917 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014918};
14919
14920static struct snd_pci_quirk alc269_fixup_tbl[] = {
Takashi Iwai74dc8902011-01-13 14:14:41 +010014921 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014922 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
14923 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
Takashi Iwai7039c742010-12-23 16:35:34 +010014924 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningsson145a9022010-09-16 10:07:53 +020014925 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
David Henningsson022c92b2010-12-17 20:43:04 +010014926 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
David Henningssonded9f522011-01-26 11:46:12 +010014927 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
14928 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
14929 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
14930 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
David Henningssonac612402010-12-15 09:18:18 +010014931 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
Kailang Yang357f9152011-01-12 08:12:52 +010014932 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014933 {}
14934};
14935
14936
Kailang Yangf6a92242007-12-13 16:52:54 +010014937/*
14938 * configuration and preset
14939 */
Takashi Iwaiea734962011-01-17 11:29:34 +010014940static const char * const alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014941 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014942 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014943 [ALC269_AMIC] = "laptop-amic",
14944 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014945 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014946 [ALC269_LIFEBOOK] = "lifebook",
14947 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014948};
14949
14950static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014951 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014952 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014953 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014954 ALC269_AMIC),
14955 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14956 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14957 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14958 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14959 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14960 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14961 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14962 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14963 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
Chih-Wei Huangc790ad32011-02-25 11:14:31 +080014964 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269VB_AMIC),
Kailang Yang84898e82010-02-04 14:16:14 +010014965 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14966 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14967 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14968 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14969 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14970 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14971 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14972 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14973 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14974 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14975 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14976 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14977 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14978 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14979 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14980 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14981 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14982 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14983 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14984 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14985 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14986 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14987 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14988 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14989 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14990 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014991 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014992 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014993 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014994 ALC269_DMIC),
14995 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14996 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014997 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014998 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014999 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
15000 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
15001 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
15002 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
15003 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
15004 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010015005 {}
15006};
15007
15008static struct alc_config_preset alc269_presets[] = {
15009 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015010 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010015011 .init_verbs = { alc269_init_verbs },
15012 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15013 .dac_nids = alc269_dac_nids,
15014 .hp_nid = 0x03,
15015 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15016 .channel_mode = alc269_modes,
15017 .input_mux = &alc269_capture_source,
15018 },
Kailang Yang60db6b52008-08-26 13:13:00 +020015019 [ALC269_QUANTA_FL1] = {
15020 .mixers = { alc269_quanta_fl1_mixer },
15021 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
15022 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15023 .dac_nids = alc269_dac_nids,
15024 .hp_nid = 0x03,
15025 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15026 .channel_mode = alc269_modes,
15027 .input_mux = &alc269_capture_source,
15028 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015029 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020015030 .init_hook = alc269_quanta_fl1_init_hook,
15031 },
Kailang Yang84898e82010-02-04 14:16:14 +010015032 [ALC269_AMIC] = {
15033 .mixers = { alc269_laptop_mixer },
15034 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020015035 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015036 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015037 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15038 .dac_nids = alc269_dac_nids,
15039 .hp_nid = 0x03,
15040 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15041 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015042 .unsol_event = alc269_laptop_unsol_event,
15043 .setup = alc269_laptop_amic_setup,
15044 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015045 },
Kailang Yang84898e82010-02-04 14:16:14 +010015046 [ALC269_DMIC] = {
15047 .mixers = { alc269_laptop_mixer },
15048 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020015049 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015050 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015051 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15052 .dac_nids = alc269_dac_nids,
15053 .hp_nid = 0x03,
15054 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15055 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015056 .unsol_event = alc269_laptop_unsol_event,
15057 .setup = alc269_laptop_dmic_setup,
15058 .init_hook = alc269_laptop_inithook,
15059 },
15060 [ALC269VB_AMIC] = {
15061 .mixers = { alc269vb_laptop_mixer },
15062 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
15063 .init_verbs = { alc269vb_init_verbs,
15064 alc269vb_laptop_amic_init_verbs },
15065 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15066 .dac_nids = alc269_dac_nids,
15067 .hp_nid = 0x03,
15068 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15069 .channel_mode = alc269_modes,
15070 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020015071 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010015072 .init_hook = alc269_laptop_inithook,
15073 },
15074 [ALC269VB_DMIC] = {
15075 .mixers = { alc269vb_laptop_mixer },
15076 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15077 .init_verbs = { alc269vb_init_verbs,
15078 alc269vb_laptop_dmic_init_verbs },
15079 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15080 .dac_nids = alc269_dac_nids,
15081 .hp_nid = 0x03,
15082 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15083 .channel_mode = alc269_modes,
15084 .unsol_event = alc269_laptop_unsol_event,
15085 .setup = alc269vb_laptop_dmic_setup,
15086 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015087 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015088 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015089 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010015090 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015091 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015092 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015093 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15094 .dac_nids = alc269_dac_nids,
15095 .hp_nid = 0x03,
15096 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15097 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015098 .unsol_event = alc269_laptop_unsol_event,
15099 .setup = alc269_laptop_dmic_setup,
15100 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015101 },
Tony Vroon64154832008-11-06 15:08:49 +000015102 [ALC269_LIFEBOOK] = {
15103 .mixers = { alc269_lifebook_mixer },
15104 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
15105 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15106 .dac_nids = alc269_dac_nids,
15107 .hp_nid = 0x03,
15108 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15109 .channel_mode = alc269_modes,
15110 .input_mux = &alc269_capture_source,
15111 .unsol_event = alc269_lifebook_unsol_event,
15112 .init_hook = alc269_lifebook_init_hook,
15113 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020015114 [ALC271_ACER] = {
15115 .mixers = { alc269_asus_mixer },
15116 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15117 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
15118 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15119 .dac_nids = alc269_dac_nids,
15120 .adc_nids = alc262_dmic_adc_nids,
15121 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
15122 .capsrc_nids = alc262_dmic_capsrc_nids,
15123 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15124 .channel_mode = alc269_modes,
15125 .input_mux = &alc269_capture_source,
15126 .dig_out_nid = ALC880_DIGOUT_NID,
15127 .unsol_event = alc_sku_unsol_event,
15128 .setup = alc269vb_laptop_dmic_setup,
15129 .init_hook = alc_inithook,
15130 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015131};
15132
Kailang Yang977ddd62010-09-15 10:02:29 +020015133static int alc269_fill_coef(struct hda_codec *codec)
15134{
15135 int val;
15136
15137 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
15138 alc_write_coef_idx(codec, 0xf, 0x960b);
15139 alc_write_coef_idx(codec, 0xe, 0x8817);
15140 }
15141
15142 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
15143 alc_write_coef_idx(codec, 0xf, 0x960b);
15144 alc_write_coef_idx(codec, 0xe, 0x8814);
15145 }
15146
15147 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
15148 val = alc_read_coef_idx(codec, 0x04);
15149 /* Power up output pin */
15150 alc_write_coef_idx(codec, 0x04, val | (1<<11));
15151 }
15152
15153 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
15154 val = alc_read_coef_idx(codec, 0xd);
15155 if ((val & 0x0c00) >> 10 != 0x1) {
15156 /* Capless ramp up clock control */
15157 alc_write_coef_idx(codec, 0xd, val | 1<<10);
15158 }
15159 val = alc_read_coef_idx(codec, 0x17);
15160 if ((val & 0x01c0) >> 6 != 0x4) {
15161 /* Class D power on reset */
15162 alc_write_coef_idx(codec, 0x17, val | 1<<7);
15163 }
15164 }
15165 return 0;
15166}
15167
Kailang Yangf6a92242007-12-13 16:52:54 +010015168static int patch_alc269(struct hda_codec *codec)
15169{
15170 struct alc_spec *spec;
Kailang Yang48c88e82010-11-23 08:56:16 +010015171 int board_config, coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010015172 int err;
15173
15174 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15175 if (spec == NULL)
15176 return -ENOMEM;
15177
15178 codec->spec = spec;
15179
Kailang Yangda00c242010-03-19 11:23:45 +010015180 alc_auto_parse_customize_define(codec);
15181
Kailang Yangc793bec2010-12-21 09:14:13 +010015182 if (codec->vendor_id == 0x10ec0269) {
15183 coef = alc_read_coef_idx(codec, 0);
15184 if ((coef & 0x00f0) == 0x0010) {
15185 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
15186 spec->cdefine.platform_type == 1) {
15187 alc_codec_rename(codec, "ALC271X");
15188 spec->codec_variant = ALC269_TYPE_ALC271X;
15189 } else if ((coef & 0xf000) == 0x1000) {
15190 spec->codec_variant = ALC269_TYPE_ALC270;
15191 } else if ((coef & 0xf000) == 0x2000) {
15192 alc_codec_rename(codec, "ALC259");
15193 spec->codec_variant = ALC269_TYPE_ALC259;
15194 } else if ((coef & 0xf000) == 0x3000) {
15195 alc_codec_rename(codec, "ALC258");
15196 spec->codec_variant = ALC269_TYPE_ALC258;
15197 } else {
15198 alc_codec_rename(codec, "ALC269VB");
15199 spec->codec_variant = ALC269_TYPE_ALC269VB;
15200 }
15201 } else
15202 alc_fix_pll_init(codec, 0x20, 0x04, 15);
15203 alc269_fill_coef(codec);
15204 }
Kailang Yang977ddd62010-09-15 10:02:29 +020015205
Kailang Yangf6a92242007-12-13 16:52:54 +010015206 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
15207 alc269_models,
15208 alc269_cfg_tbl);
15209
15210 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015211 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15212 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010015213 board_config = ALC269_AUTO;
15214 }
15215
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015216 if (board_config == ALC269_AUTO) {
15217 alc_pick_fixup(codec, NULL, alc269_fixup_tbl, alc269_fixups);
15218 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
15219 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020015220
Kailang Yangf6a92242007-12-13 16:52:54 +010015221 if (board_config == ALC269_AUTO) {
15222 /* automatic parse from the BIOS config */
15223 err = alc269_parse_auto_config(codec);
15224 if (err < 0) {
15225 alc_free(codec);
15226 return err;
15227 } else if (!err) {
15228 printk(KERN_INFO
15229 "hda_codec: Cannot set up configuration "
15230 "from BIOS. Using base mode...\n");
15231 board_config = ALC269_BASIC;
15232 }
15233 }
15234
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015235 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020015236 err = snd_hda_attach_beep_device(codec, 0x1);
15237 if (err < 0) {
15238 alc_free(codec);
15239 return err;
15240 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015241 }
15242
Kailang Yangf6a92242007-12-13 16:52:54 +010015243 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015244 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010015245
Kailang Yang84898e82010-02-04 14:16:14 +010015246 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010015247 /* Due to a hardware problem on Lenovo Ideadpad, we need to
15248 * fix the sample rate of analog I/O to 44.1kHz
15249 */
15250 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
15251 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020015252 } else if (spec->dual_adc_switch) {
15253 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15254 /* switch ADC dynamically */
15255 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010015256 } else {
15257 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15258 spec->stream_analog_capture = &alc269_pcm_analog_capture;
15259 }
Kailang Yangf6a92242007-12-13 16:52:54 +010015260 spec->stream_digital_playback = &alc269_pcm_digital_playback;
15261 spec->stream_digital_capture = &alc269_pcm_digital_capture;
15262
Takashi Iwai66946352010-03-29 17:21:45 +020015263 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
Kailang Yang1657cbd2010-11-23 08:53:32 +010015264 if (spec->codec_variant == ALC269_TYPE_NORMAL) {
Takashi Iwai66946352010-03-29 17:21:45 +020015265 spec->adc_nids = alc269_adc_nids;
15266 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
15267 spec->capsrc_nids = alc269_capsrc_nids;
15268 } else {
15269 spec->adc_nids = alc269vb_adc_nids;
15270 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
15271 spec->capsrc_nids = alc269vb_capsrc_nids;
15272 }
Kailang Yang84898e82010-02-04 14:16:14 +010015273 }
15274
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015275 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015276 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015277 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010015278 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010015279
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015280 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaiff818c22010-04-12 08:59:25 +020015281
Takashi Iwai100d5eb2009-08-10 11:55:51 +020015282 spec->vmaster_nid = 0x02;
15283
Kailang Yangf6a92242007-12-13 16:52:54 +010015284 codec->patch_ops = alc_patch_ops;
Kailang Yang977ddd62010-09-15 10:02:29 +020015285#ifdef CONFIG_SND_HDA_POWER_SAVE
15286 codec->patch_ops.suspend = alc269_suspend;
15287#endif
15288#ifdef SND_HDA_NEEDS_RESUME
15289 codec->patch_ops.resume = alc269_resume;
15290#endif
Kailang Yangf6a92242007-12-13 16:52:54 +010015291 if (board_config == ALC269_AUTO)
15292 spec->init_hook = alc269_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020015293
15294 alc_init_jacks(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010015295#ifdef CONFIG_SND_HDA_POWER_SAVE
15296 if (!spec->loopback.amplist)
15297 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020015298 if (alc269_mic2_for_mute_led(codec))
15299 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010015300#endif
15301
15302 return 0;
15303}
15304
15305/*
Kailang Yangdf694da2005-12-05 19:42:22 +010015306 * ALC861 channel source setting (2/6 channel selection for 3-stack)
15307 */
15308
15309/*
15310 * set the path ways for 2 channel output
15311 * need to set the codec line out and mic 1 pin widgets to inputs
15312 */
15313static struct hda_verb alc861_threestack_ch2_init[] = {
15314 /* set pin widget 1Ah (line in) for input */
15315 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015316 /* set pin widget 18h (mic1/2) for input, for mic also enable
15317 * the vref
15318 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015319 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15320
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015321 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15322#if 0
15323 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15324 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15325#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015326 { } /* end */
15327};
15328/*
15329 * 6ch mode
15330 * need to set the codec line out and mic 1 pin widgets to outputs
15331 */
15332static struct hda_verb alc861_threestack_ch6_init[] = {
15333 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15334 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15335 /* set pin widget 18h (mic1) for output (CLFE)*/
15336 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15337
15338 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015339 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015340
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015341 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15342#if 0
15343 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15344 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15345#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015346 { } /* end */
15347};
15348
15349static struct hda_channel_mode alc861_threestack_modes[2] = {
15350 { 2, alc861_threestack_ch2_init },
15351 { 6, alc861_threestack_ch6_init },
15352};
Takashi Iwai22309c32006-08-09 16:57:28 +020015353/* Set mic1 as input and unmute the mixer */
15354static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
15355 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15356 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15357 { } /* end */
15358};
15359/* Set mic1 as output and mute mixer */
15360static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
15361 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15362 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15363 { } /* end */
15364};
15365
15366static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
15367 { 2, alc861_uniwill_m31_ch2_init },
15368 { 4, alc861_uniwill_m31_ch4_init },
15369};
Kailang Yangdf694da2005-12-05 19:42:22 +010015370
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015371/* Set mic1 and line-in as input and unmute the mixer */
15372static struct hda_verb alc861_asus_ch2_init[] = {
15373 /* set pin widget 1Ah (line in) for input */
15374 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015375 /* set pin widget 18h (mic1/2) for input, for mic also enable
15376 * the vref
15377 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015378 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15379
15380 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15381#if 0
15382 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15383 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15384#endif
15385 { } /* end */
15386};
15387/* Set mic1 nad line-in as output and mute mixer */
15388static struct hda_verb alc861_asus_ch6_init[] = {
15389 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15390 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15391 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15392 /* set pin widget 18h (mic1) for output (CLFE)*/
15393 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15394 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15395 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
15396 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
15397
15398 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15399#if 0
15400 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15401 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15402#endif
15403 { } /* end */
15404};
15405
15406static struct hda_channel_mode alc861_asus_modes[2] = {
15407 { 2, alc861_asus_ch2_init },
15408 { 6, alc861_asus_ch6_init },
15409};
15410
Kailang Yangdf694da2005-12-05 19:42:22 +010015411/* patch-ALC861 */
15412
15413static struct snd_kcontrol_new alc861_base_mixer[] = {
15414 /* output mixer control */
15415 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15416 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15417 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15418 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15419 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15420
15421 /*Input mixer control */
15422 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15423 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15424 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15425 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15426 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15427 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15428 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15429 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15430 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15431 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015432
Kailang Yangdf694da2005-12-05 19:42:22 +010015433 { } /* end */
15434};
15435
15436static struct snd_kcontrol_new alc861_3ST_mixer[] = {
15437 /* output mixer control */
15438 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15439 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15440 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15441 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15442 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15443
15444 /* Input mixer control */
15445 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15446 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15447 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15448 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15449 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15450 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15451 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15452 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15453 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15454 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015455
Kailang Yangdf694da2005-12-05 19:42:22 +010015456 {
15457 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15458 .name = "Channel Mode",
15459 .info = alc_ch_mode_info,
15460 .get = alc_ch_mode_get,
15461 .put = alc_ch_mode_put,
15462 .private_value = ARRAY_SIZE(alc861_threestack_modes),
15463 },
15464 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015465};
15466
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015467static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015468 /* output mixer control */
15469 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15470 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15471 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015472
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015473 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015474};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015475
Takashi Iwai22309c32006-08-09 16:57:28 +020015476static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
15477 /* output mixer control */
15478 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15479 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15480 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15481 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15482 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15483
15484 /* Input mixer control */
15485 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15486 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15487 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15488 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15489 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15490 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15491 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15492 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15493 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15494 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015495
Takashi Iwai22309c32006-08-09 16:57:28 +020015496 {
15497 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15498 .name = "Channel Mode",
15499 .info = alc_ch_mode_info,
15500 .get = alc_ch_mode_get,
15501 .put = alc_ch_mode_put,
15502 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15503 },
15504 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015505};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015506
15507static struct snd_kcontrol_new alc861_asus_mixer[] = {
15508 /* output mixer control */
15509 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15510 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15511 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15512 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15513 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15514
15515 /* Input mixer control */
15516 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15517 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15518 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15519 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15520 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15521 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15522 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15523 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15524 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015525 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15526
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015527 {
15528 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15529 .name = "Channel Mode",
15530 .info = alc_ch_mode_info,
15531 .get = alc_ch_mode_get,
15532 .put = alc_ch_mode_put,
15533 .private_value = ARRAY_SIZE(alc861_asus_modes),
15534 },
15535 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015536};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015537
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015538/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015539static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015540 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15541 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015542 { }
15543};
15544
Kailang Yangdf694da2005-12-05 19:42:22 +010015545/*
15546 * generic initialization of ADC, input mixers and output mixers
15547 */
15548static struct hda_verb alc861_base_init_verbs[] = {
15549 /*
15550 * Unmute ADC0 and set the default input to mic-in
15551 */
15552 /* port-A for surround (rear panel) */
15553 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15554 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15555 /* port-B for mic-in (rear panel) with vref */
15556 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15557 /* port-C for line-in (rear panel) */
15558 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15559 /* port-D for Front */
15560 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15561 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15562 /* port-E for HP out (front panel) */
15563 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15564 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015565 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015566 /* port-F for mic-in (front panel) with vref */
15567 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15568 /* port-G for CLFE (rear panel) */
15569 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15570 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15571 /* port-H for side (rear panel) */
15572 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15573 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15574 /* CD-in */
15575 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15576 /* route front mic to ADC1*/
15577 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15578 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015579
Kailang Yangdf694da2005-12-05 19:42:22 +010015580 /* Unmute DAC0~3 & spdif out*/
15581 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15582 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15583 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15584 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15585 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015586
Kailang Yangdf694da2005-12-05 19:42:22 +010015587 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15588 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15589 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15590 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15591 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015592
Kailang Yangdf694da2005-12-05 19:42:22 +010015593 /* Unmute Stereo Mixer 15 */
15594 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15595 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15596 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015597 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015598
15599 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15600 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15601 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15602 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15603 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15604 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15605 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15606 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015607 /* hp used DAC 3 (Front) */
15608 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015609 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15610
15611 { }
15612};
15613
15614static struct hda_verb alc861_threestack_init_verbs[] = {
15615 /*
15616 * Unmute ADC0 and set the default input to mic-in
15617 */
15618 /* port-A for surround (rear panel) */
15619 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15620 /* port-B for mic-in (rear panel) with vref */
15621 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15622 /* port-C for line-in (rear panel) */
15623 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15624 /* port-D for Front */
15625 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15626 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15627 /* port-E for HP out (front panel) */
15628 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15629 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015630 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015631 /* port-F for mic-in (front panel) with vref */
15632 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15633 /* port-G for CLFE (rear panel) */
15634 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15635 /* port-H for side (rear panel) */
15636 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15637 /* CD-in */
15638 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15639 /* route front mic to ADC1*/
15640 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15641 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15642 /* Unmute DAC0~3 & spdif out*/
15643 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15644 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15645 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15646 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15647 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015648
Kailang Yangdf694da2005-12-05 19:42:22 +010015649 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15650 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15651 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15652 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15653 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015654
Kailang Yangdf694da2005-12-05 19:42:22 +010015655 /* Unmute Stereo Mixer 15 */
15656 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15657 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15658 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015659 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015660
15661 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15662 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15663 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15664 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15665 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15666 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15667 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15668 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015669 /* hp used DAC 3 (Front) */
15670 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015671 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15672 { }
15673};
Takashi Iwai22309c32006-08-09 16:57:28 +020015674
15675static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15676 /*
15677 * Unmute ADC0 and set the default input to mic-in
15678 */
15679 /* port-A for surround (rear panel) */
15680 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15681 /* port-B for mic-in (rear panel) with vref */
15682 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15683 /* port-C for line-in (rear panel) */
15684 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15685 /* port-D for Front */
15686 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15687 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15688 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015689 /* this has to be set to VREF80 */
15690 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015691 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015692 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015693 /* port-F for mic-in (front panel) with vref */
15694 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15695 /* port-G for CLFE (rear panel) */
15696 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15697 /* port-H for side (rear panel) */
15698 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15699 /* CD-in */
15700 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15701 /* route front mic to ADC1*/
15702 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15703 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15704 /* Unmute DAC0~3 & spdif out*/
15705 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15706 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15707 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15708 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15709 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015710
Takashi Iwai22309c32006-08-09 16:57:28 +020015711 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15712 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15713 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15714 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15715 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015716
Takashi Iwai22309c32006-08-09 16:57:28 +020015717 /* Unmute Stereo Mixer 15 */
15718 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15719 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15720 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015721 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015722
15723 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15724 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15725 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15726 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15727 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15728 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15729 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15730 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015731 /* hp used DAC 3 (Front) */
15732 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015733 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15734 { }
15735};
15736
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015737static struct hda_verb alc861_asus_init_verbs[] = {
15738 /*
15739 * Unmute ADC0 and set the default input to mic-in
15740 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015741 /* port-A for surround (rear panel)
15742 * according to codec#0 this is the HP jack
15743 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015744 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15745 /* route front PCM to HP */
15746 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15747 /* port-B for mic-in (rear panel) with vref */
15748 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15749 /* port-C for line-in (rear panel) */
15750 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15751 /* port-D for Front */
15752 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15753 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15754 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015755 /* this has to be set to VREF80 */
15756 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015757 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015758 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015759 /* port-F for mic-in (front panel) with vref */
15760 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15761 /* port-G for CLFE (rear panel) */
15762 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15763 /* port-H for side (rear panel) */
15764 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15765 /* CD-in */
15766 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15767 /* route front mic to ADC1*/
15768 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15769 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15770 /* Unmute DAC0~3 & spdif out*/
15771 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15772 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15773 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15774 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15775 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15776 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15777 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15778 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15779 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15780 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015781
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015782 /* Unmute Stereo Mixer 15 */
15783 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15784 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15785 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015786 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015787
15788 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15789 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15790 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15791 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15792 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15793 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15794 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15795 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015796 /* hp used DAC 3 (Front) */
15797 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015798 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15799 { }
15800};
15801
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015802/* additional init verbs for ASUS laptops */
15803static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15804 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15805 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15806 { }
15807};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015808
Kailang Yangdf694da2005-12-05 19:42:22 +010015809/*
15810 * generic initialization of ADC, input mixers and output mixers
15811 */
15812static struct hda_verb alc861_auto_init_verbs[] = {
15813 /*
15814 * Unmute ADC0 and set the default input to mic-in
15815 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015816 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015817 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015818
Kailang Yangdf694da2005-12-05 19:42:22 +010015819 /* Unmute DAC0~3 & spdif out*/
15820 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15821 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15822 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15823 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15824 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015825
Kailang Yangdf694da2005-12-05 19:42:22 +010015826 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15827 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15828 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15829 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15830 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015831
Kailang Yangdf694da2005-12-05 19:42:22 +010015832 /* Unmute Stereo Mixer 15 */
15833 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15834 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15835 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15836 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15837
Takashi Iwai1c209302009-07-22 15:17:45 +020015838 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15839 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15840 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15841 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15842 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15843 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15844 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15845 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015846
15847 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15848 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015849 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15850 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015851 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15852 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015853 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15854 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015855
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015856 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015857
15858 { }
15859};
15860
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015861static struct hda_verb alc861_toshiba_init_verbs[] = {
15862 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015863
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015864 { }
15865};
15866
15867/* toggle speaker-output according to the hp-jack state */
15868static void alc861_toshiba_automute(struct hda_codec *codec)
15869{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015870 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015871
Takashi Iwai47fd8302007-08-10 17:11:07 +020015872 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15873 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15874 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15875 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015876}
15877
15878static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15879 unsigned int res)
15880{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015881 if ((res >> 26) == ALC880_HP_EVENT)
15882 alc861_toshiba_automute(codec);
15883}
15884
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015885/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015886#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15887#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15888#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15889#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15890
15891
15892#define ALC861_DIGOUT_NID 0x07
15893
15894static struct hda_channel_mode alc861_8ch_modes[1] = {
15895 { 8, NULL }
15896};
15897
15898static hda_nid_t alc861_dac_nids[4] = {
15899 /* front, surround, clfe, side */
15900 0x03, 0x06, 0x05, 0x04
15901};
15902
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015903static hda_nid_t alc660_dac_nids[3] = {
15904 /* front, clfe, surround */
15905 0x03, 0x05, 0x06
15906};
15907
Kailang Yangdf694da2005-12-05 19:42:22 +010015908static hda_nid_t alc861_adc_nids[1] = {
15909 /* ADC0-2 */
15910 0x08,
15911};
15912
15913static struct hda_input_mux alc861_capture_source = {
15914 .num_items = 5,
15915 .items = {
15916 { "Mic", 0x0 },
15917 { "Front Mic", 0x3 },
15918 { "Line", 0x1 },
15919 { "CD", 0x4 },
15920 { "Mixer", 0x5 },
15921 },
15922};
15923
Takashi Iwai1c209302009-07-22 15:17:45 +020015924static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15925{
15926 struct alc_spec *spec = codec->spec;
15927 hda_nid_t mix, srcs[5];
15928 int i, j, num;
15929
15930 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15931 return 0;
15932 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15933 if (num < 0)
15934 return 0;
15935 for (i = 0; i < num; i++) {
15936 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015937 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015938 if (type != AC_WID_AUD_OUT)
15939 continue;
15940 for (j = 0; j < spec->multiout.num_dacs; j++)
15941 if (spec->multiout.dac_nids[j] == srcs[i])
15942 break;
15943 if (j >= spec->multiout.num_dacs)
15944 return srcs[i];
15945 }
15946 return 0;
15947}
15948
Kailang Yangdf694da2005-12-05 19:42:22 +010015949/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015950static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015951 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015952{
Takashi Iwai1c209302009-07-22 15:17:45 +020015953 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015954 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015955 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015956
15957 spec->multiout.dac_nids = spec->private_dac_nids;
15958 for (i = 0; i < cfg->line_outs; i++) {
15959 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015960 dac = alc861_look_for_dac(codec, nid);
15961 if (!dac)
15962 continue;
15963 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015964 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015965 return 0;
15966}
15967
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015968static int __alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15969 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015970{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015971 return __add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015972 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15973}
15974
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015975#define alc861_create_out_sw(codec, pfx, nid, chs) \
15976 __alc861_create_out_sw(codec, pfx, nid, 0, chs)
15977
Takashi Iwai1c209302009-07-22 15:17:45 +020015978/* add playback controls from the parsed DAC table */
15979static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15980 const struct auto_pin_cfg *cfg)
15981{
15982 struct alc_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +010015983 static const char * const chname[4] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015984 "Front", "Surround", NULL /*CLFE*/, "Side"
15985 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015986 const char *pfx = alc_get_line_out_pfx(cfg, true);
Kailang Yangdf694da2005-12-05 19:42:22 +010015987 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015988 int i, err;
15989
Kailang Yangdf694da2005-12-05 19:42:22 +010015990 for (i = 0; i < cfg->line_outs; i++) {
15991 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015992 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015993 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015994 if (!pfx && i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015995 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015996 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015997 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015998 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015999 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016000 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016001 return err;
16002 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016003 const char *name = pfx;
16004 if (!name)
16005 name = chname[i];
16006 err = __alc861_create_out_sw(codec, name, nid, i, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016007 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016008 return err;
16009 }
16010 }
16011 return 0;
16012}
16013
Takashi Iwai1c209302009-07-22 15:17:45 +020016014static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010016015{
Takashi Iwai1c209302009-07-22 15:17:45 +020016016 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016017 int err;
16018 hda_nid_t nid;
16019
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016020 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010016021 return 0;
16022
16023 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020016024 nid = alc861_look_for_dac(codec, pin);
16025 if (nid) {
16026 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
16027 if (err < 0)
16028 return err;
16029 spec->multiout.hp_nid = nid;
16030 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016031 }
16032 return 0;
16033}
16034
16035/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016036static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016037 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010016038{
Takashi Iwai05f5f472009-08-25 13:10:18 +020016039 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010016040}
16041
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016042static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
16043 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020016044 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010016045{
Takashi Iwai1c209302009-07-22 15:17:45 +020016046 hda_nid_t mix, srcs[5];
16047 int i, num;
16048
Jacek Luczak564c5be2008-05-03 18:41:23 +020016049 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
16050 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020016051 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020016052 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020016053 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
16054 return;
16055 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
16056 if (num < 0)
16057 return;
16058 for (i = 0; i < num; i++) {
16059 unsigned int mute;
16060 if (srcs[i] == dac || srcs[i] == 0x15)
16061 mute = AMP_IN_UNMUTE(i);
16062 else
16063 mute = AMP_IN_MUTE(i);
16064 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16065 mute);
16066 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016067}
16068
16069static void alc861_auto_init_multi_out(struct hda_codec *codec)
16070{
16071 struct alc_spec *spec = codec->spec;
16072 int i;
16073
16074 for (i = 0; i < spec->autocfg.line_outs; i++) {
16075 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016076 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016077 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016078 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016079 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016080 }
16081}
16082
16083static void alc861_auto_init_hp_out(struct hda_codec *codec)
16084{
16085 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016086
Takashi Iwai15870f02009-10-05 08:25:13 +020016087 if (spec->autocfg.hp_outs)
16088 alc861_auto_set_output_and_unmute(codec,
16089 spec->autocfg.hp_pins[0],
16090 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020016091 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020016092 if (spec->autocfg.speaker_outs)
16093 alc861_auto_set_output_and_unmute(codec,
16094 spec->autocfg.speaker_pins[0],
16095 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020016096 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016097}
16098
16099static void alc861_auto_init_analog_input(struct hda_codec *codec)
16100{
16101 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016102 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010016103 int i;
16104
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016105 for (i = 0; i < cfg->num_inputs; i++) {
16106 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010016107 if (nid >= 0x0c && nid <= 0x11)
Takashi Iwai30ea0982010-09-16 18:47:56 +020016108 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016109 }
16110}
16111
16112/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016113/* return 1 if successful, 0 if the proper config is not found,
16114 * or a negative error code
16115 */
Kailang Yangdf694da2005-12-05 19:42:22 +010016116static int alc861_parse_auto_config(struct hda_codec *codec)
16117{
16118 struct alc_spec *spec = codec->spec;
16119 int err;
16120 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
16121
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016122 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16123 alc861_ignore);
16124 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016125 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016126 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010016127 return 0; /* can't find valid BIOS pin config */
16128
Takashi Iwai1c209302009-07-22 15:17:45 +020016129 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016130 if (err < 0)
16131 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016132 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016133 if (err < 0)
16134 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016135 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016136 if (err < 0)
16137 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016138 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016139 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016140 return err;
16141
16142 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16143
Takashi Iwai757899a2010-07-30 10:48:14 +020016144 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016145
Takashi Iwai603c4012008-07-30 15:01:44 +020016146 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016147 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010016148
Takashi Iwaid88897e2008-10-31 15:01:37 +010016149 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010016150
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020016151 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016152 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010016153
16154 spec->adc_nids = alc861_adc_nids;
16155 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016156 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016157
Kailang Yang6227cdc2010-02-25 08:36:52 +010016158 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016159
Kailang Yangdf694da2005-12-05 19:42:22 +010016160 return 1;
16161}
16162
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016163/* additional initialization for auto-configuration model */
16164static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010016165{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016166 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016167 alc861_auto_init_multi_out(codec);
16168 alc861_auto_init_hp_out(codec);
16169 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020016170 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016171 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016172 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016173}
16174
Takashi Iwaicb53c622007-08-10 17:21:45 +020016175#ifdef CONFIG_SND_HDA_POWER_SAVE
16176static struct hda_amp_list alc861_loopbacks[] = {
16177 { 0x15, HDA_INPUT, 0 },
16178 { 0x15, HDA_INPUT, 1 },
16179 { 0x15, HDA_INPUT, 2 },
16180 { 0x15, HDA_INPUT, 3 },
16181 { } /* end */
16182};
16183#endif
16184
Kailang Yangdf694da2005-12-05 19:42:22 +010016185
16186/*
16187 * configuration and preset
16188 */
Takashi Iwaiea734962011-01-17 11:29:34 +010016189static const char * const alc861_models[ALC861_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016190 [ALC861_3ST] = "3stack",
16191 [ALC660_3ST] = "3stack-660",
16192 [ALC861_3ST_DIG] = "3stack-dig",
16193 [ALC861_6ST_DIG] = "6stack-dig",
16194 [ALC861_UNIWILL_M31] = "uniwill-m31",
16195 [ALC861_TOSHIBA] = "toshiba",
16196 [ALC861_ASUS] = "asus",
16197 [ALC861_ASUS_LAPTOP] = "asus-laptop",
16198 [ALC861_AUTO] = "auto",
16199};
16200
16201static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010016202 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016203 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16204 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16205 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016206 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020016207 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010016208 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020016209 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
16210 * Any other models that need this preset?
16211 */
16212 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020016213 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
16214 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016215 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
16216 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
16217 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
16218 /* FIXME: the below seems conflict */
16219 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
16220 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
16221 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010016222 {}
16223};
16224
16225static struct alc_config_preset alc861_presets[] = {
16226 [ALC861_3ST] = {
16227 .mixers = { alc861_3ST_mixer },
16228 .init_verbs = { alc861_threestack_init_verbs },
16229 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16230 .dac_nids = alc861_dac_nids,
16231 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16232 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016233 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016234 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16235 .adc_nids = alc861_adc_nids,
16236 .input_mux = &alc861_capture_source,
16237 },
16238 [ALC861_3ST_DIG] = {
16239 .mixers = { alc861_base_mixer },
16240 .init_verbs = { alc861_threestack_init_verbs },
16241 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16242 .dac_nids = alc861_dac_nids,
16243 .dig_out_nid = ALC861_DIGOUT_NID,
16244 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16245 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016246 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016247 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16248 .adc_nids = alc861_adc_nids,
16249 .input_mux = &alc861_capture_source,
16250 },
16251 [ALC861_6ST_DIG] = {
16252 .mixers = { alc861_base_mixer },
16253 .init_verbs = { alc861_base_init_verbs },
16254 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16255 .dac_nids = alc861_dac_nids,
16256 .dig_out_nid = ALC861_DIGOUT_NID,
16257 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
16258 .channel_mode = alc861_8ch_modes,
16259 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16260 .adc_nids = alc861_adc_nids,
16261 .input_mux = &alc861_capture_source,
16262 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016263 [ALC660_3ST] = {
16264 .mixers = { alc861_3ST_mixer },
16265 .init_verbs = { alc861_threestack_init_verbs },
16266 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
16267 .dac_nids = alc660_dac_nids,
16268 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16269 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016270 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016271 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16272 .adc_nids = alc861_adc_nids,
16273 .input_mux = &alc861_capture_source,
16274 },
Takashi Iwai22309c32006-08-09 16:57:28 +020016275 [ALC861_UNIWILL_M31] = {
16276 .mixers = { alc861_uniwill_m31_mixer },
16277 .init_verbs = { alc861_uniwill_m31_init_verbs },
16278 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16279 .dac_nids = alc861_dac_nids,
16280 .dig_out_nid = ALC861_DIGOUT_NID,
16281 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
16282 .channel_mode = alc861_uniwill_m31_modes,
16283 .need_dac_fix = 1,
16284 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16285 .adc_nids = alc861_adc_nids,
16286 .input_mux = &alc861_capture_source,
16287 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016288 [ALC861_TOSHIBA] = {
16289 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016290 .init_verbs = { alc861_base_init_verbs,
16291 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016292 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16293 .dac_nids = alc861_dac_nids,
16294 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16295 .channel_mode = alc883_3ST_2ch_modes,
16296 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16297 .adc_nids = alc861_adc_nids,
16298 .input_mux = &alc861_capture_source,
16299 .unsol_event = alc861_toshiba_unsol_event,
16300 .init_hook = alc861_toshiba_automute,
16301 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020016302 [ALC861_ASUS] = {
16303 .mixers = { alc861_asus_mixer },
16304 .init_verbs = { alc861_asus_init_verbs },
16305 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16306 .dac_nids = alc861_dac_nids,
16307 .dig_out_nid = ALC861_DIGOUT_NID,
16308 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
16309 .channel_mode = alc861_asus_modes,
16310 .need_dac_fix = 1,
16311 .hp_nid = 0x06,
16312 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16313 .adc_nids = alc861_adc_nids,
16314 .input_mux = &alc861_capture_source,
16315 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010016316 [ALC861_ASUS_LAPTOP] = {
16317 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
16318 .init_verbs = { alc861_asus_init_verbs,
16319 alc861_asus_laptop_init_verbs },
16320 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16321 .dac_nids = alc861_dac_nids,
16322 .dig_out_nid = ALC861_DIGOUT_NID,
16323 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16324 .channel_mode = alc883_3ST_2ch_modes,
16325 .need_dac_fix = 1,
16326 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16327 .adc_nids = alc861_adc_nids,
16328 .input_mux = &alc861_capture_source,
16329 },
16330};
Kailang Yangdf694da2005-12-05 19:42:22 +010016331
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016332/* Pin config fixes */
16333enum {
16334 PINFIX_FSC_AMILO_PI1505,
16335};
16336
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016337static const struct alc_fixup alc861_fixups[] = {
16338 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016339 .type = ALC_FIXUP_PINS,
16340 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020016341 { 0x0b, 0x0221101f }, /* HP */
16342 { 0x0f, 0x90170310 }, /* speaker */
16343 { }
16344 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016345 },
16346};
16347
16348static struct snd_pci_quirk alc861_fixup_tbl[] = {
16349 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
16350 {}
16351};
Kailang Yangdf694da2005-12-05 19:42:22 +010016352
16353static int patch_alc861(struct hda_codec *codec)
16354{
16355 struct alc_spec *spec;
16356 int board_config;
16357 int err;
16358
Robert P. J. Daydc041e02006-12-19 14:44:15 +010016359 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010016360 if (spec == NULL)
16361 return -ENOMEM;
16362
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016363 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016364
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016365 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
16366 alc861_models,
16367 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016368
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016369 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016370 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16371 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010016372 board_config = ALC861_AUTO;
16373 }
16374
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016375 if (board_config == ALC861_AUTO) {
16376 alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
16377 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
16378 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016379
Kailang Yangdf694da2005-12-05 19:42:22 +010016380 if (board_config == ALC861_AUTO) {
16381 /* automatic parse from the BIOS config */
16382 err = alc861_parse_auto_config(codec);
16383 if (err < 0) {
16384 alc_free(codec);
16385 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016386 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016387 printk(KERN_INFO
16388 "hda_codec: Cannot set up configuration "
16389 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010016390 board_config = ALC861_3ST_DIG;
16391 }
16392 }
16393
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016394 err = snd_hda_attach_beep_device(codec, 0x23);
16395 if (err < 0) {
16396 alc_free(codec);
16397 return err;
16398 }
16399
Kailang Yangdf694da2005-12-05 19:42:22 +010016400 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016401 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016402
Kailang Yangdf694da2005-12-05 19:42:22 +010016403 spec->stream_analog_playback = &alc861_pcm_analog_playback;
16404 spec->stream_analog_capture = &alc861_pcm_analog_capture;
16405
Kailang Yangdf694da2005-12-05 19:42:22 +010016406 spec->stream_digital_playback = &alc861_pcm_digital_playback;
16407 spec->stream_digital_capture = &alc861_pcm_digital_capture;
16408
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010016409 if (!spec->cap_mixer)
16410 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016411 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
16412
Takashi Iwai2134ea42008-01-10 16:53:55 +010016413 spec->vmaster_nid = 0x03;
16414
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016415 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016416
Kailang Yangdf694da2005-12-05 19:42:22 +010016417 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050016418 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016419 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016420#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050016421 spec->power_hook = alc_power_eapd;
16422#endif
16423 }
16424#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020016425 if (!spec->loopback.amplist)
16426 spec->loopback.amplist = alc861_loopbacks;
16427#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020016428
Kailang Yangdf694da2005-12-05 19:42:22 +010016429 return 0;
16430}
16431
16432/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016433 * ALC861-VD support
16434 *
16435 * Based on ALC882
16436 *
16437 * In addition, an independent DAC
16438 */
16439#define ALC861VD_DIGOUT_NID 0x06
16440
16441static hda_nid_t alc861vd_dac_nids[4] = {
16442 /* front, surr, clfe, side surr */
16443 0x02, 0x03, 0x04, 0x05
16444};
16445
16446/* dac_nids for ALC660vd are in a different order - according to
16447 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016448 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016449 * of ALC660vd codecs, but for now there is only 3stack mixer
16450 * - and it is the same as in 861vd.
16451 * adc_nids in ALC660vd are (is) the same as in 861vd
16452 */
16453static hda_nid_t alc660vd_dac_nids[3] = {
16454 /* front, rear, clfe, rear_surr */
16455 0x02, 0x04, 0x03
16456};
16457
16458static hda_nid_t alc861vd_adc_nids[1] = {
16459 /* ADC0 */
16460 0x09,
16461};
16462
Takashi Iwaie1406342008-02-11 18:32:32 +010016463static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
16464
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016465/* input MUX */
16466/* FIXME: should be a matrix-type input source selection */
16467static struct hda_input_mux alc861vd_capture_source = {
16468 .num_items = 4,
16469 .items = {
16470 { "Mic", 0x0 },
16471 { "Front Mic", 0x1 },
16472 { "Line", 0x2 },
16473 { "CD", 0x4 },
16474 },
16475};
16476
Kailang Yang272a5272007-05-14 11:00:38 +020016477static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016478 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016479 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +010016480 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010016481 { "Internal Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016482 },
16483};
16484
Kailang Yangd1a991a2007-08-15 16:21:59 +020016485static struct hda_input_mux alc861vd_hp_capture_source = {
16486 .num_items = 2,
16487 .items = {
16488 { "Front Mic", 0x0 },
16489 { "ATAPI Mic", 0x1 },
16490 },
16491};
16492
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016493/*
16494 * 2ch mode
16495 */
16496static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16497 { 2, NULL }
16498};
16499
16500/*
16501 * 6ch mode
16502 */
16503static struct hda_verb alc861vd_6stack_ch6_init[] = {
16504 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16505 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16506 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16507 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16508 { } /* end */
16509};
16510
16511/*
16512 * 8ch mode
16513 */
16514static struct hda_verb alc861vd_6stack_ch8_init[] = {
16515 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16516 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16517 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16518 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16519 { } /* end */
16520};
16521
16522static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16523 { 6, alc861vd_6stack_ch6_init },
16524 { 8, alc861vd_6stack_ch8_init },
16525};
16526
16527static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16528 {
16529 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16530 .name = "Channel Mode",
16531 .info = alc_ch_mode_info,
16532 .get = alc_ch_mode_get,
16533 .put = alc_ch_mode_put,
16534 },
16535 { } /* end */
16536};
16537
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016538/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16539 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16540 */
16541static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16542 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16543 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16544
16545 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16546 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16547
16548 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16549 HDA_OUTPUT),
16550 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16551 HDA_OUTPUT),
16552 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16553 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16554
16555 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16556 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16557
16558 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16559
David Henningsson5f99f862011-01-04 15:24:24 +010016560 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016561 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16562 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16563
David Henningsson5f99f862011-01-04 15:24:24 +010016564 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016565 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16566 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16567
16568 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16569 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16570
16571 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16572 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16573
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016574 { } /* end */
16575};
16576
16577static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16578 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16579 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16580
16581 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16582
David Henningsson5f99f862011-01-04 15:24:24 +010016583 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016584 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16585 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16586
David Henningsson5f99f862011-01-04 15:24:24 +010016587 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016588 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16589 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16590
16591 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16592 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16593
16594 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16595 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16596
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016597 { } /* end */
16598};
16599
Kailang Yangbdd148a2007-05-08 15:19:08 +020016600static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16601 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16602 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16603 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16604
16605 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16606
David Henningsson5f99f862011-01-04 15:24:24 +010016607 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016608 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16609 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16610
David Henningsson5f99f862011-01-04 15:24:24 +010016611 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016612 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16613 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16614
16615 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16616 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16617
16618 { } /* end */
16619};
16620
Tobin Davisb419f342008-03-07 11:57:51 +010016621/* Pin assignment: Speaker=0x14, HP = 0x15,
David Henningsson8607f7c2010-12-20 14:43:54 +010016622 * Mic=0x18, Internal Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016623 */
16624static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016625 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16626 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016627 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16628 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016629 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +010016630 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16631 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016632 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010016633 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16634 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016635 { } /* end */
16636};
16637
Kailang Yangd1a991a2007-08-15 16:21:59 +020016638/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16639 * Front Mic=0x18, ATAPI Mic = 0x19,
16640 */
16641static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16642 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16643 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16644 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16645 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16646 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16647 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16648 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16649 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016650
Kailang Yangd1a991a2007-08-15 16:21:59 +020016651 { } /* end */
16652};
16653
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016654/*
16655 * generic initialization of ADC, input mixers and output mixers
16656 */
16657static struct hda_verb alc861vd_volume_init_verbs[] = {
16658 /*
16659 * Unmute ADC0 and set the default input to mic-in
16660 */
16661 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16662 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16663
16664 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16665 * the analog-loopback mixer widget
16666 */
16667 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016668 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16669 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16670 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16671 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16672 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016673
16674 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016675 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16676 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16677 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016678 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016679
16680 /*
16681 * Set up output mixers (0x02 - 0x05)
16682 */
16683 /* set vol=0 to output mixers */
16684 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16685 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16686 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16687 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16688
16689 /* set up input amps for analog loopback */
16690 /* Amp Indices: DAC = 0, mixer = 1 */
16691 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16692 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16693 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16694 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16695 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16696 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16697 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16698 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16699
16700 { }
16701};
16702
16703/*
16704 * 3-stack pin configuration:
16705 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16706 */
16707static struct hda_verb alc861vd_3stack_init_verbs[] = {
16708 /*
16709 * Set pin mode and muting
16710 */
16711 /* set front pin widgets 0x14 for output */
16712 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16713 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16714 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16715
16716 /* Mic (rear) pin: input vref at 80% */
16717 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16718 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16719 /* Front Mic pin: input vref at 80% */
16720 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16721 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16722 /* Line In pin: input */
16723 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16724 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16725 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16726 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16727 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16728 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16729 /* CD pin widget for input */
16730 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16731
16732 { }
16733};
16734
16735/*
16736 * 6-stack pin configuration:
16737 */
16738static struct hda_verb alc861vd_6stack_init_verbs[] = {
16739 /*
16740 * Set pin mode and muting
16741 */
16742 /* set front pin widgets 0x14 for output */
16743 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16744 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16745 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16746
16747 /* Rear Pin: output 1 (0x0d) */
16748 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16749 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16750 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16751 /* CLFE Pin: output 2 (0x0e) */
16752 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16753 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16754 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16755 /* Side Pin: output 3 (0x0f) */
16756 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16757 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16758 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16759
16760 /* Mic (rear) pin: input vref at 80% */
16761 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16762 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16763 /* Front Mic pin: input vref at 80% */
16764 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16765 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16766 /* Line In pin: input */
16767 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16768 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16769 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16770 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16771 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16772 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16773 /* CD pin widget for input */
16774 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16775
16776 { }
16777};
16778
Kailang Yangbdd148a2007-05-08 15:19:08 +020016779static struct hda_verb alc861vd_eapd_verbs[] = {
16780 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16781 { }
16782};
16783
Kailang Yangf9423e72008-05-27 12:32:25 +020016784static struct hda_verb alc660vd_eapd_verbs[] = {
16785 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16786 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16787 { }
16788};
16789
Kailang Yangbdd148a2007-05-08 15:19:08 +020016790static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16791 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16792 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16793 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16794 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016795 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016796 {}
16797};
16798
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016799static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016800{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016801 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016802 spec->autocfg.hp_pins[0] = 0x1b;
16803 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016804}
16805
16806static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16807{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016808 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +010016809 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016810}
16811
16812static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16813 unsigned int res)
16814{
16815 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016816 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +010016817 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016818 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016819 default:
16820 alc_automute_amp_unsol_event(codec, res);
16821 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016822 }
16823}
16824
Kailang Yang272a5272007-05-14 11:00:38 +020016825static struct hda_verb alc861vd_dallas_verbs[] = {
16826 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16827 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16828 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16829 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16830
16831 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16832 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16833 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16834 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16835 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16836 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16837 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16838 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016839
Kailang Yang272a5272007-05-14 11:00:38 +020016840 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16841 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16842 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16843 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16844 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16845 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16846 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16847 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16848
16849 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16850 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16851 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16852 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16853 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16854 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16855 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16856 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16857
16858 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16859 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16860 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16861 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16862
16863 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016864 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016865 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16866
16867 { } /* end */
16868};
16869
16870/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016871static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016872{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016873 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016874
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016875 spec->autocfg.hp_pins[0] = 0x15;
16876 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016877}
16878
Takashi Iwaicb53c622007-08-10 17:21:45 +020016879#ifdef CONFIG_SND_HDA_POWER_SAVE
16880#define alc861vd_loopbacks alc880_loopbacks
16881#endif
16882
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016883/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016884#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16885#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16886#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16887#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16888
16889/*
16890 * configuration and preset
16891 */
Takashi Iwaiea734962011-01-17 11:29:34 +010016892static const char * const alc861vd_models[ALC861VD_MODEL_LAST] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016893 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016894 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016895 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016896 [ALC861VD_3ST] = "3stack",
16897 [ALC861VD_3ST_DIG] = "3stack-digout",
16898 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016899 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016900 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016901 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016902 [ALC861VD_AUTO] = "auto",
16903};
16904
16905static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016906 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16907 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016908 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016909 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016910 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016911 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016912 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016913 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016914 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016915 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016916 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016917 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016918 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016919 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016920 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016921 {}
16922};
16923
16924static struct alc_config_preset alc861vd_presets[] = {
16925 [ALC660VD_3ST] = {
16926 .mixers = { alc861vd_3st_mixer },
16927 .init_verbs = { alc861vd_volume_init_verbs,
16928 alc861vd_3stack_init_verbs },
16929 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16930 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016931 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16932 .channel_mode = alc861vd_3stack_2ch_modes,
16933 .input_mux = &alc861vd_capture_source,
16934 },
Mike Crash6963f842007-06-25 12:12:51 +020016935 [ALC660VD_3ST_DIG] = {
16936 .mixers = { alc861vd_3st_mixer },
16937 .init_verbs = { alc861vd_volume_init_verbs,
16938 alc861vd_3stack_init_verbs },
16939 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16940 .dac_nids = alc660vd_dac_nids,
16941 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016942 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16943 .channel_mode = alc861vd_3stack_2ch_modes,
16944 .input_mux = &alc861vd_capture_source,
16945 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016946 [ALC861VD_3ST] = {
16947 .mixers = { alc861vd_3st_mixer },
16948 .init_verbs = { alc861vd_volume_init_verbs,
16949 alc861vd_3stack_init_verbs },
16950 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16951 .dac_nids = alc861vd_dac_nids,
16952 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16953 .channel_mode = alc861vd_3stack_2ch_modes,
16954 .input_mux = &alc861vd_capture_source,
16955 },
16956 [ALC861VD_3ST_DIG] = {
16957 .mixers = { alc861vd_3st_mixer },
16958 .init_verbs = { alc861vd_volume_init_verbs,
16959 alc861vd_3stack_init_verbs },
16960 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16961 .dac_nids = alc861vd_dac_nids,
16962 .dig_out_nid = ALC861VD_DIGOUT_NID,
16963 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16964 .channel_mode = alc861vd_3stack_2ch_modes,
16965 .input_mux = &alc861vd_capture_source,
16966 },
16967 [ALC861VD_6ST_DIG] = {
16968 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16969 .init_verbs = { alc861vd_volume_init_verbs,
16970 alc861vd_6stack_init_verbs },
16971 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16972 .dac_nids = alc861vd_dac_nids,
16973 .dig_out_nid = ALC861VD_DIGOUT_NID,
16974 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16975 .channel_mode = alc861vd_6stack_modes,
16976 .input_mux = &alc861vd_capture_source,
16977 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016978 [ALC861VD_LENOVO] = {
16979 .mixers = { alc861vd_lenovo_mixer },
16980 .init_verbs = { alc861vd_volume_init_verbs,
16981 alc861vd_3stack_init_verbs,
16982 alc861vd_eapd_verbs,
16983 alc861vd_lenovo_unsol_verbs },
16984 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16985 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016986 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16987 .channel_mode = alc861vd_3stack_2ch_modes,
16988 .input_mux = &alc861vd_capture_source,
16989 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016990 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016991 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016992 },
Kailang Yang272a5272007-05-14 11:00:38 +020016993 [ALC861VD_DALLAS] = {
16994 .mixers = { alc861vd_dallas_mixer },
16995 .init_verbs = { alc861vd_dallas_verbs },
16996 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16997 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016998 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16999 .channel_mode = alc861vd_3stack_2ch_modes,
17000 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017001 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017002 .setup = alc861vd_dallas_setup,
17003 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017004 },
17005 [ALC861VD_HP] = {
17006 .mixers = { alc861vd_hp_mixer },
17007 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
17008 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
17009 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017010 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017011 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17012 .channel_mode = alc861vd_3stack_2ch_modes,
17013 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017014 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017015 .setup = alc861vd_dallas_setup,
17016 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020017017 },
Takashi Iwai13c94742008-11-05 08:06:08 +010017018 [ALC660VD_ASUS_V1S] = {
17019 .mixers = { alc861vd_lenovo_mixer },
17020 .init_verbs = { alc861vd_volume_init_verbs,
17021 alc861vd_3stack_init_verbs,
17022 alc861vd_eapd_verbs,
17023 alc861vd_lenovo_unsol_verbs },
17024 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
17025 .dac_nids = alc660vd_dac_nids,
17026 .dig_out_nid = ALC861VD_DIGOUT_NID,
17027 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17028 .channel_mode = alc861vd_3stack_2ch_modes,
17029 .input_mux = &alc861vd_capture_source,
17030 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017031 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017032 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010017033 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017034};
17035
17036/*
17037 * BIOS auto configuration
17038 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017039static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
17040 const struct auto_pin_cfg *cfg)
17041{
Herton Ronaldo Krzesinski71675942010-11-25 00:08:01 -020017042 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x22, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020017043}
17044
17045
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017046static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
17047 hda_nid_t nid, int pin_type, int dac_idx)
17048{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017049 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017050}
17051
17052static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
17053{
17054 struct alc_spec *spec = codec->spec;
17055 int i;
17056
17057 for (i = 0; i <= HDA_SIDE; i++) {
17058 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017059 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017060 if (nid)
17061 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017062 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017063 }
17064}
17065
17066
17067static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
17068{
17069 struct alc_spec *spec = codec->spec;
17070 hda_nid_t pin;
17071
17072 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017073 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017074 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017075 pin = spec->autocfg.speaker_pins[0];
17076 if (pin)
17077 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017078}
17079
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017080#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
17081
17082static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
17083{
17084 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017085 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017086 int i;
17087
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017088 for (i = 0; i < cfg->num_inputs; i++) {
17089 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017090 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020017091 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +010017092 if (nid != ALC861VD_PIN_CD_NID &&
17093 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017094 snd_hda_codec_write(codec, nid, 0,
17095 AC_VERB_SET_AMP_GAIN_MUTE,
17096 AMP_OUT_MUTE);
17097 }
17098 }
17099}
17100
Takashi Iwaif511b012008-08-15 16:46:42 +020017101#define alc861vd_auto_init_input_src alc882_auto_init_input_src
17102
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017103#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
17104#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
17105
17106/* add playback controls from the parsed DAC table */
Takashi Iwai569ed342011-01-19 10:14:46 +010017107/* Based on ALC880 version. But ALC861VD has separate,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017108 * different NIDs for mute/unmute switch and volume control */
17109static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
17110 const struct auto_pin_cfg *cfg)
17111{
Takashi Iwaiea734962011-01-17 11:29:34 +010017112 static const char * const chname[4] = {
17113 "Front", "Surround", "CLFE", "Side"
17114 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017115 const char *pfx = alc_get_line_out_pfx(cfg, true);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017116 hda_nid_t nid_v, nid_s;
17117 int i, err;
17118
17119 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017120 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017121 continue;
17122 nid_v = alc861vd_idx_to_mixer_vol(
17123 alc880_dac_to_idx(
17124 spec->multiout.dac_nids[i]));
17125 nid_s = alc861vd_idx_to_mixer_switch(
17126 alc880_dac_to_idx(
17127 spec->multiout.dac_nids[i]));
17128
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017129 if (!pfx && i == 2) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017130 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017131 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17132 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017133 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
17134 HDA_OUTPUT));
17135 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017136 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017137 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17138 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017139 HDA_COMPOSE_AMP_VAL(nid_v, 2, 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_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17144 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017145 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
17146 HDA_INPUT));
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 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017151 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
17152 HDA_INPUT));
17153 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017154 return err;
17155 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017156 const char *name = pfx;
17157 if (!name)
17158 name = chname[i];
17159 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17160 name, i,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017161 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
17162 HDA_OUTPUT));
17163 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017164 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017165 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17166 name, i,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017167 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017168 HDA_INPUT));
17169 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017170 return err;
17171 }
17172 }
17173 return 0;
17174}
17175
17176/* add playback controls for speaker and HP outputs */
17177/* Based on ALC880 version. But ALC861VD has separate,
17178 * different NIDs for mute/unmute switch and volume control */
17179static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
17180 hda_nid_t pin, const char *pfx)
17181{
17182 hda_nid_t nid_v, nid_s;
17183 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017184
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017185 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017186 return 0;
17187
17188 if (alc880_is_fixed_pin(pin)) {
17189 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17190 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017191 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017192 spec->multiout.hp_nid = nid_v;
17193 else
17194 spec->multiout.extra_out_nid[0] = nid_v;
17195 /* control HP volume/switch on the output mixer amp */
17196 nid_v = alc861vd_idx_to_mixer_vol(
17197 alc880_fixed_pin_idx(pin));
17198 nid_s = alc861vd_idx_to_mixer_switch(
17199 alc880_fixed_pin_idx(pin));
17200
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017201 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017202 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
17203 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017204 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017205 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017206 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
17207 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017208 return err;
17209 } else if (alc880_is_multi_pin(pin)) {
17210 /* set manual connection */
17211 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017212 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017213 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17214 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017215 return err;
17216 }
17217 return 0;
17218}
17219
17220/* parse the BIOS configuration and set up the alc_spec
17221 * return 1 if successful, 0 if the proper config is not found,
17222 * or a negative error code
17223 * Based on ALC880 version - had to change it to override
17224 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
17225static int alc861vd_parse_auto_config(struct hda_codec *codec)
17226{
17227 struct alc_spec *spec = codec->spec;
17228 int err;
17229 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
17230
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017231 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17232 alc861vd_ignore);
17233 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017234 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017235 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017236 return 0; /* can't find valid BIOS pin config */
17237
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017238 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17239 if (err < 0)
17240 return err;
17241 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
17242 if (err < 0)
17243 return err;
17244 err = alc861vd_auto_create_extra_out(spec,
17245 spec->autocfg.speaker_pins[0],
17246 "Speaker");
17247 if (err < 0)
17248 return err;
17249 err = alc861vd_auto_create_extra_out(spec,
17250 spec->autocfg.hp_pins[0],
17251 "Headphone");
17252 if (err < 0)
17253 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017254 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017255 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017256 return err;
17257
17258 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17259
Takashi Iwai757899a2010-07-30 10:48:14 +020017260 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017261
Takashi Iwai603c4012008-07-30 15:01:44 +020017262 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017263 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017264
Takashi Iwaid88897e2008-10-31 15:01:37 +010017265 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017266
17267 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017268 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017269
Takashi Iwai776e1842007-08-29 15:07:11 +020017270 err = alc_auto_add_mic_boost(codec);
17271 if (err < 0)
17272 return err;
17273
Kailang Yang6227cdc2010-02-25 08:36:52 +010017274 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017275
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017276 return 1;
17277}
17278
17279/* additional initialization for auto-configuration model */
17280static void alc861vd_auto_init(struct hda_codec *codec)
17281{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017282 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017283 alc861vd_auto_init_multi_out(codec);
17284 alc861vd_auto_init_hp_out(codec);
17285 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017286 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020017287 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017288 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017289 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017290}
17291
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017292enum {
17293 ALC660VD_FIX_ASUS_GPIO1
17294};
17295
17296/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017297static const struct alc_fixup alc861vd_fixups[] = {
17298 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017299 .type = ALC_FIXUP_VERBS,
17300 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020017301 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
17302 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
17303 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
17304 { }
17305 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017306 },
17307};
17308
17309static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
17310 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
17311 {}
17312};
17313
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017314static int patch_alc861vd(struct hda_codec *codec)
17315{
17316 struct alc_spec *spec;
17317 int err, board_config;
17318
17319 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17320 if (spec == NULL)
17321 return -ENOMEM;
17322
17323 codec->spec = spec;
17324
17325 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
17326 alc861vd_models,
17327 alc861vd_cfg_tbl);
17328
17329 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017330 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17331 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017332 board_config = ALC861VD_AUTO;
17333 }
17334
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017335 if (board_config == ALC861VD_AUTO) {
17336 alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
17337 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
17338 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017339
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017340 if (board_config == ALC861VD_AUTO) {
17341 /* automatic parse from the BIOS config */
17342 err = alc861vd_parse_auto_config(codec);
17343 if (err < 0) {
17344 alc_free(codec);
17345 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017346 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017347 printk(KERN_INFO
17348 "hda_codec: Cannot set up configuration "
17349 "from BIOS. Using base mode...\n");
17350 board_config = ALC861VD_3ST;
17351 }
17352 }
17353
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017354 err = snd_hda_attach_beep_device(codec, 0x23);
17355 if (err < 0) {
17356 alc_free(codec);
17357 return err;
17358 }
17359
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017360 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017361 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017362
Kailang Yang2f893282008-05-27 12:14:47 +020017363 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020017364 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010017365 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020017366 }
17367
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017368 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
17369 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
17370
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017371 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
17372 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
17373
Takashi Iwaidd704692009-08-11 08:45:11 +020017374 if (!spec->adc_nids) {
17375 spec->adc_nids = alc861vd_adc_nids;
17376 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
17377 }
17378 if (!spec->capsrc_nids)
17379 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017380
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017381 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010017382 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017383
Takashi Iwai2134ea42008-01-10 16:53:55 +010017384 spec->vmaster_nid = 0x02;
17385
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017386 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017387
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017388 codec->patch_ops = alc_patch_ops;
17389
17390 if (board_config == ALC861VD_AUTO)
17391 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017392#ifdef CONFIG_SND_HDA_POWER_SAVE
17393 if (!spec->loopback.amplist)
17394 spec->loopback.amplist = alc861vd_loopbacks;
17395#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017396
17397 return 0;
17398}
17399
17400/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017401 * ALC662 support
17402 *
17403 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
17404 * configuration. Each pin widget can choose any input DACs and a mixer.
17405 * Each ADC is connected from a mixer of all inputs. This makes possible
17406 * 6-channel independent captures.
17407 *
17408 * In addition, an independent DAC for the multi-playback (not used in this
17409 * driver yet).
17410 */
17411#define ALC662_DIGOUT_NID 0x06
17412#define ALC662_DIGIN_NID 0x0a
17413
17414static hda_nid_t alc662_dac_nids[4] = {
17415 /* front, rear, clfe, rear_surr */
17416 0x02, 0x03, 0x04
17417};
17418
Kailang Yang622e84c2009-04-21 07:39:04 +020017419static hda_nid_t alc272_dac_nids[2] = {
17420 0x02, 0x03
17421};
17422
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017423static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017424 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017425 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017426};
Takashi Iwaie1406342008-02-11 18:32:32 +010017427
Kailang Yang622e84c2009-04-21 07:39:04 +020017428static hda_nid_t alc272_adc_nids[1] = {
17429 /* ADC1-2 */
17430 0x08,
17431};
17432
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017433static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020017434static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
17435
Takashi Iwaie1406342008-02-11 18:32:32 +010017436
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017437/* input MUX */
17438/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017439static struct hda_input_mux alc662_capture_source = {
17440 .num_items = 4,
17441 .items = {
17442 { "Mic", 0x0 },
17443 { "Front Mic", 0x1 },
17444 { "Line", 0x2 },
17445 { "CD", 0x4 },
17446 },
17447};
17448
17449static struct hda_input_mux alc662_lenovo_101e_capture_source = {
17450 .num_items = 2,
17451 .items = {
17452 { "Mic", 0x1 },
17453 { "Line", 0x2 },
17454 },
17455};
Kailang Yang291702f2007-10-16 14:28:03 +020017456
Kailang Yang6dda9f42008-05-27 12:05:31 +020017457static struct hda_input_mux alc663_capture_source = {
17458 .num_items = 3,
17459 .items = {
17460 { "Mic", 0x0 },
17461 { "Front Mic", 0x1 },
17462 { "Line", 0x2 },
17463 },
17464};
17465
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017466#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020017467static struct hda_input_mux alc272_nc10_capture_source = {
17468 .num_items = 16,
17469 .items = {
17470 { "Autoselect Mic", 0x0 },
17471 { "Internal Mic", 0x1 },
17472 { "In-0x02", 0x2 },
17473 { "In-0x03", 0x3 },
17474 { "In-0x04", 0x4 },
17475 { "In-0x05", 0x5 },
17476 { "In-0x06", 0x6 },
17477 { "In-0x07", 0x7 },
17478 { "In-0x08", 0x8 },
17479 { "In-0x09", 0x9 },
17480 { "In-0x0a", 0x0a },
17481 { "In-0x0b", 0x0b },
17482 { "In-0x0c", 0x0c },
17483 { "In-0x0d", 0x0d },
17484 { "In-0x0e", 0x0e },
17485 { "In-0x0f", 0x0f },
17486 },
17487};
17488#endif
17489
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017490/*
17491 * 2ch mode
17492 */
17493static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17494 { 2, NULL }
17495};
17496
17497/*
17498 * 2ch mode
17499 */
17500static struct hda_verb alc662_3ST_ch2_init[] = {
17501 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17502 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17503 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17504 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17505 { } /* end */
17506};
17507
17508/*
17509 * 6ch mode
17510 */
17511static struct hda_verb alc662_3ST_ch6_init[] = {
17512 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17513 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17514 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17515 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17516 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17517 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17518 { } /* end */
17519};
17520
17521static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17522 { 2, alc662_3ST_ch2_init },
17523 { 6, alc662_3ST_ch6_init },
17524};
17525
17526/*
17527 * 2ch mode
17528 */
17529static struct hda_verb alc662_sixstack_ch6_init[] = {
17530 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17531 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17532 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17533 { } /* end */
17534};
17535
17536/*
17537 * 6ch mode
17538 */
17539static struct hda_verb alc662_sixstack_ch8_init[] = {
17540 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17541 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17542 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17543 { } /* end */
17544};
17545
17546static struct hda_channel_mode alc662_5stack_modes[2] = {
17547 { 2, alc662_sixstack_ch6_init },
17548 { 6, alc662_sixstack_ch8_init },
17549};
17550
17551/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17552 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17553 */
17554
17555static struct snd_kcontrol_new alc662_base_mixer[] = {
17556 /* output mixer control */
17557 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017558 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017559 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017560 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017561 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17562 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017563 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17564 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017565 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17566
17567 /*Input mixer control */
17568 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17569 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17570 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17571 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17572 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17573 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17574 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17575 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017576 { } /* end */
17577};
17578
17579static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17580 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017581 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017582 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17583 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17584 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17585 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17586 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17587 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17588 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17589 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17590 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017591 { } /* end */
17592};
17593
17594static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17595 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017596 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017597 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017598 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017599 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17600 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017601 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17602 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017603 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17604 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17605 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17606 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17607 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17608 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17609 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17610 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17611 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017612 { } /* end */
17613};
17614
17615static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17616 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17617 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017618 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17619 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017620 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17621 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17622 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17623 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17624 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017625 { } /* end */
17626};
17627
Kailang Yang291702f2007-10-16 14:28:03 +020017628static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017629 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17630 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017631
David Henningsson5f99f862011-01-04 15:24:24 +010017632 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017633 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17634 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017635
David Henningsson5f99f862011-01-04 15:24:24 +010017636 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017637 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17638 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017639 { } /* end */
17640};
17641
Kailang Yang8c427222008-01-10 13:03:59 +010017642static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017643 ALC262_HIPPO_MASTER_SWITCH,
17644 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017645 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017646 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17647 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017648 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17649 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17650 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17651 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17652 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17653 { } /* end */
17654};
17655
Kailang Yangf1d4e282008-08-26 14:03:29 +020017656static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17657 .ops = &snd_hda_bind_vol,
17658 .values = {
17659 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17660 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17661 0
17662 },
17663};
17664
17665static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17666 .ops = &snd_hda_bind_sw,
17667 .values = {
17668 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17669 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17670 0
17671 },
17672};
17673
Kailang Yang6dda9f42008-05-27 12:05:31 +020017674static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017675 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17676 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17677 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17678 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17679 { } /* end */
17680};
17681
17682static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17683 .ops = &snd_hda_bind_sw,
17684 .values = {
17685 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17686 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17687 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17688 0
17689 },
17690};
17691
17692static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17693 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17694 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17695 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17696 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17697 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17698 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17699
17700 { } /* end */
17701};
17702
17703static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17704 .ops = &snd_hda_bind_sw,
17705 .values = {
17706 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17707 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17708 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17709 0
17710 },
17711};
17712
17713static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17714 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17715 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17716 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17717 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17718 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17719 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17720 { } /* end */
17721};
17722
17723static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017724 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17725 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017726 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17727 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17728 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17729 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17730 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17731 { } /* end */
17732};
17733
17734static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17735 .ops = &snd_hda_bind_vol,
17736 .values = {
17737 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17738 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17739 0
17740 },
17741};
17742
17743static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17744 .ops = &snd_hda_bind_sw,
17745 .values = {
17746 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17747 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17748 0
17749 },
17750};
17751
17752static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17753 HDA_BIND_VOL("Master Playback Volume",
17754 &alc663_asus_two_bind_master_vol),
17755 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17756 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017757 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17758 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17759 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017760 { } /* end */
17761};
17762
17763static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17764 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17765 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17766 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17767 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17768 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17769 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017770 { } /* end */
17771};
17772
17773static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17774 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17775 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17776 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17777 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17778 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17779
17780 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17781 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017782 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17783 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017784 { } /* end */
17785};
17786
17787static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17788 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17789 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17790 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17791
17792 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17793 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017794 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17795 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017796 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17797 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17798 { } /* end */
17799};
17800
Kailang Yangebb83ee2009-12-17 12:23:00 +010017801static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17802 .ops = &snd_hda_bind_sw,
17803 .values = {
17804 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17805 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17806 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17807 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17808 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17809 0
17810 },
17811};
17812
17813static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17814 .ops = &snd_hda_bind_sw,
17815 .values = {
17816 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17817 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17818 0
17819 },
17820};
17821
17822static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17823 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17824 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17825 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17826 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17827 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17828 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17829 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17830 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17831 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17832 { } /* end */
17833};
17834
17835static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17836 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17837 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17838 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17839 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17840 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17841 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17842 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17843 { } /* end */
17844};
17845
17846
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017847static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17848 {
17849 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17850 .name = "Channel Mode",
17851 .info = alc_ch_mode_info,
17852 .get = alc_ch_mode_get,
17853 .put = alc_ch_mode_put,
17854 },
17855 { } /* end */
17856};
17857
17858static struct hda_verb alc662_init_verbs[] = {
17859 /* ADC: mute amp left and right */
17860 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17861 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017862
Kailang Yangb60dd392007-09-20 12:50:29 +020017863 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17864 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17865 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17866 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17867 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17868 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017869
17870 /* Front Pin: output 0 (0x0c) */
17871 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17872 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17873
17874 /* Rear Pin: output 1 (0x0d) */
17875 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17876 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17877
17878 /* CLFE Pin: output 2 (0x0e) */
17879 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17880 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17881
17882 /* Mic (rear) pin: input vref at 80% */
17883 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17884 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17885 /* Front Mic pin: input vref at 80% */
17886 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17887 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17888 /* Line In pin: input */
17889 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17890 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17891 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17892 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17893 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17894 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17895 /* CD pin widget for input */
17896 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17897
17898 /* FIXME: use matrix-type input source selection */
17899 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17900 /* Input mixer */
17901 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017902 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017903
17904 /* always trun on EAPD */
17905 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17906 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17907
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017908 { }
17909};
17910
Kailang Yangcec27c82010-02-04 14:18:18 +010017911static struct hda_verb alc663_init_verbs[] = {
17912 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17913 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17914 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17915 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17916 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17917 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17918 { }
17919};
17920
17921static struct hda_verb alc272_init_verbs[] = {
17922 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17923 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17924 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17925 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17926 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17927 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17928 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17929 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17930 { }
17931};
17932
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017933static struct hda_verb alc662_sue_init_verbs[] = {
17934 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17935 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017936 {}
17937};
17938
17939static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17940 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17941 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17942 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017943};
17944
Kailang Yang8c427222008-01-10 13:03:59 +010017945/* Set Unsolicited Event*/
17946static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17947 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17948 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17949 {}
17950};
17951
Kailang Yang6dda9f42008-05-27 12:05:31 +020017952static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017953 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17954 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017955 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17956 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017957 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17958 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17959 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017960 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17961 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17962 {}
17963};
17964
Kailang Yangf1d4e282008-08-26 14:03:29 +020017965static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17966 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17967 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17968 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17969 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17970 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17971 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17972 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17973 {}
17974};
17975
17976static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17977 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17978 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17979 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17980 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17981 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17982 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17983 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17984 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17985 {}
17986};
17987
17988static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17989 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17990 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17991 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17992 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17993 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17994 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17995 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17996 {}
17997};
17998
17999static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
18000 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18001 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18002 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18003 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
18004 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18005 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18006 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
18007 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18008 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18009 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18010 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18011 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18012 {}
18013};
18014
18015static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
18016 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18017 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18018 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18019 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18020 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18021 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18022 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18023 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18024 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18025 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18026 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18027 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18028 {}
18029};
18030
Kailang Yang6dda9f42008-05-27 12:05:31 +020018031static struct hda_verb alc663_g71v_init_verbs[] = {
18032 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18033 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
18034 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
18035
18036 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18037 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18038 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18039
18040 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
18041 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
18042 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
18043 {}
18044};
18045
18046static struct hda_verb alc663_g50v_init_verbs[] = {
18047 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18048 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18049 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18050
18051 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18052 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18053 {}
18054};
18055
Kailang Yangf1d4e282008-08-26 14:03:29 +020018056static struct hda_verb alc662_ecs_init_verbs[] = {
18057 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
18058 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18059 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18060 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18061 {}
18062};
18063
Kailang Yang622e84c2009-04-21 07:39:04 +020018064static struct hda_verb alc272_dell_zm1_init_verbs[] = {
18065 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18066 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18067 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18068 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18069 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18070 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18071 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18072 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18073 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18074 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18075 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18076 {}
18077};
18078
18079static struct hda_verb alc272_dell_init_verbs[] = {
18080 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18081 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18082 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18083 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18084 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18085 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18086 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18087 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18088 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18089 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18090 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18091 {}
18092};
18093
Kailang Yangebb83ee2009-12-17 12:23:00 +010018094static struct hda_verb alc663_mode7_init_verbs[] = {
18095 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18096 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18097 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18098 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18099 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18100 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18101 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
18102 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18103 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18104 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18105 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18106 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18107 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18108 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18109 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18110 {}
18111};
18112
18113static struct hda_verb alc663_mode8_init_verbs[] = {
18114 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18115 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18116 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18117 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
18118 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18119 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18120 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18121 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18122 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18123 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18124 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18125 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18126 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18127 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18128 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18129 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18130 {}
18131};
18132
Kailang Yangf1d4e282008-08-26 14:03:29 +020018133static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
18134 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
18135 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
18136 { } /* end */
18137};
18138
Kailang Yang622e84c2009-04-21 07:39:04 +020018139static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
18140 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
18141 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
18142 { } /* end */
18143};
18144
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018145static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
18146{
18147 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018148 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018149
Wu Fengguang864f92b2009-11-18 12:38:02 +080018150 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018151 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018152
Takashi Iwai47fd8302007-08-10 17:11:07 +020018153 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18154 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018155}
18156
18157static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
18158{
18159 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018160 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018161
Wu Fengguang864f92b2009-11-18 12:38:02 +080018162 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018163 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018164
Takashi Iwai47fd8302007-08-10 17:11:07 +020018165 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18166 HDA_AMP_MUTE, bits);
18167 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18168 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018169}
18170
18171static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
18172 unsigned int res)
18173{
18174 if ((res >> 26) == ALC880_HP_EVENT)
18175 alc662_lenovo_101e_all_automute(codec);
18176 if ((res >> 26) == ALC880_FRONT_EVENT)
18177 alc662_lenovo_101e_ispeaker_automute(codec);
18178}
18179
Kailang Yang291702f2007-10-16 14:28:03 +020018180/* unsolicited event for HP jack sensing */
18181static void alc662_eeepc_unsol_event(struct hda_codec *codec,
18182 unsigned int res)
18183{
Kailang Yang291702f2007-10-16 14:28:03 +020018184 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018185 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020018186 else
18187 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020018188}
18189
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018190static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020018191{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018192 struct alc_spec *spec = codec->spec;
18193
18194 alc262_hippo1_setup(codec);
18195 spec->ext_mic.pin = 0x18;
18196 spec->ext_mic.mux_idx = 0;
18197 spec->int_mic.pin = 0x19;
18198 spec->int_mic.mux_idx = 1;
18199 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020018200}
18201
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018202static void alc662_eeepc_inithook(struct hda_codec *codec)
18203{
18204 alc262_hippo_automute(codec);
18205 alc_mic_automute(codec);
18206}
18207
18208static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010018209{
Takashi Iwai42171c12009-05-08 14:11:43 +020018210 struct alc_spec *spec = codec->spec;
18211
18212 spec->autocfg.hp_pins[0] = 0x14;
18213 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010018214}
18215
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018216#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
18217
Kailang Yang6dda9f42008-05-27 12:05:31 +020018218static void alc663_m51va_speaker_automute(struct hda_codec *codec)
18219{
18220 unsigned int present;
18221 unsigned char bits;
18222
Wu Fengguang864f92b2009-11-18 12:38:02 +080018223 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018224 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018225 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018226 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018227 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018228 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018229}
18230
18231static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
18232{
18233 unsigned int present;
18234 unsigned char bits;
18235
Wu Fengguang864f92b2009-11-18 12:38:02 +080018236 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018237 bits = present ? HDA_AMP_MUTE : 0;
18238 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018239 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018240 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018241 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018242 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018243 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018244 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018245 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018246}
18247
18248static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
18249{
18250 unsigned int present;
18251 unsigned char bits;
18252
Wu Fengguang864f92b2009-11-18 12:38:02 +080018253 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018254 bits = present ? HDA_AMP_MUTE : 0;
18255 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018256 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018257 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018258 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018259 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018260 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018261 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018262 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018263}
18264
18265static void alc662_f5z_speaker_automute(struct hda_codec *codec)
18266{
18267 unsigned int present;
18268 unsigned char bits;
18269
Wu Fengguang864f92b2009-11-18 12:38:02 +080018270 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018271 bits = present ? 0 : PIN_OUT;
18272 snd_hda_codec_write(codec, 0x14, 0,
18273 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
18274}
18275
18276static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
18277{
18278 unsigned int present1, present2;
18279
Wu Fengguang864f92b2009-11-18 12:38:02 +080018280 present1 = snd_hda_jack_detect(codec, 0x21);
18281 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018282
18283 if (present1 || present2) {
18284 snd_hda_codec_write_cache(codec, 0x14, 0,
18285 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18286 } else {
18287 snd_hda_codec_write_cache(codec, 0x14, 0,
18288 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18289 }
18290}
18291
18292static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
18293{
18294 unsigned int present1, present2;
18295
Wu Fengguang864f92b2009-11-18 12:38:02 +080018296 present1 = snd_hda_jack_detect(codec, 0x1b);
18297 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018298
18299 if (present1 || present2) {
18300 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018301 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018302 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018303 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018304 } else {
18305 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018306 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018307 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018308 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018309 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020018310}
18311
Kailang Yangebb83ee2009-12-17 12:23:00 +010018312static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
18313{
18314 unsigned int present1, present2;
18315
18316 present1 = snd_hda_codec_read(codec, 0x1b, 0,
18317 AC_VERB_GET_PIN_SENSE, 0)
18318 & AC_PINSENSE_PRESENCE;
18319 present2 = snd_hda_codec_read(codec, 0x21, 0,
18320 AC_VERB_GET_PIN_SENSE, 0)
18321 & AC_PINSENSE_PRESENCE;
18322
18323 if (present1 || present2) {
18324 snd_hda_codec_write_cache(codec, 0x14, 0,
18325 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18326 snd_hda_codec_write_cache(codec, 0x17, 0,
18327 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18328 } else {
18329 snd_hda_codec_write_cache(codec, 0x14, 0,
18330 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18331 snd_hda_codec_write_cache(codec, 0x17, 0,
18332 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18333 }
18334}
18335
18336static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
18337{
18338 unsigned int present1, present2;
18339
18340 present1 = snd_hda_codec_read(codec, 0x21, 0,
18341 AC_VERB_GET_PIN_SENSE, 0)
18342 & AC_PINSENSE_PRESENCE;
18343 present2 = snd_hda_codec_read(codec, 0x15, 0,
18344 AC_VERB_GET_PIN_SENSE, 0)
18345 & AC_PINSENSE_PRESENCE;
18346
18347 if (present1 || present2) {
18348 snd_hda_codec_write_cache(codec, 0x14, 0,
18349 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18350 snd_hda_codec_write_cache(codec, 0x17, 0,
18351 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18352 } else {
18353 snd_hda_codec_write_cache(codec, 0x14, 0,
18354 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18355 snd_hda_codec_write_cache(codec, 0x17, 0,
18356 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18357 }
18358}
18359
Kailang Yang6dda9f42008-05-27 12:05:31 +020018360static void alc663_m51va_unsol_event(struct hda_codec *codec,
18361 unsigned int res)
18362{
18363 switch (res >> 26) {
18364 case ALC880_HP_EVENT:
18365 alc663_m51va_speaker_automute(codec);
18366 break;
18367 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018368 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018369 break;
18370 }
18371}
18372
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018373static void alc663_m51va_setup(struct hda_codec *codec)
18374{
18375 struct alc_spec *spec = codec->spec;
18376 spec->ext_mic.pin = 0x18;
18377 spec->ext_mic.mux_idx = 0;
18378 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018379 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018380 spec->auto_mic = 1;
18381}
18382
Kailang Yang6dda9f42008-05-27 12:05:31 +020018383static void alc663_m51va_inithook(struct hda_codec *codec)
18384{
18385 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018386 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018387}
18388
Kailang Yangf1d4e282008-08-26 14:03:29 +020018389/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018390#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010018391
18392static void alc663_mode1_setup(struct hda_codec *codec)
18393{
18394 struct alc_spec *spec = codec->spec;
18395 spec->ext_mic.pin = 0x18;
18396 spec->ext_mic.mux_idx = 0;
18397 spec->int_mic.pin = 0x19;
18398 spec->int_mic.mux_idx = 1;
18399 spec->auto_mic = 1;
18400}
18401
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018402#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020018403
Kailang Yangf1d4e282008-08-26 14:03:29 +020018404/* ***************** Mode2 ******************************/
18405static void alc662_mode2_unsol_event(struct hda_codec *codec,
18406 unsigned int res)
18407{
18408 switch (res >> 26) {
18409 case ALC880_HP_EVENT:
18410 alc662_f5z_speaker_automute(codec);
18411 break;
18412 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018413 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018414 break;
18415 }
18416}
18417
Kailang Yangebb83ee2009-12-17 12:23:00 +010018418#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018419
Kailang Yangf1d4e282008-08-26 14:03:29 +020018420static void alc662_mode2_inithook(struct hda_codec *codec)
18421{
18422 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018423 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018424}
18425/* ***************** Mode3 ******************************/
18426static void alc663_mode3_unsol_event(struct hda_codec *codec,
18427 unsigned int res)
18428{
18429 switch (res >> 26) {
18430 case ALC880_HP_EVENT:
18431 alc663_two_hp_m1_speaker_automute(codec);
18432 break;
18433 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018434 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018435 break;
18436 }
18437}
18438
Kailang Yangebb83ee2009-12-17 12:23:00 +010018439#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018440
Kailang Yangf1d4e282008-08-26 14:03:29 +020018441static void alc663_mode3_inithook(struct hda_codec *codec)
18442{
18443 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018444 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018445}
18446/* ***************** Mode4 ******************************/
18447static void alc663_mode4_unsol_event(struct hda_codec *codec,
18448 unsigned int res)
18449{
18450 switch (res >> 26) {
18451 case ALC880_HP_EVENT:
18452 alc663_21jd_two_speaker_automute(codec);
18453 break;
18454 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018455 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018456 break;
18457 }
18458}
18459
Kailang Yangebb83ee2009-12-17 12:23:00 +010018460#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018461
Kailang Yangf1d4e282008-08-26 14:03:29 +020018462static void alc663_mode4_inithook(struct hda_codec *codec)
18463{
18464 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018465 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018466}
18467/* ***************** Mode5 ******************************/
18468static void alc663_mode5_unsol_event(struct hda_codec *codec,
18469 unsigned int res)
18470{
18471 switch (res >> 26) {
18472 case ALC880_HP_EVENT:
18473 alc663_15jd_two_speaker_automute(codec);
18474 break;
18475 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018476 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018477 break;
18478 }
18479}
18480
Kailang Yangebb83ee2009-12-17 12:23:00 +010018481#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018482
Kailang Yangf1d4e282008-08-26 14:03:29 +020018483static void alc663_mode5_inithook(struct hda_codec *codec)
18484{
18485 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018486 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018487}
18488/* ***************** Mode6 ******************************/
18489static void alc663_mode6_unsol_event(struct hda_codec *codec,
18490 unsigned int res)
18491{
18492 switch (res >> 26) {
18493 case ALC880_HP_EVENT:
18494 alc663_two_hp_m2_speaker_automute(codec);
18495 break;
18496 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018497 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018498 break;
18499 }
18500}
18501
Kailang Yangebb83ee2009-12-17 12:23:00 +010018502#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018503
Kailang Yangf1d4e282008-08-26 14:03:29 +020018504static void alc663_mode6_inithook(struct hda_codec *codec)
18505{
18506 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018507 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018508}
18509
Kailang Yangebb83ee2009-12-17 12:23:00 +010018510/* ***************** Mode7 ******************************/
18511static void alc663_mode7_unsol_event(struct hda_codec *codec,
18512 unsigned int res)
18513{
18514 switch (res >> 26) {
18515 case ALC880_HP_EVENT:
18516 alc663_two_hp_m7_speaker_automute(codec);
18517 break;
18518 case ALC880_MIC_EVENT:
18519 alc_mic_automute(codec);
18520 break;
18521 }
18522}
18523
18524#define alc663_mode7_setup alc663_mode1_setup
18525
18526static void alc663_mode7_inithook(struct hda_codec *codec)
18527{
18528 alc663_two_hp_m7_speaker_automute(codec);
18529 alc_mic_automute(codec);
18530}
18531
18532/* ***************** Mode8 ******************************/
18533static void alc663_mode8_unsol_event(struct hda_codec *codec,
18534 unsigned int res)
18535{
18536 switch (res >> 26) {
18537 case ALC880_HP_EVENT:
18538 alc663_two_hp_m8_speaker_automute(codec);
18539 break;
18540 case ALC880_MIC_EVENT:
18541 alc_mic_automute(codec);
18542 break;
18543 }
18544}
18545
18546#define alc663_mode8_setup alc663_m51va_setup
18547
18548static void alc663_mode8_inithook(struct hda_codec *codec)
18549{
18550 alc663_two_hp_m8_speaker_automute(codec);
18551 alc_mic_automute(codec);
18552}
18553
Kailang Yang6dda9f42008-05-27 12:05:31 +020018554static void alc663_g71v_hp_automute(struct hda_codec *codec)
18555{
18556 unsigned int present;
18557 unsigned char bits;
18558
Wu Fengguang864f92b2009-11-18 12:38:02 +080018559 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018560 bits = present ? HDA_AMP_MUTE : 0;
18561 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18562 HDA_AMP_MUTE, bits);
18563 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18564 HDA_AMP_MUTE, bits);
18565}
18566
18567static void alc663_g71v_front_automute(struct hda_codec *codec)
18568{
18569 unsigned int present;
18570 unsigned char bits;
18571
Wu Fengguang864f92b2009-11-18 12:38:02 +080018572 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018573 bits = present ? HDA_AMP_MUTE : 0;
18574 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18575 HDA_AMP_MUTE, bits);
18576}
18577
18578static void alc663_g71v_unsol_event(struct hda_codec *codec,
18579 unsigned int res)
18580{
18581 switch (res >> 26) {
18582 case ALC880_HP_EVENT:
18583 alc663_g71v_hp_automute(codec);
18584 break;
18585 case ALC880_FRONT_EVENT:
18586 alc663_g71v_front_automute(codec);
18587 break;
18588 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018589 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018590 break;
18591 }
18592}
18593
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018594#define alc663_g71v_setup alc663_m51va_setup
18595
Kailang Yang6dda9f42008-05-27 12:05:31 +020018596static void alc663_g71v_inithook(struct hda_codec *codec)
18597{
18598 alc663_g71v_front_automute(codec);
18599 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018600 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018601}
18602
18603static void alc663_g50v_unsol_event(struct hda_codec *codec,
18604 unsigned int res)
18605{
18606 switch (res >> 26) {
18607 case ALC880_HP_EVENT:
18608 alc663_m51va_speaker_automute(codec);
18609 break;
18610 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018611 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018612 break;
18613 }
18614}
18615
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018616#define alc663_g50v_setup alc663_m51va_setup
18617
Kailang Yang6dda9f42008-05-27 12:05:31 +020018618static void alc663_g50v_inithook(struct hda_codec *codec)
18619{
18620 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018621 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018622}
18623
Kailang Yangf1d4e282008-08-26 14:03:29 +020018624static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18625 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018626 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018627
David Henningsson5f99f862011-01-04 15:24:24 +010018628 HDA_CODEC_VOLUME("Mic/LineIn Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018629 HDA_CODEC_VOLUME("Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18630 HDA_CODEC_MUTE("Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018631
David Henningsson5f99f862011-01-04 15:24:24 +010018632 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018633 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18634 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018635 { } /* end */
18636};
18637
Chris Pockelé9541ba12009-05-12 08:08:53 +020018638static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18639 /* Master Playback automatically created from Speaker and Headphone */
18640 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18641 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18642 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18643 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18644
David Henningsson8607f7c2010-12-20 14:43:54 +010018645 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18646 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018647 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018648
David Henningsson28c4edb2010-12-20 14:24:29 +010018649 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18650 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018651 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018652 { } /* end */
18653};
18654
Takashi Iwaicb53c622007-08-10 17:21:45 +020018655#ifdef CONFIG_SND_HDA_POWER_SAVE
18656#define alc662_loopbacks alc880_loopbacks
18657#endif
18658
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018659
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018660/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018661#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18662#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18663#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18664#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18665
18666/*
18667 * configuration and preset
18668 */
Takashi Iwaiea734962011-01-17 11:29:34 +010018669static const char * const alc662_models[ALC662_MODEL_LAST] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018670 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18671 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18672 [ALC662_3ST_6ch] = "3stack-6ch",
18673 [ALC662_5ST_DIG] = "6stack-dig",
18674 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018675 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018676 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018677 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018678 [ALC663_ASUS_M51VA] = "m51va",
18679 [ALC663_ASUS_G71V] = "g71v",
18680 [ALC663_ASUS_H13] = "h13",
18681 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018682 [ALC663_ASUS_MODE1] = "asus-mode1",
18683 [ALC662_ASUS_MODE2] = "asus-mode2",
18684 [ALC663_ASUS_MODE3] = "asus-mode3",
18685 [ALC663_ASUS_MODE4] = "asus-mode4",
18686 [ALC663_ASUS_MODE5] = "asus-mode5",
18687 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018688 [ALC663_ASUS_MODE7] = "asus-mode7",
18689 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018690 [ALC272_DELL] = "dell",
18691 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018692 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018693 [ALC662_AUTO] = "auto",
18694};
18695
18696static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018697 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018698 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18699 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018700 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18701 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018702 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018703 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18704 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18705 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18706 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018707 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18708 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018709 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018710 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18711 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18712 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18713 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18714 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018715 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018716 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18717 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018718 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18719 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18720 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18721 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018722 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018723 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18724 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18725 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018726 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18727 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18728 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18729 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018730 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018731 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18732 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018733 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018734 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18735 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18736 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018737 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018738 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018739 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18740 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018741 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18742 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18743 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018744 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018745 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18746 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018747 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018748 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018749 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018750 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18751 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18752 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018753 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018754 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18755 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018756 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018757 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018758 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018759 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018760 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18761 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018762 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018763 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018764 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18765 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018766 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018767 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018768 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018769 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018770 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018771 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018772 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18773 ALC663_ASUS_H13),
Anisse Astier965b76d2011-02-10 13:14:44 +010018774 SND_PCI_QUIRK(0x1991, 0x5628, "Ordissimo EVE", ALC662_LENOVO_101E),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018775 {}
18776};
18777
18778static struct alc_config_preset alc662_presets[] = {
18779 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018780 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018781 .init_verbs = { alc662_init_verbs },
18782 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18783 .dac_nids = alc662_dac_nids,
18784 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018785 .dig_in_nid = ALC662_DIGIN_NID,
18786 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18787 .channel_mode = alc662_3ST_2ch_modes,
18788 .input_mux = &alc662_capture_source,
18789 },
18790 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018791 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018792 .init_verbs = { alc662_init_verbs },
18793 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18794 .dac_nids = alc662_dac_nids,
18795 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018796 .dig_in_nid = ALC662_DIGIN_NID,
18797 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18798 .channel_mode = alc662_3ST_6ch_modes,
18799 .need_dac_fix = 1,
18800 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018801 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018802 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018803 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018804 .init_verbs = { alc662_init_verbs },
18805 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18806 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018807 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18808 .channel_mode = alc662_3ST_6ch_modes,
18809 .need_dac_fix = 1,
18810 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018811 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018812 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018813 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018814 .init_verbs = { alc662_init_verbs },
18815 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18816 .dac_nids = alc662_dac_nids,
18817 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018818 .dig_in_nid = ALC662_DIGIN_NID,
18819 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18820 .channel_mode = alc662_5stack_modes,
18821 .input_mux = &alc662_capture_source,
18822 },
18823 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018824 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018825 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18826 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18827 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018828 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18829 .channel_mode = alc662_3ST_2ch_modes,
18830 .input_mux = &alc662_lenovo_101e_capture_source,
18831 .unsol_event = alc662_lenovo_101e_unsol_event,
18832 .init_hook = alc662_lenovo_101e_all_automute,
18833 },
Kailang Yang291702f2007-10-16 14:28:03 +020018834 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018835 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018836 .init_verbs = { alc662_init_verbs,
18837 alc662_eeepc_sue_init_verbs },
18838 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18839 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018840 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18841 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018842 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018843 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018844 .init_hook = alc662_eeepc_inithook,
18845 },
Kailang Yang8c427222008-01-10 13:03:59 +010018846 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018847 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018848 alc662_chmode_mixer },
18849 .init_verbs = { alc662_init_verbs,
18850 alc662_eeepc_ep20_sue_init_verbs },
18851 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18852 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018853 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18854 .channel_mode = alc662_3ST_6ch_modes,
18855 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018856 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018857 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018858 .init_hook = alc662_eeepc_ep20_inithook,
18859 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018860 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018861 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018862 .init_verbs = { alc662_init_verbs,
18863 alc662_ecs_init_verbs },
18864 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18865 .dac_nids = alc662_dac_nids,
18866 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18867 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018868 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018869 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018870 .init_hook = alc662_eeepc_inithook,
18871 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018872 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018873 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018874 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18875 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18876 .dac_nids = alc662_dac_nids,
18877 .dig_out_nid = ALC662_DIGOUT_NID,
18878 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18879 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018880 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018881 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018882 .init_hook = alc663_m51va_inithook,
18883 },
18884 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018885 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018886 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18887 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18888 .dac_nids = alc662_dac_nids,
18889 .dig_out_nid = ALC662_DIGOUT_NID,
18890 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18891 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018892 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018893 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018894 .init_hook = alc663_g71v_inithook,
18895 },
18896 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018897 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018898 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18899 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18900 .dac_nids = alc662_dac_nids,
18901 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18902 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018903 .unsol_event = alc663_m51va_unsol_event,
18904 .init_hook = alc663_m51va_inithook,
18905 },
18906 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018907 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018908 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18909 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18910 .dac_nids = alc662_dac_nids,
18911 .dig_out_nid = ALC662_DIGOUT_NID,
18912 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18913 .channel_mode = alc662_3ST_6ch_modes,
18914 .input_mux = &alc663_capture_source,
18915 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018916 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018917 .init_hook = alc663_g50v_inithook,
18918 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018919 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018920 .mixers = { alc663_m51va_mixer },
18921 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018922 .init_verbs = { alc662_init_verbs,
18923 alc663_21jd_amic_init_verbs },
18924 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18925 .hp_nid = 0x03,
18926 .dac_nids = alc662_dac_nids,
18927 .dig_out_nid = ALC662_DIGOUT_NID,
18928 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18929 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018930 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018931 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018932 .init_hook = alc663_mode1_inithook,
18933 },
18934 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018935 .mixers = { alc662_1bjd_mixer },
18936 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018937 .init_verbs = { alc662_init_verbs,
18938 alc662_1bjd_amic_init_verbs },
18939 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18940 .dac_nids = alc662_dac_nids,
18941 .dig_out_nid = ALC662_DIGOUT_NID,
18942 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18943 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018944 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018945 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018946 .init_hook = alc662_mode2_inithook,
18947 },
18948 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018949 .mixers = { alc663_two_hp_m1_mixer },
18950 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018951 .init_verbs = { alc662_init_verbs,
18952 alc663_two_hp_amic_m1_init_verbs },
18953 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18954 .hp_nid = 0x03,
18955 .dac_nids = alc662_dac_nids,
18956 .dig_out_nid = ALC662_DIGOUT_NID,
18957 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18958 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018959 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018960 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018961 .init_hook = alc663_mode3_inithook,
18962 },
18963 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018964 .mixers = { alc663_asus_21jd_clfe_mixer },
18965 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018966 .init_verbs = { alc662_init_verbs,
18967 alc663_21jd_amic_init_verbs},
18968 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18969 .hp_nid = 0x03,
18970 .dac_nids = alc662_dac_nids,
18971 .dig_out_nid = ALC662_DIGOUT_NID,
18972 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18973 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018974 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018975 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018976 .init_hook = alc663_mode4_inithook,
18977 },
18978 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018979 .mixers = { alc663_asus_15jd_clfe_mixer },
18980 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018981 .init_verbs = { alc662_init_verbs,
18982 alc663_15jd_amic_init_verbs },
18983 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18984 .hp_nid = 0x03,
18985 .dac_nids = alc662_dac_nids,
18986 .dig_out_nid = ALC662_DIGOUT_NID,
18987 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18988 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018989 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018990 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018991 .init_hook = alc663_mode5_inithook,
18992 },
18993 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018994 .mixers = { alc663_two_hp_m2_mixer },
18995 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018996 .init_verbs = { alc662_init_verbs,
18997 alc663_two_hp_amic_m2_init_verbs },
18998 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18999 .hp_nid = 0x03,
19000 .dac_nids = alc662_dac_nids,
19001 .dig_out_nid = ALC662_DIGOUT_NID,
19002 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19003 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019004 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019005 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019006 .init_hook = alc663_mode6_inithook,
19007 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019008 [ALC663_ASUS_MODE7] = {
19009 .mixers = { alc663_mode7_mixer },
19010 .cap_mixer = alc662_auto_capture_mixer,
19011 .init_verbs = { alc662_init_verbs,
19012 alc663_mode7_init_verbs },
19013 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
19014 .hp_nid = 0x03,
19015 .dac_nids = alc662_dac_nids,
19016 .dig_out_nid = ALC662_DIGOUT_NID,
19017 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19018 .channel_mode = alc662_3ST_2ch_modes,
19019 .unsol_event = alc663_mode7_unsol_event,
19020 .setup = alc663_mode7_setup,
19021 .init_hook = alc663_mode7_inithook,
19022 },
19023 [ALC663_ASUS_MODE8] = {
19024 .mixers = { alc663_mode8_mixer },
19025 .cap_mixer = alc662_auto_capture_mixer,
19026 .init_verbs = { alc662_init_verbs,
19027 alc663_mode8_init_verbs },
19028 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
19029 .hp_nid = 0x03,
19030 .dac_nids = alc662_dac_nids,
19031 .dig_out_nid = ALC662_DIGOUT_NID,
19032 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19033 .channel_mode = alc662_3ST_2ch_modes,
19034 .unsol_event = alc663_mode8_unsol_event,
19035 .setup = alc663_mode8_setup,
19036 .init_hook = alc663_mode8_inithook,
19037 },
Kailang Yang622e84c2009-04-21 07:39:04 +020019038 [ALC272_DELL] = {
19039 .mixers = { alc663_m51va_mixer },
19040 .cap_mixer = alc272_auto_capture_mixer,
19041 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
19042 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19043 .dac_nids = alc662_dac_nids,
19044 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19045 .adc_nids = alc272_adc_nids,
19046 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
19047 .capsrc_nids = alc272_capsrc_nids,
19048 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020019049 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019050 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020019051 .init_hook = alc663_m51va_inithook,
19052 },
19053 [ALC272_DELL_ZM1] = {
19054 .mixers = { alc663_m51va_mixer },
19055 .cap_mixer = alc662_auto_capture_mixer,
19056 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
19057 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19058 .dac_nids = alc662_dac_nids,
19059 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19060 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019061 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020019062 .capsrc_nids = alc662_capsrc_nids,
19063 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020019064 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019065 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020019066 .init_hook = alc663_m51va_inithook,
19067 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020019068 [ALC272_SAMSUNG_NC10] = {
19069 .mixers = { alc272_nc10_mixer },
19070 .init_verbs = { alc662_init_verbs,
19071 alc663_21jd_amic_init_verbs },
19072 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19073 .dac_nids = alc272_dac_nids,
19074 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19075 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019076 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020019077 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019078 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020019079 .init_hook = alc663_mode4_inithook,
19080 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019081};
19082
19083
19084/*
19085 * BIOS auto configuration
19086 */
19087
Takashi Iwai7085ec12009-10-02 09:03:58 +020019088/* convert from MIX nid to DAC */
19089static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
19090{
19091 if (nid == 0x0f)
19092 return 0x02;
19093 else if (nid >= 0x0c && nid <= 0x0e)
19094 return nid - 0x0c + 0x02;
David Henningssoncc1c4522010-11-24 14:17:47 +010019095 else if (nid == 0x26) /* ALC887-VD has this DAC too */
19096 return 0x25;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019097 else
19098 return 0;
19099}
19100
19101/* get MIX nid connected to the given pin targeted to DAC */
19102static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
19103 hda_nid_t dac)
19104{
David Henningssoncc1c4522010-11-24 14:17:47 +010019105 hda_nid_t mix[5];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019106 int i, num;
19107
19108 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
19109 for (i = 0; i < num; i++) {
19110 if (alc662_mix_to_dac(mix[i]) == dac)
19111 return mix[i];
19112 }
19113 return 0;
19114}
19115
19116/* look for an empty DAC slot */
19117static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
19118{
19119 struct alc_spec *spec = codec->spec;
19120 hda_nid_t srcs[5];
19121 int i, j, num;
19122
19123 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
19124 if (num < 0)
19125 return 0;
19126 for (i = 0; i < num; i++) {
19127 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
19128 if (!nid)
19129 continue;
19130 for (j = 0; j < spec->multiout.num_dacs; j++)
19131 if (spec->multiout.dac_nids[j] == nid)
19132 break;
19133 if (j >= spec->multiout.num_dacs)
19134 return nid;
19135 }
19136 return 0;
19137}
19138
19139/* fill in the dac_nids table from the parsed pin configuration */
19140static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
19141 const struct auto_pin_cfg *cfg)
19142{
19143 struct alc_spec *spec = codec->spec;
19144 int i;
19145 hda_nid_t dac;
19146
19147 spec->multiout.dac_nids = spec->private_dac_nids;
19148 for (i = 0; i < cfg->line_outs; i++) {
19149 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
19150 if (!dac)
19151 continue;
19152 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19153 }
19154 return 0;
19155}
19156
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019157static inline int __alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
19158 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019159{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019160 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019161 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
19162}
19163
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019164static inline int __alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
19165 hda_nid_t nid, int idx, unsigned int chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019166{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019167 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019168 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
19169}
19170
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019171#define alc662_add_vol_ctl(spec, pfx, nid, chs) \
19172 __alc662_add_vol_ctl(spec, pfx, nid, 0, chs)
19173#define alc662_add_sw_ctl(spec, pfx, nid, chs) \
19174 __alc662_add_sw_ctl(spec, pfx, nid, 0, chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019175#define alc662_add_stereo_vol(spec, pfx, nid) \
19176 alc662_add_vol_ctl(spec, pfx, nid, 3)
19177#define alc662_add_stereo_sw(spec, pfx, nid) \
19178 alc662_add_sw_ctl(spec, pfx, nid, 3)
19179
19180/* add playback controls from the parsed DAC table */
19181static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
19182 const struct auto_pin_cfg *cfg)
19183{
19184 struct alc_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +010019185 static const char * const chname[4] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019186 "Front", "Surround", NULL /*CLFE*/, "Side"
19187 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019188 const char *pfx = alc_get_line_out_pfx(cfg, true);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019189 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019190 int i, err;
19191
19192 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019193 nid = spec->multiout.dac_nids[i];
19194 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019195 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019196 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
19197 if (!mix)
19198 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019199 if (!pfx && i == 2) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019200 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019201 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019202 if (err < 0)
19203 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019204 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019205 if (err < 0)
19206 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019207 err = alc662_add_sw_ctl(spec, "Center", mix, 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_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019211 if (err < 0)
19212 return err;
19213 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019214 const char *name = pfx;
19215 if (!name)
19216 name = chname[i];
19217 err = __alc662_add_vol_ctl(spec, name, nid, i, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019218 if (err < 0)
19219 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019220 err = __alc662_add_sw_ctl(spec, name, mix, i, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019221 if (err < 0)
19222 return err;
19223 }
19224 }
19225 return 0;
19226}
19227
19228/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019229/* return DAC nid if any new DAC is assigned */
19230static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019231 const char *pfx)
19232{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019233 struct alc_spec *spec = codec->spec;
19234 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019235 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019236
19237 if (!pin)
19238 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019239 nid = alc662_look_for_dac(codec, pin);
19240 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019241 /* the corresponding DAC is already occupied */
19242 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
19243 return 0; /* no way */
19244 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019245 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019246 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19247 }
19248
19249 mix = alc662_dac_to_mix(codec, pin, nid);
19250 if (!mix)
19251 return 0;
19252 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
19253 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020019254 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019255 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
19256 if (err < 0)
19257 return err;
19258 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019259}
19260
19261/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020019262#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020019263 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019264
19265static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
19266 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019267 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019268{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019269 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020019270 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019271
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019272 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019273 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019274 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
19275 if (num <= 1)
19276 return;
19277 for (i = 0; i < num; i++) {
19278 if (alc662_mix_to_dac(srcs[i]) != dac)
19279 continue;
19280 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
19281 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019282 }
19283}
19284
19285static void alc662_auto_init_multi_out(struct hda_codec *codec)
19286{
19287 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019288 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019289 int i;
19290
19291 for (i = 0; i <= HDA_SIDE; i++) {
19292 hda_nid_t nid = spec->autocfg.line_out_pins[i];
19293 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020019294 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019295 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019296 }
19297}
19298
19299static void alc662_auto_init_hp_out(struct hda_codec *codec)
19300{
19301 struct alc_spec *spec = codec->spec;
19302 hda_nid_t pin;
19303
19304 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019305 if (pin)
19306 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
19307 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019308 pin = spec->autocfg.speaker_pins[0];
19309 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019310 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
19311 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019312}
19313
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019314#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
19315
19316static void alc662_auto_init_analog_input(struct hda_codec *codec)
19317{
19318 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019319 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019320 int i;
19321
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019322 for (i = 0; i < cfg->num_inputs; i++) {
19323 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019324 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020019325 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010019326 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010019327 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019328 snd_hda_codec_write(codec, nid, 0,
19329 AC_VERB_SET_AMP_GAIN_MUTE,
19330 AMP_OUT_MUTE);
19331 }
19332 }
19333}
19334
Takashi Iwaif511b012008-08-15 16:46:42 +020019335#define alc662_auto_init_input_src alc882_auto_init_input_src
19336
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019337static int alc662_parse_auto_config(struct hda_codec *codec)
19338{
19339 struct alc_spec *spec = codec->spec;
19340 int err;
19341 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
19342
19343 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19344 alc662_ignore);
19345 if (err < 0)
19346 return err;
19347 if (!spec->autocfg.line_outs)
19348 return 0; /* can't find valid BIOS pin config */
19349
Takashi Iwai7085ec12009-10-02 09:03:58 +020019350 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019351 if (err < 0)
19352 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019353 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019354 if (err < 0)
19355 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019356 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019357 spec->autocfg.speaker_pins[0],
19358 "Speaker");
19359 if (err < 0)
19360 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019361 if (err)
19362 spec->multiout.extra_out_nid[0] = err;
19363 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019364 "Headphone");
19365 if (err < 0)
19366 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019367 if (err)
19368 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019369 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019370 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019371 return err;
19372
19373 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
19374
Takashi Iwai757899a2010-07-30 10:48:14 +020019375 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019376
Takashi Iwai603c4012008-07-30 15:01:44 +020019377 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010019378 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019379
19380 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020019381 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020019382
Kailang Yangcec27c82010-02-04 14:18:18 +010019383 add_verb(spec, alc662_init_verbs);
19384 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019385 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Kailang Yangcec27c82010-02-04 14:18:18 +010019386 add_verb(spec, alc663_init_verbs);
19387
19388 if (codec->vendor_id == 0x10ec0272)
19389 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020019390
19391 err = alc_auto_add_mic_boost(codec);
19392 if (err < 0)
19393 return err;
19394
Kailang Yang6227cdc2010-02-25 08:36:52 +010019395 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
19396 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
19397 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
19398 else
19399 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020019400
Takashi Iwai8c872862007-06-19 12:11:16 +020019401 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019402}
19403
19404/* additional initialization for auto-configuration model */
19405static void alc662_auto_init(struct hda_codec *codec)
19406{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019407 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019408 alc662_auto_init_multi_out(codec);
19409 alc662_auto_init_hp_out(codec);
19410 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020019411 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019412 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019413 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020019414 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019415}
19416
Todd Broch6be79482010-12-07 16:51:05 -080019417static void alc272_fixup_mario(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019418 const struct alc_fixup *fix, int action)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010019419{
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019420 if (action != ALC_FIXUP_ACT_PROBE)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010019421 return;
Todd Broch6be79482010-12-07 16:51:05 -080019422 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
19423 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
19424 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
19425 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
19426 (0 << AC_AMPCAP_MUTE_SHIFT)))
19427 printk(KERN_WARNING
19428 "hda_codec: failed to override amp caps for NID 0x2\n");
19429}
19430
David Henningsson6cb3b702010-09-09 08:51:44 +020019431enum {
Daniel T Chen2df03512010-10-10 22:39:28 -040019432 ALC662_FIXUP_ASPIRE,
David Henningsson6cb3b702010-09-09 08:51:44 +020019433 ALC662_FIXUP_IDEAPAD,
Todd Broch6be79482010-12-07 16:51:05 -080019434 ALC272_FIXUP_MARIO,
Anisse Astierd2ebd472011-01-20 12:36:21 +010019435 ALC662_FIXUP_CZC_P10T,
David Henningsson6cb3b702010-09-09 08:51:44 +020019436};
19437
19438static const struct alc_fixup alc662_fixups[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019439 [ALC662_FIXUP_ASPIRE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019440 .type = ALC_FIXUP_PINS,
19441 .v.pins = (const struct alc_pincfg[]) {
Daniel T Chen2df03512010-10-10 22:39:28 -040019442 { 0x15, 0x99130112 }, /* subwoofer */
19443 { }
19444 }
19445 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019446 [ALC662_FIXUP_IDEAPAD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019447 .type = ALC_FIXUP_PINS,
19448 .v.pins = (const struct alc_pincfg[]) {
David Henningsson6cb3b702010-09-09 08:51:44 +020019449 { 0x17, 0x99130112 }, /* subwoofer */
19450 { }
19451 }
19452 },
Todd Broch6be79482010-12-07 16:51:05 -080019453 [ALC272_FIXUP_MARIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019454 .type = ALC_FIXUP_FUNC,
19455 .v.func = alc272_fixup_mario,
Anisse Astierd2ebd472011-01-20 12:36:21 +010019456 },
19457 [ALC662_FIXUP_CZC_P10T] = {
19458 .type = ALC_FIXUP_VERBS,
19459 .v.verbs = (const struct hda_verb[]) {
19460 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
19461 {}
19462 }
19463 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019464};
19465
19466static struct snd_pci_quirk alc662_fixup_tbl[] = {
David Henningssona6c47a82011-02-10 15:39:19 +010019467 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
Daniel T Chen2df03512010-10-10 22:39:28 -040019468 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
Daniel T Chena0e90ac2010-11-20 10:20:35 -050019469 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
Valentine Sinitsynd4118582010-10-01 22:24:08 +060019470 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
David Henningsson6cb3b702010-09-09 08:51:44 +020019471 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
Anisse Astierd2ebd472011-01-20 12:36:21 +010019472 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
David Henningsson6cb3b702010-09-09 08:51:44 +020019473 {}
19474};
19475
Todd Broch6be79482010-12-07 16:51:05 -080019476static const struct alc_model_fixup alc662_fixup_models[] = {
19477 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
19478 {}
19479};
David Henningsson6cb3b702010-09-09 08:51:44 +020019480
19481
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019482static int patch_alc662(struct hda_codec *codec)
19483{
19484 struct alc_spec *spec;
19485 int err, board_config;
Kailang Yang693194f2010-10-21 08:51:48 +020019486 int coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019487
19488 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19489 if (!spec)
19490 return -ENOMEM;
19491
19492 codec->spec = spec;
19493
Kailang Yangda00c242010-03-19 11:23:45 +010019494 alc_auto_parse_customize_define(codec);
19495
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020019496 alc_fix_pll_init(codec, 0x20, 0x04, 15);
19497
Kailang Yang693194f2010-10-21 08:51:48 +020019498 coef = alc_read_coef_idx(codec, 0);
19499 if (coef == 0x8020 || coef == 0x8011)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019500 alc_codec_rename(codec, "ALC661");
Kailang Yang693194f2010-10-21 08:51:48 +020019501 else if (coef & (1 << 14) &&
19502 codec->bus->pci->subsystem_vendor == 0x1025 &&
19503 spec->cdefine.platform_type == 1)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019504 alc_codec_rename(codec, "ALC272X");
Kailang Yang693194f2010-10-21 08:51:48 +020019505 else if (coef == 0x4011)
19506 alc_codec_rename(codec, "ALC656");
Kailang Yang274693f2009-12-03 10:07:50 +010019507
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019508 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19509 alc662_models,
19510 alc662_cfg_tbl);
19511 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019512 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19513 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019514 board_config = ALC662_AUTO;
19515 }
19516
19517 if (board_config == ALC662_AUTO) {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019518 alc_pick_fixup(codec, alc662_fixup_models,
19519 alc662_fixup_tbl, alc662_fixups);
19520 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019521 /* automatic parse from the BIOS config */
19522 err = alc662_parse_auto_config(codec);
19523 if (err < 0) {
19524 alc_free(codec);
19525 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020019526 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019527 printk(KERN_INFO
19528 "hda_codec: Cannot set up configuration "
19529 "from BIOS. Using base mode...\n");
19530 board_config = ALC662_3ST_2ch_DIG;
19531 }
19532 }
19533
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019534 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019535 err = snd_hda_attach_beep_device(codec, 0x1);
19536 if (err < 0) {
19537 alc_free(codec);
19538 return err;
19539 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019540 }
19541
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019542 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019543 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019544
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019545 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19546 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19547
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019548 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19549 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19550
Takashi Iwaidd704692009-08-11 08:45:11 +020019551 if (!spec->adc_nids) {
19552 spec->adc_nids = alc662_adc_nids;
19553 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19554 }
19555 if (!spec->capsrc_nids)
19556 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019557
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019558 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019559 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019560
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019561 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019562 switch (codec->vendor_id) {
19563 case 0x10ec0662:
19564 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19565 break;
19566 case 0x10ec0272:
19567 case 0x10ec0663:
19568 case 0x10ec0665:
19569 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19570 break;
19571 case 0x10ec0273:
19572 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19573 break;
19574 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019575 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019576 spec->vmaster_nid = 0x02;
19577
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019578 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
19579
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019580 codec->patch_ops = alc_patch_ops;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019581 if (board_config == ALC662_AUTO)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019582 spec->init_hook = alc662_auto_init;
David Henningsson6cb3b702010-09-09 08:51:44 +020019583
Kailang Yangbf1b0222010-10-21 08:49:56 +020019584 alc_init_jacks(codec);
19585
Takashi Iwaicb53c622007-08-10 17:21:45 +020019586#ifdef CONFIG_SND_HDA_POWER_SAVE
19587 if (!spec->loopback.amplist)
19588 spec->loopback.amplist = alc662_loopbacks;
19589#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019590
19591 return 0;
19592}
19593
Kailang Yang274693f2009-12-03 10:07:50 +010019594static int patch_alc888(struct hda_codec *codec)
19595{
19596 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19597 kfree(codec->chip_name);
Kailang Yang01e0f132010-11-22 10:59:36 +010019598 if (codec->vendor_id == 0x10ec0887)
19599 codec->chip_name = kstrdup("ALC887-VD", GFP_KERNEL);
19600 else
19601 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019602 if (!codec->chip_name) {
19603 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019604 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019605 }
19606 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019607 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019608 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019609}
19610
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019611/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019612 * ALC680 support
19613 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019614#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019615#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19616#define alc680_modes alc260_modes
19617
19618static hda_nid_t alc680_dac_nids[3] = {
19619 /* Lout1, Lout2, hp */
19620 0x02, 0x03, 0x04
19621};
19622
19623static hda_nid_t alc680_adc_nids[3] = {
19624 /* ADC0-2 */
19625 /* DMIC, MIC, Line-in*/
19626 0x07, 0x08, 0x09
19627};
19628
Kailang Yangc69aefa2010-08-17 10:39:22 +020019629/*
19630 * Analog capture ADC cgange
19631 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019632static void alc680_rec_autoswitch(struct hda_codec *codec)
19633{
19634 struct alc_spec *spec = codec->spec;
19635 struct auto_pin_cfg *cfg = &spec->autocfg;
19636 int pin_found = 0;
19637 int type_found = AUTO_PIN_LAST;
19638 hda_nid_t nid;
19639 int i;
19640
19641 for (i = 0; i < cfg->num_inputs; i++) {
19642 nid = cfg->inputs[i].pin;
19643 if (!(snd_hda_query_pin_caps(codec, nid) &
19644 AC_PINCAP_PRES_DETECT))
19645 continue;
19646 if (snd_hda_jack_detect(codec, nid)) {
19647 if (cfg->inputs[i].type < type_found) {
19648 type_found = cfg->inputs[i].type;
19649 pin_found = nid;
19650 }
19651 }
19652 }
19653
19654 nid = 0x07;
19655 if (pin_found)
19656 snd_hda_get_connections(codec, pin_found, &nid, 1);
19657
19658 if (nid != spec->cur_adc)
19659 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19660 spec->cur_adc = nid;
19661 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19662 spec->cur_adc_format);
19663}
19664
Kailang Yangc69aefa2010-08-17 10:39:22 +020019665static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19666 struct hda_codec *codec,
19667 unsigned int stream_tag,
19668 unsigned int format,
19669 struct snd_pcm_substream *substream)
19670{
19671 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019672
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019673 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019674 spec->cur_adc_stream_tag = stream_tag;
19675 spec->cur_adc_format = format;
19676
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019677 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019678 return 0;
19679}
19680
19681static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19682 struct hda_codec *codec,
19683 struct snd_pcm_substream *substream)
19684{
19685 snd_hda_codec_cleanup_stream(codec, 0x07);
19686 snd_hda_codec_cleanup_stream(codec, 0x08);
19687 snd_hda_codec_cleanup_stream(codec, 0x09);
19688 return 0;
19689}
19690
19691static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19692 .substreams = 1, /* can be overridden */
19693 .channels_min = 2,
19694 .channels_max = 2,
19695 /* NID is set in alc_build_pcms */
19696 .ops = {
19697 .prepare = alc680_capture_pcm_prepare,
19698 .cleanup = alc680_capture_pcm_cleanup
19699 },
19700};
19701
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019702static struct snd_kcontrol_new alc680_base_mixer[] = {
19703 /* output mixer control */
19704 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19705 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19706 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19707 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010019708 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x12, 0, HDA_INPUT),
19709 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
19710 HDA_CODEC_VOLUME("Line In Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019711 { }
19712};
19713
Kailang Yangc69aefa2010-08-17 10:39:22 +020019714static struct hda_bind_ctls alc680_bind_cap_vol = {
19715 .ops = &snd_hda_bind_vol,
19716 .values = {
19717 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19718 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19719 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19720 0
19721 },
19722};
19723
19724static struct hda_bind_ctls alc680_bind_cap_switch = {
19725 .ops = &snd_hda_bind_sw,
19726 .values = {
19727 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19728 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19729 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19730 0
19731 },
19732};
19733
19734static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19735 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19736 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019737 { } /* end */
19738};
19739
19740/*
19741 * generic initialization of ADC, input mixers and output mixers
19742 */
19743static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019744 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19745 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19746 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019747
Kailang Yangc69aefa2010-08-17 10:39:22 +020019748 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19749 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19750 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19751 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19752 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19753 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019754
19755 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19756 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19757 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19758 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19759 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019760
19761 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19762 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019763 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019764
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019765 { }
19766};
19767
Kailang Yangc69aefa2010-08-17 10:39:22 +020019768/* toggle speaker-output according to the hp-jack state */
19769static void alc680_base_setup(struct hda_codec *codec)
19770{
19771 struct alc_spec *spec = codec->spec;
19772
19773 spec->autocfg.hp_pins[0] = 0x16;
19774 spec->autocfg.speaker_pins[0] = 0x14;
19775 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019776 spec->autocfg.num_inputs = 2;
19777 spec->autocfg.inputs[0].pin = 0x18;
19778 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19779 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019780 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019781}
19782
19783static void alc680_unsol_event(struct hda_codec *codec,
19784 unsigned int res)
19785{
19786 if ((res >> 26) == ALC880_HP_EVENT)
19787 alc_automute_amp(codec);
19788 if ((res >> 26) == ALC880_MIC_EVENT)
19789 alc680_rec_autoswitch(codec);
19790}
19791
19792static void alc680_inithook(struct hda_codec *codec)
19793{
19794 alc_automute_amp(codec);
19795 alc680_rec_autoswitch(codec);
19796}
19797
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019798/* create input playback/capture controls for the given pin */
19799static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19800 const char *ctlname, int idx)
19801{
19802 hda_nid_t dac;
19803 int err;
19804
19805 switch (nid) {
19806 case 0x14:
19807 dac = 0x02;
19808 break;
19809 case 0x15:
19810 dac = 0x03;
19811 break;
19812 case 0x16:
19813 dac = 0x04;
19814 break;
19815 default:
19816 return 0;
19817 }
19818 if (spec->multiout.dac_nids[0] != dac &&
19819 spec->multiout.dac_nids[1] != dac) {
19820 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19821 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19822 HDA_OUTPUT));
19823 if (err < 0)
19824 return err;
19825
19826 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19827 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19828
19829 if (err < 0)
19830 return err;
19831 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19832 }
19833
19834 return 0;
19835}
19836
19837/* add playback controls from the parsed DAC table */
19838static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19839 const struct auto_pin_cfg *cfg)
19840{
19841 hda_nid_t nid;
19842 int err;
19843
19844 spec->multiout.dac_nids = spec->private_dac_nids;
19845
19846 nid = cfg->line_out_pins[0];
19847 if (nid) {
19848 const char *name;
19849 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19850 name = "Speaker";
19851 else
19852 name = "Front";
19853 err = alc680_new_analog_output(spec, nid, name, 0);
19854 if (err < 0)
19855 return err;
19856 }
19857
19858 nid = cfg->speaker_pins[0];
19859 if (nid) {
19860 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19861 if (err < 0)
19862 return err;
19863 }
19864 nid = cfg->hp_pins[0];
19865 if (nid) {
19866 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19867 if (err < 0)
19868 return err;
19869 }
19870
19871 return 0;
19872}
19873
19874static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19875 hda_nid_t nid, int pin_type)
19876{
19877 alc_set_pin_output(codec, nid, pin_type);
19878}
19879
19880static void alc680_auto_init_multi_out(struct hda_codec *codec)
19881{
19882 struct alc_spec *spec = codec->spec;
19883 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19884 if (nid) {
19885 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19886 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19887 }
19888}
19889
19890static void alc680_auto_init_hp_out(struct hda_codec *codec)
19891{
19892 struct alc_spec *spec = codec->spec;
19893 hda_nid_t pin;
19894
19895 pin = spec->autocfg.hp_pins[0];
19896 if (pin)
19897 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19898 pin = spec->autocfg.speaker_pins[0];
19899 if (pin)
19900 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19901}
19902
19903/* pcm configuration: identical with ALC880 */
19904#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19905#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19906#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19907#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019908#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019909
19910/*
19911 * BIOS auto configuration
19912 */
19913static int alc680_parse_auto_config(struct hda_codec *codec)
19914{
19915 struct alc_spec *spec = codec->spec;
19916 int err;
19917 static hda_nid_t alc680_ignore[] = { 0 };
19918
19919 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19920 alc680_ignore);
19921 if (err < 0)
19922 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019923
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019924 if (!spec->autocfg.line_outs) {
19925 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19926 spec->multiout.max_channels = 2;
19927 spec->no_analog = 1;
19928 goto dig_only;
19929 }
19930 return 0; /* can't find valid BIOS pin config */
19931 }
19932 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19933 if (err < 0)
19934 return err;
19935
19936 spec->multiout.max_channels = 2;
19937
19938 dig_only:
19939 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019940 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019941 if (spec->kctls.list)
19942 add_mixer(spec, spec->kctls.list);
19943
19944 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019945
19946 err = alc_auto_add_mic_boost(codec);
19947 if (err < 0)
19948 return err;
19949
19950 return 1;
19951}
19952
19953#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19954
19955/* init callback for auto-configuration model -- overriding the default init */
19956static void alc680_auto_init(struct hda_codec *codec)
19957{
19958 struct alc_spec *spec = codec->spec;
19959 alc680_auto_init_multi_out(codec);
19960 alc680_auto_init_hp_out(codec);
19961 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019962 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019963 if (spec->unsol_event)
19964 alc_inithook(codec);
19965}
19966
19967/*
19968 * configuration and preset
19969 */
Takashi Iwaiea734962011-01-17 11:29:34 +010019970static const char * const alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019971 [ALC680_BASE] = "base",
19972 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019973};
19974
19975static struct snd_pci_quirk alc680_cfg_tbl[] = {
19976 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19977 {}
19978};
19979
19980static struct alc_config_preset alc680_presets[] = {
19981 [ALC680_BASE] = {
19982 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019983 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019984 .init_verbs = { alc680_init_verbs },
19985 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19986 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019987 .dig_out_nid = ALC680_DIGOUT_NID,
19988 .num_channel_mode = ARRAY_SIZE(alc680_modes),
19989 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020019990 .unsol_event = alc680_unsol_event,
19991 .setup = alc680_base_setup,
19992 .init_hook = alc680_inithook,
19993
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019994 },
19995};
19996
19997static int patch_alc680(struct hda_codec *codec)
19998{
19999 struct alc_spec *spec;
20000 int board_config;
20001 int err;
20002
20003 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
20004 if (spec == NULL)
20005 return -ENOMEM;
20006
20007 codec->spec = spec;
20008
20009 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
20010 alc680_models,
20011 alc680_cfg_tbl);
20012
20013 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
20014 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
20015 codec->chip_name);
20016 board_config = ALC680_AUTO;
20017 }
20018
20019 if (board_config == ALC680_AUTO) {
20020 /* automatic parse from the BIOS config */
20021 err = alc680_parse_auto_config(codec);
20022 if (err < 0) {
20023 alc_free(codec);
20024 return err;
20025 } else if (!err) {
20026 printk(KERN_INFO
20027 "hda_codec: Cannot set up configuration "
20028 "from BIOS. Using base mode...\n");
20029 board_config = ALC680_BASE;
20030 }
20031 }
20032
20033 if (board_config != ALC680_AUTO)
20034 setup_preset(codec, &alc680_presets[board_config]);
20035
20036 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020020037 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020038 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020020039 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020040
20041 if (!spec->adc_nids) {
20042 spec->adc_nids = alc680_adc_nids;
20043 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
20044 }
20045
20046 if (!spec->cap_mixer)
20047 set_capture_mixer(codec);
20048
20049 spec->vmaster_nid = 0x02;
20050
20051 codec->patch_ops = alc_patch_ops;
20052 if (board_config == ALC680_AUTO)
20053 spec->init_hook = alc680_auto_init;
20054
20055 return 0;
20056}
20057
20058/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070020059 * patch entries
20060 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010020061static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070020062 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020063 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020064 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020020065 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020066 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020067 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020020068 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020069 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020070 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020071 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020072 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
20073 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
20074 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020075 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020076 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020077 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
20078 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020020079 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010020080 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010020081 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020082 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020083 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020084 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020085 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020020086 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020087 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020020088 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020089 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020090 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yang01e0f132010-11-22 10:59:36 +010020091 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc888 },
Kailang Yang44426082008-10-15 11:18:05 +020020092 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020093 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020094 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020095 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020096 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020097 {} /* terminator */
20098};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010020099
20100MODULE_ALIAS("snd-hda-codec-id:10ec*");
20101
20102MODULE_LICENSE("GPL");
20103MODULE_DESCRIPTION("Realtek HD-audio codec");
20104
20105static struct hda_codec_preset_list realtek_list = {
20106 .preset = snd_hda_preset_realtek,
20107 .owner = THIS_MODULE,
20108};
20109
20110static int __init patch_realtek_init(void)
20111{
20112 return snd_hda_add_codec_preset(&realtek_list);
20113}
20114
20115static void __exit patch_realtek_exit(void)
20116{
20117 snd_hda_delete_codec_preset(&realtek_list);
20118}
20119
20120module_init(patch_realtek_init)
20121module_exit(patch_realtek_exit)