blob: b4a22dd775a22ae21e64912ac3592e953f960efd [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
Kailang Yang9ad0e492010-09-14 23:22:00 +020031#include <sound/jack.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include "hda_codec.h"
33#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090034#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
Kailang Yangccc656c2006-10-17 12:32:26 +020036#define ALC880_FRONT_EVENT 0x01
37#define ALC880_DCVOL_EVENT 0x02
38#define ALC880_HP_EVENT 0x04
39#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
41/* ALC880 board config type */
42enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 ALC880_3ST,
44 ALC880_3ST_DIG,
45 ALC880_5ST,
46 ALC880_5ST_DIG,
47 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020048 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020049 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020050 ALC880_6ST_DIG,
51 ALC880_F1734,
52 ALC880_ASUS,
53 ALC880_ASUS_DIG,
54 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010055 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010056 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020057 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020058 ALC880_UNIWILL,
59 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010060 ALC880_CLEVO,
61 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010062 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010063 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020064 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020065#ifdef CONFIG_SND_DEBUG
66 ALC880_TEST,
67#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010068 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020069 ALC880_MODEL_LAST /* last tag */
70};
71
72/* ALC260 models */
73enum {
74 ALC260_BASIC,
75 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020076 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010077 ALC260_HP_3013,
78 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010079 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020080 ALC260_WILL,
81 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010082 ALC260_FAVORIT100,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010083#ifdef CONFIG_SND_DEBUG
84 ALC260_TEST,
85#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010086 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020087 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070088};
89
Kailang Yangdf694da2005-12-05 19:42:22 +010090/* ALC262 models */
91enum {
92 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020093 ALC262_HIPPO,
94 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010095 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020096 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010097 ALC262_HP_BPC_D7000_WL,
98 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010099 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +0100100 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200101 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200102 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200103 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200104 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100105 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200106 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200107 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200108 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000109 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100110 ALC262_AUTO,
111 ALC262_MODEL_LAST /* last tag */
112};
113
Kailang Yanga361d842007-06-05 12:30:55 +0200114/* ALC268 models */
115enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200116 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200117 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200118 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200119 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100120 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200121 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100122 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100123 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100124#ifdef CONFIG_SND_DEBUG
125 ALC268_TEST,
126#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200127 ALC268_AUTO,
128 ALC268_MODEL_LAST /* last tag */
129};
130
Kailang Yangf6a92242007-12-13 16:52:54 +0100131/* ALC269 models */
132enum {
133 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200134 ALC269_QUANTA_FL1,
Kailang Yang84898e82010-02-04 14:16:14 +0100135 ALC269_AMIC,
136 ALC269_DMIC,
137 ALC269VB_AMIC,
138 ALC269VB_DMIC,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100139 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000140 ALC269_LIFEBOOK,
Kailang Yangfe3eb0a2010-08-06 10:02:57 +0200141 ALC271_ACER,
Kailang Yangf6a92242007-12-13 16:52:54 +0100142 ALC269_AUTO,
143 ALC269_MODEL_LAST /* last tag */
144};
145
Kailang Yangdf694da2005-12-05 19:42:22 +0100146/* ALC861 models */
147enum {
148 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200149 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100150 ALC861_3ST_DIG,
151 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200152 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200153 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200154 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100155 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100156 ALC861_AUTO,
157 ALC861_MODEL_LAST,
158};
159
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100160/* ALC861-VD models */
161enum {
162 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200163 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100164 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100165 ALC861VD_3ST,
166 ALC861VD_3ST_DIG,
167 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200168 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200169 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200170 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100171 ALC861VD_AUTO,
172 ALC861VD_MODEL_LAST,
173};
174
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200175/* ALC662 models */
176enum {
177 ALC662_3ST_2ch_DIG,
178 ALC662_3ST_6ch_DIG,
179 ALC662_3ST_6ch,
180 ALC662_5ST_DIG,
181 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200182 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100183 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200184 ALC663_ASUS_M51VA,
185 ALC663_ASUS_G71V,
186 ALC663_ASUS_H13,
187 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200188 ALC662_ECS,
189 ALC663_ASUS_MODE1,
190 ALC662_ASUS_MODE2,
191 ALC663_ASUS_MODE3,
192 ALC663_ASUS_MODE4,
193 ALC663_ASUS_MODE5,
194 ALC663_ASUS_MODE6,
Kailang Yangebb83ee2009-12-17 12:23:00 +0100195 ALC663_ASUS_MODE7,
196 ALC663_ASUS_MODE8,
Kailang Yang622e84c2009-04-21 07:39:04 +0200197 ALC272_DELL,
198 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200199 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200200 ALC662_AUTO,
201 ALC662_MODEL_LAST,
202};
203
Kailang Yangdf694da2005-12-05 19:42:22 +0100204/* ALC882 models */
205enum {
206 ALC882_3ST_DIG,
207 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200208 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200209 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200210 ALC882_TARGA,
211 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200212 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100213 ALC885_MACPRO,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -0800214 ALC885_MBA21,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200215 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200216 ALC885_MB5,
Luke Yelaviche458b1f2010-02-12 16:28:29 +1100217 ALC885_MACMINI3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200218 ALC885_IMAC24,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -0800219 ALC885_IMAC91,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200220 ALC883_3ST_2ch_DIG,
221 ALC883_3ST_6ch_DIG,
222 ALC883_3ST_6ch,
223 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200224 ALC883_TARGA_DIG,
225 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200226 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200227 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200228 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800229 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100230 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200231 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200232 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200233 ALC883_MEDION,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +0200234 ALC883_MEDION_WIM2160,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100235 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200236 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200237 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200238 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200239 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200240 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200241 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100242 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100243 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430244 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100245 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100246 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800247 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200248 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200249 ALC889A_INTEL,
250 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200251 ALC888_ASUS_M90V,
252 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200253 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100254 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200255 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200256 ALC882_AUTO,
257 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200258};
259
Takashi Iwaid4a86d82010-06-23 17:51:26 +0200260/* ALC680 models */
261enum {
262 ALC680_BASE,
263 ALC680_AUTO,
264 ALC680_MODEL_LAST,
265};
266
Kailang Yangdf694da2005-12-05 19:42:22 +0100267/* for GPIO Poll */
268#define GPIO_MASK 0x03
269
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200270/* extra amp-initialization sequence types */
271enum {
272 ALC_INIT_NONE,
273 ALC_INIT_DEFAULT,
274 ALC_INIT_GPIO1,
275 ALC_INIT_GPIO2,
276 ALC_INIT_GPIO3,
277};
278
Takashi Iwai6c819492009-08-10 18:47:44 +0200279struct alc_mic_route {
280 hda_nid_t pin;
281 unsigned char mux_idx;
282 unsigned char amix_idx;
283};
284
285#define MUX_IDX_UNDEF ((unsigned char)-1)
286
Kailang Yangda00c242010-03-19 11:23:45 +0100287struct alc_customize_define {
288 unsigned int sku_cfg;
289 unsigned char port_connectivity;
290 unsigned char check_sum;
291 unsigned char customization;
292 unsigned char external_amp;
293 unsigned int enable_pcbeep:1;
294 unsigned int platform_type:1;
295 unsigned int swap:1;
296 unsigned int override:1;
David Henningsson90622912010-10-14 14:50:18 +0200297 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
Kailang Yangda00c242010-03-19 11:23:45 +0100298};
299
Takashi Iwaib5bfbc62011-01-13 14:22:32 +0100300struct alc_fixup;
301
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302struct alc_spec {
303 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100304 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100306 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100307 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200309 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200310 * don't forget NULL
311 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200312 */
313 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200315 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 struct hda_pcm_stream *stream_analog_playback;
317 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100318 struct hda_pcm_stream *stream_analog_alt_playback;
319 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200321 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 struct hda_pcm_stream *stream_digital_playback;
323 struct hda_pcm_stream *stream_digital_capture;
324
325 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200326 struct hda_multi_out multiout; /* playback set-up
327 * max_channels, dacs must be set
328 * dig_out_nid and hp_nid are optional
329 */
Takashi Iwai63300792008-01-24 15:31:36 +0100330 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100331 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100332 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333
334 /* capture */
335 unsigned int num_adc_nids;
336 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100337 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200338 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339
Takashi Iwai840b64c2010-07-13 22:49:01 +0200340 /* capture setup for dynamic dual-adc switch */
341 unsigned int cur_adc_idx;
342 hda_nid_t cur_adc;
343 unsigned int cur_adc_stream_tag;
344 unsigned int cur_adc_format;
345
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200347 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 const struct hda_input_mux *input_mux;
349 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200350 struct alc_mic_route ext_mic;
351 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352
353 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100354 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200356 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200357 int const_channel_count;
358 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359
360 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100361 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200362
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200363 /* dynamic controls, init_verbs and input_mux */
364 struct auto_pin_cfg autocfg;
Kailang Yangda00c242010-03-19 11:23:45 +0100365 struct alc_customize_define cdefine;
Takashi Iwai603c4012008-07-30 15:01:44 +0200366 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200367 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200368 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200369 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
370 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100371
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100372 /* hooks */
373 void (*init_hook)(struct hda_codec *codec);
374 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100375#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -0500376 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100377#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100378
Takashi Iwai834be882006-03-01 14:16:17 +0100379 /* for pin sensing */
380 unsigned int sense_updated: 1;
381 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100382 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200383 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200384
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100385 /* other flags */
386 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai840b64c2010-07-13 22:49:01 +0200387 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200388 int init_amp;
Takashi Iwaid433a672010-09-20 15:11:54 +0200389 int codec_variant; /* flag for other variants */
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100390
Takashi Iwai2134ea42008-01-10 16:53:55 +0100391 /* for virtual master */
392 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200393#ifdef CONFIG_SND_HDA_POWER_SAVE
394 struct hda_loopback_check loopback;
395#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200396
397 /* for PLL fix */
398 hda_nid_t pll_nid;
399 unsigned int pll_coef_idx, pll_coef_bit;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +0100400
401 /* fix-up list */
402 int fixup_id;
403 const struct alc_fixup *fixup_list;
404 const char *fixup_name;
Kailang Yangdf694da2005-12-05 19:42:22 +0100405};
406
407/*
408 * configuration template - to be copied to the spec instance
409 */
410struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200411 struct snd_kcontrol_new *mixers[5]; /* should be identical size
412 * with spec
413 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100414 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100415 const struct hda_verb *init_verbs[5];
416 unsigned int num_dacs;
417 hda_nid_t *dac_nids;
418 hda_nid_t dig_out_nid; /* optional */
419 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800420 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100421 unsigned int num_adc_nids;
422 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100423 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100424 hda_nid_t dig_in_nid;
425 unsigned int num_channel_mode;
426 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200427 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200428 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200429 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100430 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100431 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200432 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100433 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200434#ifdef CONFIG_SND_HDA_POWER_SAVE
435 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500436 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200437#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438};
439
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440
441/*
442 * input MUX handling
443 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200444static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
445 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446{
447 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
448 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200449 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
450 if (mux_idx >= spec->num_mux_defs)
451 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100452 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
453 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200454 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455}
456
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200457static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
458 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459{
460 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
461 struct alc_spec *spec = codec->spec;
462 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
463
464 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
465 return 0;
466}
467
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200468static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
469 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470{
471 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
472 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100473 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100475 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100476 hda_nid_t nid = spec->capsrc_nids ?
477 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200478 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479
Takashi Iwaicd896c32008-11-18 12:36:33 +0100480 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
481 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100482 if (!imux->num_items && mux_idx > 0)
483 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100484
Takashi Iwaia22d5432009-07-27 12:54:26 +0200485 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200486 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100487 /* Matrix-mixer style (e.g. ALC882) */
488 unsigned int *cur_val = &spec->cur_mux[adc_idx];
489 unsigned int i, idx;
490
491 idx = ucontrol->value.enumerated.item[0];
492 if (idx >= imux->num_items)
493 idx = imux->num_items - 1;
494 if (*cur_val == idx)
495 return 0;
496 for (i = 0; i < imux->num_items; i++) {
497 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
498 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
499 imux->items[i].index,
500 HDA_AMP_MUTE, v);
501 }
502 *cur_val = idx;
503 return 1;
504 } else {
505 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100506 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100507 &spec->cur_mux[adc_idx]);
508 }
509}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200510
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511/*
512 * channel mode setting
513 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200514static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
515 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516{
517 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
518 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100519 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
520 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521}
522
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200523static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
524 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525{
526 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
527 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100528 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200529 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200530 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531}
532
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200533static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
534 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535{
536 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
537 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200538 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
539 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200540 &spec->ext_channel_count);
541 if (err >= 0 && !spec->const_channel_count) {
542 spec->multiout.max_channels = spec->ext_channel_count;
543 if (spec->need_dac_fix)
544 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
545 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200546 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547}
548
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100550 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200551 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100552 * being part of a format specifier. Maximum allowed length of a value is
553 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100554 *
555 * Note: some retasking pin complexes seem to ignore requests for input
556 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
557 * are requested. Therefore order this list so that this behaviour will not
558 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200559 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
560 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200561 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100562static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100563 "Mic 50pc bias", "Mic 80pc bias",
564 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100565};
566static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100567 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100568};
569/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200570 * in the pin being assumed to be exclusively an input or an output pin. In
571 * addition, "input" pins may or may not process the mic bias option
572 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
573 * accept requests for bias as of chip versions up to March 2006) and/or
574 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100575 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200576#define ALC_PIN_DIR_IN 0x00
577#define ALC_PIN_DIR_OUT 0x01
578#define ALC_PIN_DIR_INOUT 0x02
579#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
580#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100581
Kailang Yangea1fb292008-08-26 12:58:38 +0200582/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100583 * For each direction the minimum and maximum values are given.
584 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200585static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100586 { 0, 2 }, /* ALC_PIN_DIR_IN */
587 { 3, 4 }, /* ALC_PIN_DIR_OUT */
588 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200589 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
590 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100591};
592#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
593#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
594#define alc_pin_mode_n_items(_dir) \
595 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
596
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200597static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
598 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200599{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100600 unsigned int item_num = uinfo->value.enumerated.item;
601 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
602
603 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200604 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100605 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
606
607 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
608 item_num = alc_pin_mode_min(dir);
609 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200610 return 0;
611}
612
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200613static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
614 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200615{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100616 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200617 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
618 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100619 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200620 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200621 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
622 AC_VERB_GET_PIN_WIDGET_CONTROL,
623 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200624
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100625 /* Find enumerated value for current pinctl setting */
626 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200627 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100628 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200629 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100630 return 0;
631}
632
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200633static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
634 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100635{
636 signed int change;
637 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
638 hda_nid_t nid = kcontrol->private_value & 0xffff;
639 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
640 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200641 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
642 AC_VERB_GET_PIN_WIDGET_CONTROL,
643 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100644
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200645 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100646 val = alc_pin_mode_min(dir);
647
648 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100649 if (change) {
650 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200651 snd_hda_codec_write_cache(codec, nid, 0,
652 AC_VERB_SET_PIN_WIDGET_CONTROL,
653 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100654
Kailang Yangea1fb292008-08-26 12:58:38 +0200655 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100656 * for the requested pin mode. Enum values of 2 or less are
657 * input modes.
658 *
659 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200660 * reduces noise slightly (particularly on input) so we'll
661 * do it. However, having both input and output buffers
662 * enabled simultaneously doesn't seem to be problematic if
663 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100664 */
665 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200666 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
667 HDA_AMP_MUTE, HDA_AMP_MUTE);
668 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
669 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100670 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200671 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
672 HDA_AMP_MUTE, HDA_AMP_MUTE);
673 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
674 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100675 }
676 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200677 return change;
678}
679
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100680#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200681 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100682 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100683 .info = alc_pin_mode_info, \
684 .get = alc_pin_mode_get, \
685 .put = alc_pin_mode_put, \
686 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100687
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100688/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
689 * together using a mask with more than one bit set. This control is
690 * currently used only by the ALC260 test model. At this stage they are not
691 * needed for any "production" models.
692 */
693#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200694#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200695
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200696static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
697 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100698{
699 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
700 hda_nid_t nid = kcontrol->private_value & 0xffff;
701 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
702 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200703 unsigned int val = snd_hda_codec_read(codec, nid, 0,
704 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100705
706 *valp = (val & mask) != 0;
707 return 0;
708}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200709static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
710 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100711{
712 signed int change;
713 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
714 hda_nid_t nid = kcontrol->private_value & 0xffff;
715 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
716 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200717 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
718 AC_VERB_GET_GPIO_DATA,
719 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100720
721 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200722 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
723 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100724 gpio_data &= ~mask;
725 else
726 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200727 snd_hda_codec_write_cache(codec, nid, 0,
728 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100729
730 return change;
731}
732#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
733 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100734 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100735 .info = alc_gpio_data_info, \
736 .get = alc_gpio_data_get, \
737 .put = alc_gpio_data_put, \
738 .private_value = nid | (mask<<16) }
739#endif /* CONFIG_SND_DEBUG */
740
Jonathan Woithe92621f12006-02-28 11:47:47 +0100741/* A switch control to allow the enabling of the digital IO pins on the
742 * ALC260. This is incredibly simplistic; the intention of this control is
743 * to provide something in the test model allowing digital outputs to be
744 * identified if present. If models are found which can utilise these
745 * outputs a more complete mixer control can be devised for those models if
746 * necessary.
747 */
748#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200749#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200750
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200751static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
752 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100753{
754 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
755 hda_nid_t nid = kcontrol->private_value & 0xffff;
756 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
757 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200758 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100759 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100760
761 *valp = (val & mask) != 0;
762 return 0;
763}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200764static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
765 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100766{
767 signed int change;
768 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
769 hda_nid_t nid = kcontrol->private_value & 0xffff;
770 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
771 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200772 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100773 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200774 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100775
776 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200777 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100778 if (val==0)
779 ctrl_data &= ~mask;
780 else
781 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200782 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
783 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100784
785 return change;
786}
787#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
788 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100789 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100790 .info = alc_spdif_ctrl_info, \
791 .get = alc_spdif_ctrl_get, \
792 .put = alc_spdif_ctrl_put, \
793 .private_value = nid | (mask<<16) }
794#endif /* CONFIG_SND_DEBUG */
795
Jonathan Woithef8225f62008-01-08 12:16:54 +0100796/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
797 * Again, this is only used in the ALC26x test models to help identify when
798 * the EAPD line must be asserted for features to work.
799 */
800#ifdef CONFIG_SND_DEBUG
801#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
802
803static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
804 struct snd_ctl_elem_value *ucontrol)
805{
806 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
807 hda_nid_t nid = kcontrol->private_value & 0xffff;
808 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
809 long *valp = ucontrol->value.integer.value;
810 unsigned int val = snd_hda_codec_read(codec, nid, 0,
811 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
812
813 *valp = (val & mask) != 0;
814 return 0;
815}
816
817static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
818 struct snd_ctl_elem_value *ucontrol)
819{
820 int change;
821 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
822 hda_nid_t nid = kcontrol->private_value & 0xffff;
823 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
824 long val = *ucontrol->value.integer.value;
825 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
826 AC_VERB_GET_EAPD_BTLENABLE,
827 0x00);
828
829 /* Set/unset the masked control bit(s) as needed */
830 change = (!val ? 0 : mask) != (ctrl_data & mask);
831 if (!val)
832 ctrl_data &= ~mask;
833 else
834 ctrl_data |= mask;
835 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
836 ctrl_data);
837
838 return change;
839}
840
841#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
842 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100843 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100844 .info = alc_eapd_ctrl_info, \
845 .get = alc_eapd_ctrl_get, \
846 .put = alc_eapd_ctrl_put, \
847 .private_value = nid | (mask<<16) }
848#endif /* CONFIG_SND_DEBUG */
849
Kailang Yangdf694da2005-12-05 19:42:22 +0100850/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100851 * set up the input pin config (depending on the given auto-pin type)
852 */
853static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
854 int auto_pin_type)
855{
856 unsigned int val = PIN_IN;
857
Takashi Iwai86e29592010-09-09 14:50:17 +0200858 if (auto_pin_type == AUTO_PIN_MIC) {
Takashi Iwai23f0c042009-02-26 13:03:58 +0100859 unsigned int pincap;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200860 unsigned int oldval;
861 oldval = snd_hda_codec_read(codec, nid, 0,
862 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Takashi Iwai1327a322009-03-23 13:07:47 +0100863 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100864 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200865 /* if the default pin setup is vref50, we give it priority */
866 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
Takashi Iwai23f0c042009-02-26 13:03:58 +0100867 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200868 else if (pincap & AC_PINCAP_VREF_50)
869 val = PIN_VREF50;
870 else if (pincap & AC_PINCAP_VREF_100)
871 val = PIN_VREF100;
872 else if (pincap & AC_PINCAP_VREF_GRD)
873 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100874 }
875 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
876}
877
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200878static void alc_fixup_autocfg_pin_nums(struct hda_codec *codec)
879{
880 struct alc_spec *spec = codec->spec;
881 struct auto_pin_cfg *cfg = &spec->autocfg;
882
883 if (!cfg->line_outs) {
884 while (cfg->line_outs < AUTO_CFG_MAX_OUTS &&
885 cfg->line_out_pins[cfg->line_outs])
886 cfg->line_outs++;
887 }
888 if (!cfg->speaker_outs) {
889 while (cfg->speaker_outs < AUTO_CFG_MAX_OUTS &&
890 cfg->speaker_pins[cfg->speaker_outs])
891 cfg->speaker_outs++;
892 }
893 if (!cfg->hp_outs) {
894 while (cfg->hp_outs < AUTO_CFG_MAX_OUTS &&
895 cfg->hp_pins[cfg->hp_outs])
896 cfg->hp_outs++;
897 }
898}
899
Takashi Iwai23f0c042009-02-26 13:03:58 +0100900/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100901 */
902static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
903{
904 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
905 return;
906 spec->mixers[spec->num_mixers++] = mix;
907}
908
909static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
910{
911 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
912 return;
913 spec->init_verbs[spec->num_init_verbs++] = verb;
914}
915
916/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100917 * set up from the preset table
918 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200919static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200920 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100921{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200922 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100923 int i;
924
925 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100926 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100927 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200928 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
929 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100930 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200931
Kailang Yangdf694da2005-12-05 19:42:22 +0100932 spec->channel_mode = preset->channel_mode;
933 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200934 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200935 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100936
Hector Martin3b315d72009-06-02 10:54:19 +0200937 if (preset->const_channel_count)
938 spec->multiout.max_channels = preset->const_channel_count;
939 else
940 spec->multiout.max_channels = spec->channel_mode[0].channels;
941 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100942
943 spec->multiout.num_dacs = preset->num_dacs;
944 spec->multiout.dac_nids = preset->dac_nids;
945 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800946 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100947 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200948
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200949 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200950 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200951 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100952 spec->input_mux = preset->input_mux;
953
954 spec->num_adc_nids = preset->num_adc_nids;
955 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100956 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100957 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100958
959 spec->unsol_event = preset->unsol_event;
960 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200961#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100962 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200963 spec->loopback.amplist = preset->loopbacks;
964#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200965
966 if (preset->setup)
967 preset->setup(codec);
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200968
969 alc_fixup_autocfg_pin_nums(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100970}
971
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200972/* Enable GPIO mask and set output */
973static struct hda_verb alc_gpio1_init_verbs[] = {
974 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
975 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
976 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
977 { }
978};
979
980static struct hda_verb alc_gpio2_init_verbs[] = {
981 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
982 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
983 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
984 { }
985};
986
Kailang Yangbdd148a2007-05-08 15:19:08 +0200987static struct hda_verb alc_gpio3_init_verbs[] = {
988 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
989 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
990 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
991 { }
992};
993
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200994/*
995 * Fix hardware PLL issue
996 * On some codecs, the analog PLL gating control must be off while
997 * the default value is 1.
998 */
999static void alc_fix_pll(struct hda_codec *codec)
1000{
1001 struct alc_spec *spec = codec->spec;
1002 unsigned int val;
1003
1004 if (!spec->pll_nid)
1005 return;
1006 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1007 spec->pll_coef_idx);
1008 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
1009 AC_VERB_GET_PROC_COEF, 0);
1010 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1011 spec->pll_coef_idx);
1012 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
1013 val & ~(1 << spec->pll_coef_bit));
1014}
1015
1016static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
1017 unsigned int coef_idx, unsigned int coef_bit)
1018{
1019 struct alc_spec *spec = codec->spec;
1020 spec->pll_nid = nid;
1021 spec->pll_coef_idx = coef_idx;
1022 spec->pll_coef_bit = coef_bit;
1023 alc_fix_pll(codec);
1024}
1025
Kailang Yang9ad0e492010-09-14 23:22:00 +02001026static int alc_init_jacks(struct hda_codec *codec)
1027{
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001028#ifdef CONFIG_SND_HDA_INPUT_JACK
Kailang Yang9ad0e492010-09-14 23:22:00 +02001029 struct alc_spec *spec = codec->spec;
1030 int err;
1031 unsigned int hp_nid = spec->autocfg.hp_pins[0];
1032 unsigned int mic_nid = spec->ext_mic.pin;
1033
Takashi Iwai265a0242010-09-21 11:26:21 +02001034 if (hp_nid) {
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001035 err = snd_hda_input_jack_add(codec, hp_nid,
1036 SND_JACK_HEADPHONE, NULL);
Takashi Iwai265a0242010-09-21 11:26:21 +02001037 if (err < 0)
1038 return err;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001039 snd_hda_input_jack_report(codec, hp_nid);
Takashi Iwai265a0242010-09-21 11:26:21 +02001040 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001041
Takashi Iwai265a0242010-09-21 11:26:21 +02001042 if (mic_nid) {
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001043 err = snd_hda_input_jack_add(codec, mic_nid,
1044 SND_JACK_MICROPHONE, NULL);
Takashi Iwai265a0242010-09-21 11:26:21 +02001045 if (err < 0)
1046 return err;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001047 snd_hda_input_jack_report(codec, mic_nid);
Takashi Iwai265a0242010-09-21 11:26:21 +02001048 }
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001049#endif /* CONFIG_SND_HDA_INPUT_JACK */
Kailang Yang9ad0e492010-09-14 23:22:00 +02001050 return 0;
1051}
Kailang Yang9ad0e492010-09-14 23:22:00 +02001052
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001053static void alc_automute_speaker(struct hda_codec *codec, int pinctl)
Kailang Yangc9b58002007-10-16 14:30:01 +02001054{
1055 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001056 unsigned int mute;
1057 hda_nid_t nid;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001058 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +02001059
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001060 spec->jack_present = 0;
1061 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1062 nid = spec->autocfg.hp_pins[i];
1063 if (!nid)
1064 break;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001065 snd_hda_input_jack_report(codec, nid);
David Henningssonf0ce2792011-02-28 15:58:07 +01001066 spec->jack_present |= snd_hda_jack_detect(codec, nid);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001067 }
1068
1069 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1070 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001071 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1072 nid = spec->autocfg.speaker_pins[i];
1073 if (!nid)
1074 break;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001075 if (pinctl) {
1076 snd_hda_codec_write(codec, nid, 0,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001077 AC_VERB_SET_PIN_WIDGET_CONTROL,
1078 spec->jack_present ? 0 : PIN_OUT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001079 } else {
1080 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1081 HDA_AMP_MUTE, mute);
1082 }
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001083 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001084}
1085
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001086static void alc_automute_pin(struct hda_codec *codec)
1087{
1088 alc_automute_speaker(codec, 1);
1089}
1090
Takashi Iwai6c819492009-08-10 18:47:44 +02001091static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1092 hda_nid_t nid)
1093{
1094 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1095 int i, nums;
1096
1097 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1098 for (i = 0; i < nums; i++)
1099 if (conn[i] == nid)
1100 return i;
1101 return -1;
1102}
1103
Takashi Iwai840b64c2010-07-13 22:49:01 +02001104/* switch the current ADC according to the jack state */
1105static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1106{
1107 struct alc_spec *spec = codec->spec;
1108 unsigned int present;
1109 hda_nid_t new_adc;
1110
1111 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1112 if (present)
1113 spec->cur_adc_idx = 1;
1114 else
1115 spec->cur_adc_idx = 0;
1116 new_adc = spec->adc_nids[spec->cur_adc_idx];
1117 if (spec->cur_adc && spec->cur_adc != new_adc) {
1118 /* stream is running, let's swap the current ADC */
Takashi Iwaif0cea792010-08-13 11:56:53 +02001119 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
Takashi Iwai840b64c2010-07-13 22:49:01 +02001120 spec->cur_adc = new_adc;
1121 snd_hda_codec_setup_stream(codec, new_adc,
1122 spec->cur_adc_stream_tag, 0,
1123 spec->cur_adc_format);
1124 }
1125}
1126
Kailang Yang7fb0d782008-10-15 11:12:35 +02001127static void alc_mic_automute(struct hda_codec *codec)
1128{
1129 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001130 struct alc_mic_route *dead, *alive;
1131 unsigned int present, type;
1132 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001133
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001134 if (!spec->auto_mic)
1135 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001136 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1137 return;
1138 if (snd_BUG_ON(!spec->adc_nids))
1139 return;
1140
Takashi Iwai840b64c2010-07-13 22:49:01 +02001141 if (spec->dual_adc_switch) {
1142 alc_dual_mic_adc_auto_switch(codec);
1143 return;
1144 }
1145
Takashi Iwai6c819492009-08-10 18:47:44 +02001146 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1147
Wu Fengguang864f92b2009-11-18 12:38:02 +08001148 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001149 if (present) {
1150 alive = &spec->ext_mic;
1151 dead = &spec->int_mic;
1152 } else {
1153 alive = &spec->int_mic;
1154 dead = &spec->ext_mic;
1155 }
1156
Takashi Iwai6c819492009-08-10 18:47:44 +02001157 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1158 if (type == AC_WID_AUD_MIX) {
1159 /* Matrix-mixer style (e.g. ALC882) */
1160 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1161 alive->mux_idx,
1162 HDA_AMP_MUTE, 0);
1163 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1164 dead->mux_idx,
1165 HDA_AMP_MUTE, HDA_AMP_MUTE);
1166 } else {
1167 /* MUX style (e.g. ALC880) */
1168 snd_hda_codec_write_cache(codec, cap_nid, 0,
1169 AC_VERB_SET_CONNECT_SEL,
1170 alive->mux_idx);
1171 }
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001172 snd_hda_input_jack_report(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001173
1174 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001175}
1176
Kailang Yangc9b58002007-10-16 14:30:01 +02001177/* unsolicited event for HP jack sensing */
1178static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1179{
1180 if (codec->vendor_id == 0x10ec0880)
1181 res >>= 28;
1182 else
1183 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001184 switch (res) {
1185 case ALC880_HP_EVENT:
1186 alc_automute_pin(codec);
1187 break;
1188 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001189 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001190 break;
1191 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001192}
1193
1194static void alc_inithook(struct hda_codec *codec)
1195{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001196 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001197 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001198}
1199
Kailang Yangf9423e72008-05-27 12:32:25 +02001200/* additional initialization for ALC888 variants */
1201static void alc888_coef_init(struct hda_codec *codec)
1202{
1203 unsigned int tmp;
1204
1205 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1206 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1207 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001208 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001209 /* alc888S-VC */
1210 snd_hda_codec_read(codec, 0x20, 0,
1211 AC_VERB_SET_PROC_COEF, 0x830);
1212 else
1213 /* alc888-VB */
1214 snd_hda_codec_read(codec, 0x20, 0,
1215 AC_VERB_SET_PROC_COEF, 0x3030);
1216}
1217
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001218static void alc889_coef_init(struct hda_codec *codec)
1219{
1220 unsigned int tmp;
1221
1222 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1223 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1224 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1225 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1226}
1227
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001228/* turn on/off EAPD control (only if available) */
1229static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1230{
1231 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1232 return;
1233 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1234 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1235 on ? 2 : 0);
1236}
1237
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001238static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001239{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001240 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001241
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001242 switch (type) {
1243 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001244 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1245 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001246 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001247 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1248 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001249 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001250 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1251 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001252 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001253 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001254 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001255 set_eapd(codec, 0x0f, 1);
1256 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001257 break;
1258 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001259 case 0x10ec0267:
1260 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001261 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001262 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001263 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001264 case 0x10ec0660:
1265 case 0x10ec0662:
1266 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001267 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001268 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001269 set_eapd(codec, 0x14, 1);
1270 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001271 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001272 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001273 switch (codec->vendor_id) {
1274 case 0x10ec0260:
1275 snd_hda_codec_write(codec, 0x1a, 0,
1276 AC_VERB_SET_COEF_INDEX, 7);
1277 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1278 AC_VERB_GET_PROC_COEF, 0);
1279 snd_hda_codec_write(codec, 0x1a, 0,
1280 AC_VERB_SET_COEF_INDEX, 7);
1281 snd_hda_codec_write(codec, 0x1a, 0,
1282 AC_VERB_SET_PROC_COEF,
1283 tmp | 0x2010);
1284 break;
1285 case 0x10ec0262:
1286 case 0x10ec0880:
1287 case 0x10ec0882:
1288 case 0x10ec0883:
1289 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001290 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001291 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001292 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001293 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001294 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001295 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001296 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001297#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001298 case 0x10ec0267:
1299 case 0x10ec0268:
1300 snd_hda_codec_write(codec, 0x20, 0,
1301 AC_VERB_SET_COEF_INDEX, 7);
1302 tmp = snd_hda_codec_read(codec, 0x20, 0,
1303 AC_VERB_GET_PROC_COEF, 0);
1304 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001305 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001306 snd_hda_codec_write(codec, 0x20, 0,
1307 AC_VERB_SET_PROC_COEF,
1308 tmp | 0x3000);
1309 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001310#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001311 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001312 break;
1313 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001314}
Kailang Yangea1fb292008-08-26 12:58:38 +02001315
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001316static void alc_init_auto_hp(struct hda_codec *codec)
1317{
1318 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001319 struct auto_pin_cfg *cfg = &spec->autocfg;
1320 int i;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001321
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001322 if (!cfg->hp_pins[0]) {
1323 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001324 return;
1325 }
1326
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001327 if (!cfg->speaker_pins[0]) {
1328 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
1329 return;
1330 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1331 sizeof(cfg->speaker_pins));
1332 cfg->speaker_outs = cfg->line_outs;
1333 }
1334
1335 if (!cfg->hp_pins[0]) {
1336 memcpy(cfg->hp_pins, cfg->line_out_pins,
1337 sizeof(cfg->hp_pins));
1338 cfg->hp_outs = cfg->line_outs;
1339 }
1340
1341 for (i = 0; i < cfg->hp_outs; i++) {
1342 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1343 cfg->hp_pins[i]);
1344 snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0,
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001345 AC_VERB_SET_UNSOLICITED_ENABLE,
1346 AC_USRSP_EN | ALC880_HP_EVENT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001347 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001348 spec->unsol_event = alc_sku_unsol_event;
1349}
1350
Takashi Iwai6c819492009-08-10 18:47:44 +02001351static void alc_init_auto_mic(struct hda_codec *codec)
1352{
1353 struct alc_spec *spec = codec->spec;
1354 struct auto_pin_cfg *cfg = &spec->autocfg;
1355 hda_nid_t fixed, ext;
1356 int i;
1357
1358 /* there must be only two mic inputs exclusively */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001359 for (i = 0; i < cfg->num_inputs; i++)
Takashi Iwai86e29592010-09-09 14:50:17 +02001360 if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
Takashi Iwai6c819492009-08-10 18:47:44 +02001361 return;
1362
1363 fixed = ext = 0;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001364 for (i = 0; i < cfg->num_inputs; i++) {
1365 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai6c819492009-08-10 18:47:44 +02001366 unsigned int defcfg;
Takashi Iwai6c819492009-08-10 18:47:44 +02001367 defcfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001368 switch (snd_hda_get_input_pin_attr(defcfg)) {
1369 case INPUT_PIN_ATTR_INT:
Takashi Iwai6c819492009-08-10 18:47:44 +02001370 if (fixed)
1371 return; /* already occupied */
1372 fixed = nid;
1373 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001374 case INPUT_PIN_ATTR_UNUSED:
1375 return; /* invalid entry */
1376 default:
Takashi Iwai6c819492009-08-10 18:47:44 +02001377 if (ext)
1378 return; /* already occupied */
1379 ext = nid;
1380 break;
Takashi Iwai6c819492009-08-10 18:47:44 +02001381 }
1382 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001383 if (!ext || !fixed)
1384 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001385 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1386 return; /* no unsol support */
1387 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1388 ext, fixed);
1389 spec->ext_mic.pin = ext;
1390 spec->int_mic.pin = fixed;
1391 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1392 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1393 spec->auto_mic = 1;
1394 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1395 AC_VERB_SET_UNSOLICITED_ENABLE,
1396 AC_USRSP_EN | ALC880_MIC_EVENT);
1397 spec->unsol_event = alc_sku_unsol_event;
1398}
1399
David Henningsson90622912010-10-14 14:50:18 +02001400/* Could be any non-zero and even value. When used as fixup, tells
1401 * the driver to ignore any present sku defines.
1402 */
1403#define ALC_FIXUP_SKU_IGNORE (2)
1404
Kailang Yangda00c242010-03-19 11:23:45 +01001405static int alc_auto_parse_customize_define(struct hda_codec *codec)
1406{
1407 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001408 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001409 struct alc_spec *spec = codec->spec;
1410
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001411 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1412
David Henningsson90622912010-10-14 14:50:18 +02001413 if (spec->cdefine.fixup) {
1414 ass = spec->cdefine.sku_cfg;
1415 if (ass == ALC_FIXUP_SKU_IGNORE)
1416 return -1;
1417 goto do_sku;
1418 }
1419
Kailang Yangda00c242010-03-19 11:23:45 +01001420 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001421 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +01001422 goto do_sku;
1423
1424 nid = 0x1d;
1425 if (codec->vendor_id == 0x10ec0260)
1426 nid = 0x17;
1427 ass = snd_hda_codec_get_pincfg(codec, nid);
1428
1429 if (!(ass & 1)) {
1430 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1431 codec->chip_name, ass);
1432 return -1;
1433 }
1434
1435 /* check sum */
1436 tmp = 0;
1437 for (i = 1; i < 16; i++) {
1438 if ((ass >> i) & 1)
1439 tmp++;
1440 }
1441 if (((ass >> 16) & 0xf) != tmp)
1442 return -1;
1443
1444 spec->cdefine.port_connectivity = ass >> 30;
1445 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1446 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1447 spec->cdefine.customization = ass >> 8;
1448do_sku:
1449 spec->cdefine.sku_cfg = ass;
1450 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1451 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1452 spec->cdefine.swap = (ass & 0x2) >> 1;
1453 spec->cdefine.override = ass & 0x1;
1454
1455 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1456 nid, spec->cdefine.sku_cfg);
1457 snd_printd("SKU: port_connectivity=0x%x\n",
1458 spec->cdefine.port_connectivity);
1459 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1460 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1461 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1462 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1463 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1464 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1465 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1466
1467 return 0;
1468}
1469
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001470/* check subsystem ID and set up device-specific initialization;
1471 * return 1 if initialized, 0 if invalid SSID
1472 */
1473/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1474 * 31 ~ 16 : Manufacture ID
1475 * 15 ~ 8 : SKU ID
1476 * 7 ~ 0 : Assembly ID
1477 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1478 */
1479static int alc_subsystem_id(struct hda_codec *codec,
1480 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001481 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001482{
1483 unsigned int ass, tmp, i;
1484 unsigned nid;
1485 struct alc_spec *spec = codec->spec;
1486
David Henningsson90622912010-10-14 14:50:18 +02001487 if (spec->cdefine.fixup) {
1488 ass = spec->cdefine.sku_cfg;
1489 if (ass == ALC_FIXUP_SKU_IGNORE)
1490 return 0;
1491 goto do_sku;
1492 }
1493
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001494 ass = codec->subsystem_id & 0xffff;
1495 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1496 goto do_sku;
1497
1498 /* invalid SSID, check the special NID pin defcfg instead */
1499 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001500 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001501 * 29~21 : reserve
1502 * 20 : PCBEEP input
1503 * 19~16 : Check sum (15:1)
1504 * 15~1 : Custom
1505 * 0 : override
1506 */
1507 nid = 0x1d;
1508 if (codec->vendor_id == 0x10ec0260)
1509 nid = 0x17;
1510 ass = snd_hda_codec_get_pincfg(codec, nid);
1511 snd_printd("realtek: No valid SSID, "
1512 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001513 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001514 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001515 return 0;
1516 if ((ass >> 30) != 1) /* no physical connection */
1517 return 0;
1518
1519 /* check sum */
1520 tmp = 0;
1521 for (i = 1; i < 16; i++) {
1522 if ((ass >> i) & 1)
1523 tmp++;
1524 }
1525 if (((ass >> 16) & 0xf) != tmp)
1526 return 0;
1527do_sku:
1528 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1529 ass & 0xffff, codec->vendor_id);
1530 /*
1531 * 0 : override
1532 * 1 : Swap Jack
1533 * 2 : 0 --> Desktop, 1 --> Laptop
1534 * 3~5 : External Amplifier control
1535 * 7~6 : Reserved
1536 */
1537 tmp = (ass & 0x38) >> 3; /* external Amp control */
1538 switch (tmp) {
1539 case 1:
1540 spec->init_amp = ALC_INIT_GPIO1;
1541 break;
1542 case 3:
1543 spec->init_amp = ALC_INIT_GPIO2;
1544 break;
1545 case 7:
1546 spec->init_amp = ALC_INIT_GPIO3;
1547 break;
1548 case 5:
Takashi Iwai5a8cfb42010-11-26 17:11:18 +01001549 default:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001550 spec->init_amp = ALC_INIT_DEFAULT;
1551 break;
1552 }
1553
1554 /* is laptop or Desktop and enable the function "Mute internal speaker
1555 * when the external headphone out jack is plugged"
1556 */
1557 if (!(ass & 0x8000))
1558 return 1;
1559 /*
1560 * 10~8 : Jack location
1561 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1562 * 14~13: Resvered
1563 * 15 : 1 --> enable the function "Mute internal speaker
1564 * when the external headphone out jack is plugged"
1565 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001566 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001567 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001568 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1569 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001570 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001571 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001572 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001573 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001574 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001575 else if (tmp == 3)
1576 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001577 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001578 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001579 for (i = 0; i < spec->autocfg.line_outs; i++)
1580 if (spec->autocfg.line_out_pins[i] == nid)
1581 return 1;
1582 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001583 }
1584
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001585 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001586 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001587 return 1;
1588}
Kailang Yangea1fb292008-08-26 12:58:38 +02001589
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001590static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001591 hda_nid_t porta, hda_nid_t porte,
1592 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001593{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001594 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001595 struct alc_spec *spec = codec->spec;
1596 snd_printd("realtek: "
1597 "Enable default setup for auto mode as fallback\n");
1598 spec->init_amp = ALC_INIT_DEFAULT;
1599 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001600 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001601 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001602}
1603
Takashi Iwai41e41f12005-06-08 14:48:49 +02001604/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001605 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001606 */
1607
1608struct alc_pincfg {
1609 hda_nid_t nid;
1610 u32 val;
1611};
1612
Todd Broche1eb5f12010-12-06 11:19:51 -08001613struct alc_model_fixup {
1614 const int id;
1615 const char *name;
1616};
1617
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001618struct alc_fixup {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001619 int type;
Takashi Iwai361fe6e2011-01-14 09:55:32 +01001620 bool chained;
1621 int chain_id;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001622 union {
1623 unsigned int sku;
1624 const struct alc_pincfg *pins;
1625 const struct hda_verb *verbs;
1626 void (*func)(struct hda_codec *codec,
1627 const struct alc_fixup *fix,
1628 int action);
1629 } v;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001630};
1631
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001632enum {
1633 ALC_FIXUP_INVALID,
1634 ALC_FIXUP_SKU,
1635 ALC_FIXUP_PINS,
1636 ALC_FIXUP_VERBS,
1637 ALC_FIXUP_FUNC,
1638};
Takashi Iwaif95474e2007-07-10 00:47:43 +02001639
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001640enum {
1641 ALC_FIXUP_ACT_PRE_PROBE,
1642 ALC_FIXUP_ACT_PROBE,
Takashi Iwai58701122011-01-13 15:41:45 +01001643 ALC_FIXUP_ACT_INIT,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001644};
1645
1646static void alc_apply_fixup(struct hda_codec *codec, int action)
1647{
1648 struct alc_spec *spec = codec->spec;
1649 int id = spec->fixup_id;
Takashi Iwaiaa1d0c52011-01-19 17:27:58 +01001650#ifdef CONFIG_SND_DEBUG_VERBOSE
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001651 const char *modelname = spec->fixup_name;
Takashi Iwaiaa1d0c52011-01-19 17:27:58 +01001652#endif
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001653 int depth = 0;
1654
1655 if (!spec->fixup_list)
1656 return;
1657
1658 while (id >= 0) {
1659 const struct alc_fixup *fix = spec->fixup_list + id;
1660 const struct alc_pincfg *cfg;
1661
1662 switch (fix->type) {
1663 case ALC_FIXUP_SKU:
1664 if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku)
1665 break;;
1666 snd_printdd(KERN_INFO "hda_codec: %s: "
1667 "Apply sku override for %s\n",
1668 codec->chip_name, modelname);
1669 spec->cdefine.sku_cfg = fix->v.sku;
1670 spec->cdefine.fixup = 1;
1671 break;
1672 case ALC_FIXUP_PINS:
1673 cfg = fix->v.pins;
1674 if (action != ALC_FIXUP_ACT_PRE_PROBE || !cfg)
1675 break;
1676 snd_printdd(KERN_INFO "hda_codec: %s: "
1677 "Apply pincfg for %s\n",
1678 codec->chip_name, modelname);
1679 for (; cfg->nid; cfg++)
1680 snd_hda_codec_set_pincfg(codec, cfg->nid,
1681 cfg->val);
1682 break;
1683 case ALC_FIXUP_VERBS:
1684 if (action != ALC_FIXUP_ACT_PROBE || !fix->v.verbs)
1685 break;
1686 snd_printdd(KERN_INFO "hda_codec: %s: "
1687 "Apply fix-verbs for %s\n",
1688 codec->chip_name, modelname);
1689 add_verb(codec->spec, fix->v.verbs);
1690 break;
1691 case ALC_FIXUP_FUNC:
1692 if (!fix->v.func)
1693 break;
1694 snd_printdd(KERN_INFO "hda_codec: %s: "
1695 "Apply fix-func for %s\n",
1696 codec->chip_name, modelname);
1697 fix->v.func(codec, fix, action);
1698 break;
1699 default:
1700 snd_printk(KERN_ERR "hda_codec: %s: "
1701 "Invalid fixup type %d\n",
1702 codec->chip_name, fix->type);
1703 break;
1704 }
1705 if (!fix[id].chained)
1706 break;
1707 if (++depth > 10)
1708 break;
1709 id = fix[id].chain_id;
Takashi Iwai9d578832010-11-22 13:29:19 +01001710 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001711}
1712
Todd Broche1eb5f12010-12-06 11:19:51 -08001713static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001714 const struct alc_model_fixup *models,
1715 const struct snd_pci_quirk *quirk,
1716 const struct alc_fixup *fixlist)
Todd Broche1eb5f12010-12-06 11:19:51 -08001717{
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001718 struct alc_spec *spec = codec->spec;
1719 int id = -1;
1720 const char *name = NULL;
Todd Broche1eb5f12010-12-06 11:19:51 -08001721
Todd Broche1eb5f12010-12-06 11:19:51 -08001722 if (codec->modelname && models) {
1723 while (models->name) {
1724 if (!strcmp(codec->modelname, models->name)) {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001725 id = models->id;
1726 name = models->name;
Todd Broche1eb5f12010-12-06 11:19:51 -08001727 break;
1728 }
1729 models++;
1730 }
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001731 }
1732 if (id < 0) {
1733 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1734 if (quirk) {
1735 id = quirk->value;
1736#ifdef CONFIG_SND_DEBUG_VERBOSE
1737 name = quirk->name;
1738#endif
1739 }
1740 }
1741
1742 spec->fixup_id = id;
1743 if (id >= 0) {
1744 spec->fixup_list = fixlist;
1745 spec->fixup_name = name;
Todd Broche1eb5f12010-12-06 11:19:51 -08001746 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001747}
1748
Kailang Yang274693f2009-12-03 10:07:50 +01001749static int alc_read_coef_idx(struct hda_codec *codec,
1750 unsigned int coef_idx)
1751{
1752 unsigned int val;
1753 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1754 coef_idx);
1755 val = snd_hda_codec_read(codec, 0x20, 0,
1756 AC_VERB_GET_PROC_COEF, 0);
1757 return val;
1758}
1759
Kailang Yang977ddd62010-09-15 10:02:29 +02001760static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1761 unsigned int coef_val)
1762{
1763 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1764 coef_idx);
1765 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1766 coef_val);
1767}
1768
Takashi Iwai757899a2010-07-30 10:48:14 +02001769/* set right pin controls for digital I/O */
1770static void alc_auto_init_digital(struct hda_codec *codec)
1771{
1772 struct alc_spec *spec = codec->spec;
1773 int i;
1774 hda_nid_t pin;
1775
1776 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1777 pin = spec->autocfg.dig_out_pins[i];
1778 if (pin) {
1779 snd_hda_codec_write(codec, pin, 0,
1780 AC_VERB_SET_PIN_WIDGET_CONTROL,
1781 PIN_OUT);
1782 }
1783 }
1784 pin = spec->autocfg.dig_in_pin;
1785 if (pin)
1786 snd_hda_codec_write(codec, pin, 0,
1787 AC_VERB_SET_PIN_WIDGET_CONTROL,
1788 PIN_IN);
1789}
1790
1791/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1792static void alc_auto_parse_digital(struct hda_codec *codec)
1793{
1794 struct alc_spec *spec = codec->spec;
1795 int i, err;
1796 hda_nid_t dig_nid;
1797
1798 /* support multiple SPDIFs; the secondary is set up as a slave */
1799 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1800 err = snd_hda_get_connections(codec,
1801 spec->autocfg.dig_out_pins[i],
1802 &dig_nid, 1);
1803 if (err < 0)
1804 continue;
1805 if (!i) {
1806 spec->multiout.dig_out_nid = dig_nid;
1807 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1808 } else {
1809 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1810 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1811 break;
1812 spec->slave_dig_outs[i - 1] = dig_nid;
1813 }
1814 }
1815
1816 if (spec->autocfg.dig_in_pin) {
Takashi Iwai01fdf182010-09-24 09:09:42 +02001817 dig_nid = codec->start_nid;
1818 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
1819 unsigned int wcaps = get_wcaps(codec, dig_nid);
1820 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
1821 continue;
1822 if (!(wcaps & AC_WCAP_DIGITAL))
1823 continue;
1824 if (!(wcaps & AC_WCAP_CONN_LIST))
1825 continue;
1826 err = get_connection_index(codec, dig_nid,
1827 spec->autocfg.dig_in_pin);
1828 if (err >= 0) {
1829 spec->dig_in_nid = dig_nid;
1830 break;
1831 }
1832 }
Takashi Iwai757899a2010-07-30 10:48:14 +02001833 }
1834}
1835
Takashi Iwaif95474e2007-07-10 00:47:43 +02001836/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001837 * ALC888
1838 */
1839
1840/*
1841 * 2ch mode
1842 */
1843static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1844/* Mic-in jack as mic in */
1845 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1846 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1847/* Line-in jack as Line in */
1848 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1849 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1850/* Line-Out as Front */
1851 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1852 { } /* end */
1853};
1854
1855/*
1856 * 4ch mode
1857 */
1858static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1859/* Mic-in jack as mic in */
1860 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1861 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1862/* Line-in jack as Surround */
1863 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1864 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1865/* Line-Out as Front */
1866 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1867 { } /* end */
1868};
1869
1870/*
1871 * 6ch mode
1872 */
1873static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1874/* Mic-in jack as CLFE */
1875 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1876 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1877/* Line-in jack as Surround */
1878 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1879 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1880/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1881 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1882 { } /* end */
1883};
1884
1885/*
1886 * 8ch mode
1887 */
1888static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1889/* Mic-in jack as CLFE */
1890 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1891 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1892/* Line-in jack as Surround */
1893 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1894 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1895/* Line-Out as Side */
1896 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1897 { } /* end */
1898};
1899
1900static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1901 { 2, alc888_4ST_ch2_intel_init },
1902 { 4, alc888_4ST_ch4_intel_init },
1903 { 6, alc888_4ST_ch6_intel_init },
1904 { 8, alc888_4ST_ch8_intel_init },
1905};
1906
1907/*
1908 * ALC888 Fujitsu Siemens Amillo xa3530
1909 */
1910
1911static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1912/* Front Mic: set to PIN_IN (empty by default) */
1913 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1914/* Connect Internal HP to Front */
1915 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1916 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1917 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1918/* Connect Bass HP to Front */
1919 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1920 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1921 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1922/* Connect Line-Out side jack (SPDIF) to Side */
1923 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1924 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1925 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1926/* Connect Mic jack to CLFE */
1927 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1928 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1929 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1930/* Connect Line-in jack to Surround */
1931 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1932 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1933 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1934/* Connect HP out jack to Front */
1935 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1936 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1937 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1938/* Enable unsolicited event for HP jack and Line-out jack */
1939 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1940 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1941 {}
1942};
1943
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001944static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001945{
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001946 alc_automute_speaker(codec, 0);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001947}
1948
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001949static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1950 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001951{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001952 if (codec->vendor_id == 0x10ec0880)
1953 res >>= 28;
1954 else
1955 res >>= 26;
1956 if (res == ALC880_HP_EVENT)
1957 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001958}
1959
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001960static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001961{
1962 struct alc_spec *spec = codec->spec;
1963
1964 spec->autocfg.hp_pins[0] = 0x15;
1965 spec->autocfg.speaker_pins[0] = 0x14;
1966 spec->autocfg.speaker_pins[1] = 0x16;
1967 spec->autocfg.speaker_pins[2] = 0x17;
1968 spec->autocfg.speaker_pins[3] = 0x19;
1969 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001970}
1971
1972static void alc889_intel_init_hook(struct hda_codec *codec)
1973{
1974 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001975 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001976}
1977
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001978static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001979{
1980 struct alc_spec *spec = codec->spec;
1981
1982 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1983 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1984 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1985 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001986}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001987
1988/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001989 * ALC888 Acer Aspire 4930G model
1990 */
1991
1992static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1993/* Front Mic: set to PIN_IN (empty by default) */
1994 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1995/* Unselect Front Mic by default in input mixer 3 */
1996 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001997/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001998 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1999/* Connect Internal HP to front */
2000 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2001 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2002 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2003/* Connect HP out to front */
2004 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2005 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2006 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie2e93292011-01-12 08:03:39 +01002007 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002008 { }
2009};
2010
Hector Martin3b315d72009-06-02 10:54:19 +02002011/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01002012 * ALC888 Acer Aspire 6530G model
2013 */
2014
2015static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01002016/* Route to built-in subwoofer as well as speakers */
2017 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2018 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2019 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2020 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002021/* Bias voltage on for external mic port */
2022 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02002023/* Front Mic: set to PIN_IN (empty by default) */
2024 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2025/* Unselect Front Mic by default in input mixer 3 */
2026 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002027/* Enable unsolicited event for HP jack */
2028 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2029/* Enable speaker output */
2030 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2031 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01002032 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002033/* Enable headphone output */
2034 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2035 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2036 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01002037 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002038 { }
2039};
2040
2041/*
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002042 *ALC888 Acer Aspire 7730G model
2043 */
2044
2045static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
2046/* Bias voltage on for external mic port */
2047 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
2048/* Front Mic: set to PIN_IN (empty by default) */
2049 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2050/* Unselect Front Mic by default in input mixer 3 */
2051 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2052/* Enable unsolicited event for HP jack */
2053 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2054/* Enable speaker output */
2055 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2056 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2057 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
2058/* Enable headphone output */
2059 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2060 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2061 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2062 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
2063/*Enable internal subwoofer */
2064 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2065 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2066 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
2067 {0x17, AC_VERB_SET_EAPD_BTLENABLE, 2},
2068 { }
2069};
2070
2071/*
Hector Martin018df412009-06-04 00:13:40 +02002072 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02002073 */
2074
Hector Martin018df412009-06-04 00:13:40 +02002075static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02002076/* Front Mic: set to PIN_IN (empty by default) */
2077 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2078/* Unselect Front Mic by default in input mixer 3 */
2079 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2080/* Enable unsolicited event for HP jack */
2081 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2082/* Connect Internal Front to Front */
2083 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2084 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2085 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2086/* Connect Internal Rear to Rear */
2087 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2088 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2089 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
2090/* Connect Internal CLFE to CLFE */
2091 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2092 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2093 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
2094/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02002095 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02002096 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2097 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2098/* Enable all DACs */
2099/* DAC DISABLE/MUTE 1? */
2100/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
2101 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
2102 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2103/* DAC DISABLE/MUTE 2? */
2104/* some bit here disables the other DACs. Init=0x4900 */
2105 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
2106 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02002107/* DMIC fix
2108 * This laptop has a stereo digital microphone. The mics are only 1cm apart
2109 * which makes the stereo useless. However, either the mic or the ALC889
2110 * makes the signal become a difference/sum signal instead of standard
2111 * stereo, which is annoying. So instead we flip this bit which makes the
2112 * codec replicate the sum signal to both channels, turning it into a
2113 * normal mono mic.
2114 */
2115/* DMIC_CONTROL? Init value = 0x0001 */
2116 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
2117 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02002118 { }
2119};
2120
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002121static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002122 /* Front mic only available on one ADC */
2123 {
2124 .num_items = 4,
2125 .items = {
2126 { "Mic", 0x0 },
2127 { "Line", 0x2 },
2128 { "CD", 0x4 },
2129 { "Front Mic", 0xb },
2130 },
2131 },
2132 {
2133 .num_items = 3,
2134 .items = {
2135 { "Mic", 0x0 },
2136 { "Line", 0x2 },
2137 { "CD", 0x4 },
2138 },
2139 }
2140};
2141
Tony Vroond2fd4b02009-06-21 00:40:10 +01002142static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2143 /* Interal mic only available on one ADC */
2144 {
Tony Vroon684a8842009-06-26 09:27:50 +01002145 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002146 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +01002147 { "Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002148 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002149 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002150 { "Input Mix", 0xa },
David Henningsson28c4edb2010-12-20 14:24:29 +01002151 { "Internal Mic", 0xb },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002152 },
2153 },
2154 {
Tony Vroon684a8842009-06-26 09:27:50 +01002155 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002156 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +01002157 { "Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002158 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002159 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002160 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002161 },
2162 }
2163};
2164
Hector Martin018df412009-06-04 00:13:40 +02002165static struct hda_input_mux alc889_capture_sources[3] = {
2166 /* Digital mic only available on first "ADC" */
2167 {
2168 .num_items = 5,
2169 .items = {
2170 { "Mic", 0x0 },
2171 { "Line", 0x2 },
2172 { "CD", 0x4 },
2173 { "Front Mic", 0xb },
2174 { "Input Mix", 0xa },
2175 },
2176 },
2177 {
2178 .num_items = 4,
2179 .items = {
2180 { "Mic", 0x0 },
2181 { "Line", 0x2 },
2182 { "CD", 0x4 },
2183 { "Input Mix", 0xa },
2184 },
2185 },
2186 {
2187 .num_items = 4,
2188 .items = {
2189 { "Mic", 0x0 },
2190 { "Line", 0x2 },
2191 { "CD", 0x4 },
2192 { "Input Mix", 0xa },
2193 },
2194 }
2195};
2196
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002197static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002198 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2199 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2200 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2201 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2202 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2203 HDA_OUTPUT),
2204 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2205 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2206 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2207 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2208 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2209 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2210 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2211 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2212 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2213 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01002214 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002215 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002216 { } /* end */
2217};
2218
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002219static struct snd_kcontrol_new alc888_acer_aspire_4930g_mixer[] = {
2220 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2221 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2222 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2223 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Łukasz Wojniłowicz786c51f2011-02-24 10:03:31 +01002224 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002225 HDA_OUTPUT),
Łukasz Wojniłowicz786c51f2011-02-24 10:03:31 +01002226 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2227 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2228 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2229 HDA_CODEC_VOLUME_MONO("Internal LFE Playback Volume", 0x0f, 1, 0x0, HDA_OUTPUT),
2230 HDA_BIND_MUTE_MONO("Internal LFE Playback Switch", 0x0f, 1, 2, HDA_INPUT),
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002231 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2232 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2233 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2234 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2235 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2236 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
2237 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2238 { } /* end */
2239};
2240
Hector Martin556eea92009-12-20 22:51:23 +01002241static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2242 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2243 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2244 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2245 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2246 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2247 HDA_OUTPUT),
2248 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2249 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2250 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2251 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2252 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2253 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01002254 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hector Martin556eea92009-12-20 22:51:23 +01002255 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2256 { } /* end */
2257};
2258
2259
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002260static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002261{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002262 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002263
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002264 spec->autocfg.hp_pins[0] = 0x15;
2265 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01002266 spec->autocfg.speaker_pins[1] = 0x16;
2267 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002268}
2269
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002270static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02002271{
2272 struct alc_spec *spec = codec->spec;
2273
2274 spec->autocfg.hp_pins[0] = 0x15;
2275 spec->autocfg.speaker_pins[0] = 0x14;
2276 spec->autocfg.speaker_pins[1] = 0x16;
2277 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02002278}
2279
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002280static void alc888_acer_aspire_7730g_setup(struct hda_codec *codec)
2281{
2282 struct alc_spec *spec = codec->spec;
2283
2284 spec->autocfg.hp_pins[0] = 0x15;
2285 spec->autocfg.speaker_pins[0] = 0x14;
2286 spec->autocfg.speaker_pins[1] = 0x16;
2287 spec->autocfg.speaker_pins[2] = 0x17;
2288}
2289
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002290static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02002291{
2292 struct alc_spec *spec = codec->spec;
2293
2294 spec->autocfg.hp_pins[0] = 0x15;
2295 spec->autocfg.speaker_pins[0] = 0x14;
2296 spec->autocfg.speaker_pins[1] = 0x16;
2297 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02002298}
2299
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002300/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002301 * ALC880 3-stack model
2302 *
2303 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002304 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2305 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07002306 */
2307
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002308static hda_nid_t alc880_dac_nids[4] = {
2309 /* front, rear, clfe, rear_surr */
2310 0x02, 0x05, 0x04, 0x03
2311};
2312
2313static hda_nid_t alc880_adc_nids[3] = {
2314 /* ADC0-2 */
2315 0x07, 0x08, 0x09,
2316};
2317
2318/* The datasheet says the node 0x07 is connected from inputs,
2319 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01002320 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07002321 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002322static hda_nid_t alc880_adc_nids_alt[2] = {
2323 /* ADC1-2 */
2324 0x08, 0x09,
2325};
2326
2327#define ALC880_DIGOUT_NID 0x06
2328#define ALC880_DIGIN_NID 0x0a
2329
2330static struct hda_input_mux alc880_capture_source = {
2331 .num_items = 4,
2332 .items = {
2333 { "Mic", 0x0 },
2334 { "Front Mic", 0x3 },
2335 { "Line", 0x2 },
2336 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002337 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002338};
2339
2340/* channel source setting (2/6 channel selection for 3-stack) */
2341/* 2ch mode */
2342static struct hda_verb alc880_threestack_ch2_init[] = {
2343 /* set line-in to input, mute it */
2344 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2345 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2346 /* set mic-in to input vref 80%, mute it */
2347 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2348 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002349 { } /* end */
2350};
2351
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002352/* 6ch mode */
2353static struct hda_verb alc880_threestack_ch6_init[] = {
2354 /* set line-in to output, unmute it */
2355 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2356 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2357 /* set mic-in to output, unmute it */
2358 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2359 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2360 { } /* end */
2361};
2362
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002363static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002364 { 2, alc880_threestack_ch2_init },
2365 { 6, alc880_threestack_ch6_init },
2366};
2367
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002368static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002369 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002370 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002371 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002372 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002373 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2374 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002375 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2376 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002377 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2378 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2379 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2380 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2381 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2382 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2383 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2384 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002385 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002386 {
2387 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2388 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002389 .info = alc_ch_mode_info,
2390 .get = alc_ch_mode_get,
2391 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002392 },
2393 { } /* end */
2394};
2395
2396/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002397static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2398 struct snd_ctl_elem_info *uinfo)
2399{
2400 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2401 struct alc_spec *spec = codec->spec;
2402 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002403
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002404 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002405 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2406 HDA_INPUT);
2407 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002408 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002409 return err;
2410}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002411
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002412static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2413 unsigned int size, unsigned int __user *tlv)
2414{
2415 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2416 struct alc_spec *spec = codec->spec;
2417 int err;
2418
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002419 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002420 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2421 HDA_INPUT);
2422 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002423 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002424 return err;
2425}
2426
2427typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2428 struct snd_ctl_elem_value *ucontrol);
2429
2430static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2431 struct snd_ctl_elem_value *ucontrol,
2432 getput_call_t func)
2433{
2434 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2435 struct alc_spec *spec = codec->spec;
2436 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2437 int err;
2438
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002439 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002440 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2441 3, 0, HDA_INPUT);
2442 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002443 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002444 return err;
2445}
2446
2447static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2448 struct snd_ctl_elem_value *ucontrol)
2449{
2450 return alc_cap_getput_caller(kcontrol, ucontrol,
2451 snd_hda_mixer_amp_volume_get);
2452}
2453
2454static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2455 struct snd_ctl_elem_value *ucontrol)
2456{
2457 return alc_cap_getput_caller(kcontrol, ucontrol,
2458 snd_hda_mixer_amp_volume_put);
2459}
2460
2461/* capture mixer elements */
2462#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2463
2464static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2465 struct snd_ctl_elem_value *ucontrol)
2466{
2467 return alc_cap_getput_caller(kcontrol, ucontrol,
2468 snd_hda_mixer_amp_switch_get);
2469}
2470
2471static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2472 struct snd_ctl_elem_value *ucontrol)
2473{
2474 return alc_cap_getput_caller(kcontrol, ucontrol,
2475 snd_hda_mixer_amp_switch_put);
2476}
2477
Takashi Iwaia23b6882009-03-23 15:21:36 +01002478#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002479 { \
2480 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2481 .name = "Capture Switch", \
2482 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2483 .count = num, \
2484 .info = alc_cap_sw_info, \
2485 .get = alc_cap_sw_get, \
2486 .put = alc_cap_sw_put, \
2487 }, \
2488 { \
2489 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2490 .name = "Capture Volume", \
2491 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2492 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2493 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2494 .count = num, \
2495 .info = alc_cap_vol_info, \
2496 .get = alc_cap_vol_get, \
2497 .put = alc_cap_vol_put, \
2498 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002499 }
2500
2501#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002502 { \
2503 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2504 /* .name = "Capture Source", */ \
2505 .name = "Input Source", \
2506 .count = num, \
2507 .info = alc_mux_enum_info, \
2508 .get = alc_mux_enum_get, \
2509 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002510 }
2511
2512#define DEFINE_CAPMIX(num) \
2513static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2514 _DEFINE_CAPMIX(num), \
2515 _DEFINE_CAPSRC(num), \
2516 { } /* end */ \
2517}
2518
2519#define DEFINE_CAPMIX_NOSRC(num) \
2520static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2521 _DEFINE_CAPMIX(num), \
2522 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002523}
2524
2525/* up to three ADCs */
2526DEFINE_CAPMIX(1);
2527DEFINE_CAPMIX(2);
2528DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002529DEFINE_CAPMIX_NOSRC(1);
2530DEFINE_CAPMIX_NOSRC(2);
2531DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002532
2533/*
2534 * ALC880 5-stack model
2535 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002536 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2537 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002538 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2539 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2540 */
2541
2542/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002543static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002544 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002545 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002546 { } /* end */
2547};
2548
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002549/* channel source setting (6/8 channel selection for 5-stack) */
2550/* 6ch mode */
2551static struct hda_verb alc880_fivestack_ch6_init[] = {
2552 /* set line-in to input, mute it */
2553 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2554 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002555 { } /* end */
2556};
2557
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002558/* 8ch mode */
2559static struct hda_verb alc880_fivestack_ch8_init[] = {
2560 /* set line-in to output, unmute it */
2561 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2562 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2563 { } /* end */
2564};
2565
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002566static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002567 { 6, alc880_fivestack_ch6_init },
2568 { 8, alc880_fivestack_ch8_init },
2569};
2570
2571
2572/*
2573 * ALC880 6-stack model
2574 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002575 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2576 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002577 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2578 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2579 */
2580
2581static hda_nid_t alc880_6st_dac_nids[4] = {
2582 /* front, rear, clfe, rear_surr */
2583 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002584};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002585
2586static struct hda_input_mux alc880_6stack_capture_source = {
2587 .num_items = 4,
2588 .items = {
2589 { "Mic", 0x0 },
2590 { "Front Mic", 0x1 },
2591 { "Line", 0x2 },
2592 { "CD", 0x4 },
2593 },
2594};
2595
2596/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002597static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002598 { 8, NULL },
2599};
2600
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002601static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002602 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002603 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002604 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002605 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002606 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2607 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002608 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2609 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002610 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002611 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002612 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2613 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2614 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2615 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2616 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2617 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2618 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2619 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002620 {
2621 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2622 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002623 .info = alc_ch_mode_info,
2624 .get = alc_ch_mode_get,
2625 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002626 },
2627 { } /* end */
2628};
2629
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002630
2631/*
2632 * ALC880 W810 model
2633 *
2634 * W810 has rear IO for:
2635 * Front (DAC 02)
2636 * Surround (DAC 03)
2637 * Center/LFE (DAC 04)
2638 * Digital out (06)
2639 *
2640 * The system also has a pair of internal speakers, and a headphone jack.
2641 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002642 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002643 * There is a variable resistor to control the speaker or headphone
2644 * volume. This is a hardware-only device without a software API.
2645 *
2646 * Plugging headphones in will disable the internal speakers. This is
2647 * implemented in hardware, not via the driver using jack sense. In
2648 * a similar fashion, plugging into the rear socket marked "front" will
2649 * disable both the speakers and headphones.
2650 *
2651 * For input, there's a microphone jack, and an "audio in" jack.
2652 * These may not do anything useful with this driver yet, because I
2653 * haven't setup any initialization verbs for these yet...
2654 */
2655
2656static hda_nid_t alc880_w810_dac_nids[3] = {
2657 /* front, rear/surround, clfe */
2658 0x02, 0x03, 0x04
2659};
2660
2661/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002662static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002663 { 6, NULL }
2664};
2665
2666/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002667static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002668 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002669 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002670 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002671 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002672 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2673 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002674 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2675 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002676 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2677 { } /* end */
2678};
2679
2680
2681/*
2682 * Z710V model
2683 *
2684 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002685 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2686 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002687 */
2688
2689static hda_nid_t alc880_z71v_dac_nids[1] = {
2690 0x02
2691};
2692#define ALC880_Z71V_HP_DAC 0x03
2693
2694/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002695static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002696 { 2, NULL }
2697};
2698
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002699static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002700 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002701 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002702 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002703 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002704 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2705 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2706 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2707 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2708 { } /* end */
2709};
2710
2711
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002712/*
2713 * ALC880 F1734 model
2714 *
2715 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2716 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2717 */
2718
2719static hda_nid_t alc880_f1734_dac_nids[1] = {
2720 0x03
2721};
2722#define ALC880_F1734_HP_DAC 0x02
2723
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002724static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002725 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002726 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002727 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2728 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002729 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2730 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002731 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2732 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002733 { } /* end */
2734};
2735
Takashi Iwai937b4162008-02-11 14:52:36 +01002736static struct hda_input_mux alc880_f1734_capture_source = {
2737 .num_items = 2,
2738 .items = {
2739 { "Mic", 0x1 },
2740 { "CD", 0x4 },
2741 },
2742};
2743
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002744
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002745/*
2746 * ALC880 ASUS model
2747 *
2748 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2749 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2750 * Mic = 0x18, Line = 0x1a
2751 */
2752
2753#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2754#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2755
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002756static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002757 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002758 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002759 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002760 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002761 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2762 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002763 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2764 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002765 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2766 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2767 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2768 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2769 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2770 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002771 {
2772 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2773 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002774 .info = alc_ch_mode_info,
2775 .get = alc_ch_mode_get,
2776 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002777 },
2778 { } /* end */
2779};
2780
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002781/*
2782 * ALC880 ASUS W1V model
2783 *
2784 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2785 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2786 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2787 */
2788
2789/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002790static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002791 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2792 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002793 { } /* end */
2794};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002795
Kailang Yangdf694da2005-12-05 19:42:22 +01002796/* TCL S700 */
2797static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2798 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2799 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2800 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2801 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2802 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2803 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2804 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2805 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2806 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002807 { } /* end */
2808};
2809
Kailang Yangccc656c2006-10-17 12:32:26 +02002810/* Uniwill */
2811static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002812 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2813 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2814 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2815 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002816 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2817 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2818 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2819 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2820 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2821 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2822 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2823 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2824 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2825 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2826 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2827 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002828 {
2829 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2830 .name = "Channel Mode",
2831 .info = alc_ch_mode_info,
2832 .get = alc_ch_mode_get,
2833 .put = alc_ch_mode_put,
2834 },
2835 { } /* end */
2836};
2837
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002838static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2839 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2840 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2841 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2842 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2843 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2844 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +01002845 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2846 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01002847 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2848 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002849 { } /* end */
2850};
2851
Kailang Yangccc656c2006-10-17 12:32:26 +02002852static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002853 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2854 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2855 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2856 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002857 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2858 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2859 { } /* end */
2860};
2861
Linus Torvalds1da177e2005-04-16 15:20:36 -07002862/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002863 * virtual master controls
2864 */
2865
2866/*
2867 * slave controls for virtual master
2868 */
Takashi Iwaiea734962011-01-17 11:29:34 +01002869static const char * const alc_slave_vols[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002870 "Front Playback Volume",
2871 "Surround Playback Volume",
2872 "Center Playback Volume",
2873 "LFE Playback Volume",
2874 "Side Playback Volume",
2875 "Headphone Playback Volume",
2876 "Speaker Playback Volume",
2877 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002878 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002879 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002880 NULL,
2881};
2882
Takashi Iwaiea734962011-01-17 11:29:34 +01002883static const char * const alc_slave_sws[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002884 "Front Playback Switch",
2885 "Surround Playback Switch",
2886 "Center Playback Switch",
2887 "LFE Playback Switch",
2888 "Side Playback Switch",
2889 "Headphone Playback Switch",
2890 "Speaker Playback Switch",
2891 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002892 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002893 "Line-Out Playback Switch",
2894 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002895 NULL,
2896};
2897
2898/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002899 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002900 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002901
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002902#define NID_MAPPING (-1)
2903
2904#define SUBDEV_SPEAKER_ (0 << 6)
2905#define SUBDEV_HP_ (1 << 6)
2906#define SUBDEV_LINE_ (2 << 6)
2907#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2908#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2909#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2910
Takashi Iwai603c4012008-07-30 15:01:44 +02002911static void alc_free_kctls(struct hda_codec *codec);
2912
Takashi Iwai67d634c2009-11-16 15:35:59 +01002913#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002914/* additional beep mixers; the actual parameters are overwritten at build */
2915static struct snd_kcontrol_new alc_beep_mixer[] = {
2916 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002917 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002918 { } /* end */
2919};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002920#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002921
Linus Torvalds1da177e2005-04-16 15:20:36 -07002922static int alc_build_controls(struct hda_codec *codec)
2923{
2924 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02002925 struct snd_kcontrol *kctl = NULL;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002926 struct snd_kcontrol_new *knew;
2927 int i, j, err;
2928 unsigned int u;
2929 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002930
2931 for (i = 0; i < spec->num_mixers; i++) {
2932 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2933 if (err < 0)
2934 return err;
2935 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002936 if (spec->cap_mixer) {
2937 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2938 if (err < 0)
2939 return err;
2940 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002941 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002942 err = snd_hda_create_spdif_out_ctls(codec,
2943 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002944 if (err < 0)
2945 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002946 if (!spec->no_analog) {
2947 err = snd_hda_create_spdif_share_sw(codec,
2948 &spec->multiout);
2949 if (err < 0)
2950 return err;
2951 spec->multiout.share_spdif = 1;
2952 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002953 }
2954 if (spec->dig_in_nid) {
2955 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2956 if (err < 0)
2957 return err;
2958 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002959
Takashi Iwai67d634c2009-11-16 15:35:59 +01002960#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002961 /* create beep controls if needed */
2962 if (spec->beep_amp) {
2963 struct snd_kcontrol_new *knew;
2964 for (knew = alc_beep_mixer; knew->name; knew++) {
2965 struct snd_kcontrol *kctl;
2966 kctl = snd_ctl_new1(knew, codec);
2967 if (!kctl)
2968 return -ENOMEM;
2969 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002970 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002971 if (err < 0)
2972 return err;
2973 }
2974 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002975#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002976
Takashi Iwai2134ea42008-01-10 16:53:55 +01002977 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002978 if (!spec->no_analog &&
2979 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002980 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002981 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002982 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002983 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002984 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002985 if (err < 0)
2986 return err;
2987 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002988 if (!spec->no_analog &&
2989 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002990 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2991 NULL, alc_slave_sws);
2992 if (err < 0)
2993 return err;
2994 }
2995
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002996 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02002997 if (spec->capsrc_nids || spec->adc_nids) {
2998 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2999 if (!kctl)
3000 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
3001 for (i = 0; kctl && i < kctl->count; i++) {
3002 hda_nid_t *nids = spec->capsrc_nids;
3003 if (!nids)
3004 nids = spec->adc_nids;
3005 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
3006 if (err < 0)
3007 return err;
3008 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003009 }
3010 if (spec->cap_mixer) {
3011 const char *kname = kctl ? kctl->id.name : NULL;
3012 for (knew = spec->cap_mixer; knew->name; knew++) {
3013 if (kname && strcmp(knew->name, kname) == 0)
3014 continue;
3015 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3016 for (i = 0; kctl && i < kctl->count; i++) {
3017 err = snd_hda_add_nid(codec, kctl, i,
3018 spec->adc_nids[i]);
3019 if (err < 0)
3020 return err;
3021 }
3022 }
3023 }
3024
3025 /* other nid->control mapping */
3026 for (i = 0; i < spec->num_mixers; i++) {
3027 for (knew = spec->mixers[i]; knew->name; knew++) {
3028 if (knew->iface != NID_MAPPING)
3029 continue;
3030 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3031 if (kctl == NULL)
3032 continue;
3033 u = knew->subdevice;
3034 for (j = 0; j < 4; j++, u >>= 8) {
3035 nid = u & 0x3f;
3036 if (nid == 0)
3037 continue;
3038 switch (u & 0xc0) {
3039 case SUBDEV_SPEAKER_:
3040 nid = spec->autocfg.speaker_pins[nid];
3041 break;
3042 case SUBDEV_LINE_:
3043 nid = spec->autocfg.line_out_pins[nid];
3044 break;
3045 case SUBDEV_HP_:
3046 nid = spec->autocfg.hp_pins[nid];
3047 break;
3048 default:
3049 continue;
3050 }
3051 err = snd_hda_add_nid(codec, kctl, 0, nid);
3052 if (err < 0)
3053 return err;
3054 }
3055 u = knew->private_value;
3056 for (j = 0; j < 4; j++, u >>= 8) {
3057 nid = u & 0xff;
3058 if (nid == 0)
3059 continue;
3060 err = snd_hda_add_nid(codec, kctl, 0, nid);
3061 if (err < 0)
3062 return err;
3063 }
3064 }
3065 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01003066
3067 alc_free_kctls(codec); /* no longer needed */
3068
Linus Torvalds1da177e2005-04-16 15:20:36 -07003069 return 0;
3070}
3071
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003072
Linus Torvalds1da177e2005-04-16 15:20:36 -07003073/*
3074 * initialize the codec volumes, etc
3075 */
3076
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003077/*
3078 * generic initialization of ADC, input mixers and output mixers
3079 */
3080static struct hda_verb alc880_volume_init_verbs[] = {
3081 /*
3082 * Unmute ADC0-2 and set the default input to mic-in
3083 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003084 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003085 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003086 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003087 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003088 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003089 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003090
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003091 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3092 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003093 * Note: PASD motherboards uses the Line In 2 as the input for front
3094 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003095 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003096 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003097 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3098 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3099 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3101 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003104
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003105 /*
3106 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003107 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003108 /* set vol=0 to output mixers */
3109 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3110 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3111 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3112 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3113 /* set up input amps for analog loopback */
3114 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003115 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3116 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003117 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3118 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003119 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3120 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003121 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3122 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003123
3124 { }
3125};
3126
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003127/*
3128 * 3-stack pin configuration:
3129 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
3130 */
3131static struct hda_verb alc880_pin_3stack_init_verbs[] = {
3132 /*
3133 * preset connection lists of input pins
3134 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3135 */
3136 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3137 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3138 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3139
3140 /*
3141 * Set pin mode and muting
3142 */
3143 /* set front pin widgets 0x14 for output */
3144 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3145 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3146 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3147 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3148 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3149 /* Mic2 (as headphone out) for HP output */
3150 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3151 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3152 /* Line In pin widget for input */
3153 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3154 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3155 /* Line2 (as front mic) pin widget for input and vref at 80% */
3156 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3157 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3158 /* CD pin widget for input */
3159 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3160
3161 { }
3162};
3163
3164/*
3165 * 5-stack pin configuration:
3166 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3167 * line-in/side = 0x1a, f-mic = 0x1b
3168 */
3169static struct hda_verb alc880_pin_5stack_init_verbs[] = {
3170 /*
3171 * preset connection lists of input pins
3172 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3173 */
3174 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3175 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3176
3177 /*
3178 * Set pin mode and muting
3179 */
3180 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02003181 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3182 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3183 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3184 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003185 /* unmute pins for output (no gain on this amp) */
3186 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3187 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3188 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3189 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3190
Linus Torvalds1da177e2005-04-16 15:20:36 -07003191 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003192 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003193 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3194 /* Mic2 (as headphone out) for HP output */
3195 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003196 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003197 /* Line In pin widget for input */
3198 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3199 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3200 /* Line2 (as front mic) pin widget for input and vref at 80% */
3201 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3202 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3203 /* CD pin widget for input */
3204 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003205
3206 { }
3207};
3208
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003209/*
3210 * W810 pin configuration:
3211 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3212 */
3213static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003214 /* hphone/speaker input selector: front DAC */
3215 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3216
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003217 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3218 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3219 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3220 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3221 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3222 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3223
3224 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003225 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003226
Linus Torvalds1da177e2005-04-16 15:20:36 -07003227 { }
3228};
3229
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003230/*
3231 * Z71V pin configuration:
3232 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3233 */
3234static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003235 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003236 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02003237 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003238 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003239
Takashi Iwai16ded522005-06-10 19:58:24 +02003240 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003241 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003242 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003243 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003244
3245 { }
3246};
3247
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003248/*
3249 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003250 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3251 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003252 */
3253static struct hda_verb alc880_pin_6stack_init_verbs[] = {
3254 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3255
Takashi Iwai16ded522005-06-10 19:58:24 +02003256 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003257 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003258 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003259 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003260 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003261 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003262 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003263 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3264
Takashi Iwai16ded522005-06-10 19:58:24 +02003265 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003266 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003267 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003268 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003269 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003270 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003271 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003272 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003273 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003274
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003275 { }
3276};
Takashi Iwai16ded522005-06-10 19:58:24 +02003277
Kailang Yangccc656c2006-10-17 12:32:26 +02003278/*
3279 * Uniwill pin configuration:
3280 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3281 * line = 0x1a
3282 */
3283static struct hda_verb alc880_uniwill_init_verbs[] = {
3284 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3285
3286 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3287 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3288 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3289 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3290 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3291 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3292 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3293 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3294 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3295 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3296 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3297 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3298 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3299 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3300
3301 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3302 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3303 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3304 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3305 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3306 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3307 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3308 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3309 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3310
3311 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3312 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3313
3314 { }
3315};
3316
3317/*
3318* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003319* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003320 */
3321static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3322 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3323
3324 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3325 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3326 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3327 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3328 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3329 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3330 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3331 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3332 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3333 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3335 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3336
3337 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3338 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3339 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3340 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3341 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3342 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3343
3344 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3345 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3346
3347 { }
3348};
3349
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003350static struct hda_verb alc880_beep_init_verbs[] = {
3351 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3352 { }
3353};
3354
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003355/* auto-toggle front mic */
Anisse Astiereeb43382010-12-16 12:19:47 +01003356static void alc88x_simple_mic_automute(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003357{
3358 unsigned int present;
3359 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003360
Wu Fengguang864f92b2009-11-18 12:38:02 +08003361 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003362 bits = present ? HDA_AMP_MUTE : 0;
3363 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003364}
3365
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003366static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003367{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003368 struct alc_spec *spec = codec->spec;
3369
3370 spec->autocfg.hp_pins[0] = 0x14;
3371 spec->autocfg.speaker_pins[0] = 0x15;
3372 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003373}
3374
3375static void alc880_uniwill_init_hook(struct hda_codec *codec)
3376{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003377 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01003378 alc88x_simple_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003379}
3380
3381static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3382 unsigned int res)
3383{
3384 /* Looks like the unsol event is incompatible with the standard
3385 * definition. 4bit tag is placed at 28 bit!
3386 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003387 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003388 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01003389 alc88x_simple_mic_automute(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003390 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003391 default:
3392 alc_automute_amp_unsol_event(codec, res);
3393 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003394 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003395}
3396
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003397static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003398{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003399 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003400
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003401 spec->autocfg.hp_pins[0] = 0x14;
3402 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02003403}
3404
3405static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3406{
3407 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003408
Kailang Yangccc656c2006-10-17 12:32:26 +02003409 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003410 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3411 present &= HDA_AMP_VOLMASK;
3412 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3413 HDA_AMP_VOLMASK, present);
3414 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3415 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003416}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003417
Kailang Yangccc656c2006-10-17 12:32:26 +02003418static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3419 unsigned int res)
3420{
3421 /* Looks like the unsol event is incompatible with the standard
3422 * definition. 4bit tag is placed at 28 bit!
3423 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003424 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003425 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003426 else
3427 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003428}
3429
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003430/*
3431 * F1734 pin configuration:
3432 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3433 */
3434static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003435 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003436 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3437 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3438 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3439 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3440
3441 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3442 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3443 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3444 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3445
3446 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3447 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003448 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003449 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3450 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3451 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3452 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3453 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3454 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003455
Takashi Iwai937b4162008-02-11 14:52:36 +01003456 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3457 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3458
Takashi Iwai16ded522005-06-10 19:58:24 +02003459 { }
3460};
3461
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003462/*
3463 * ASUS pin configuration:
3464 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3465 */
3466static struct hda_verb alc880_pin_asus_init_verbs[] = {
3467 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3468 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3469 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3470 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3471
3472 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3473 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3474 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3475 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3476 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3477 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3478 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3479 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3480
3481 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3482 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3483 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3484 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3485 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3486 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3487 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3488 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3489 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003490
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003491 { }
3492};
3493
3494/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003495#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3496#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003497#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003498
Kailang Yangdf694da2005-12-05 19:42:22 +01003499/* Clevo m520g init */
3500static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3501 /* headphone output */
3502 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3503 /* line-out */
3504 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3505 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3506 /* Line-in */
3507 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3508 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3509 /* CD */
3510 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3511 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3512 /* Mic1 (rear panel) */
3513 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3514 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3515 /* Mic2 (front panel) */
3516 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3517 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3518 /* headphone */
3519 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3520 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3521 /* change to EAPD mode */
3522 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3523 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3524
3525 { }
3526};
3527
3528static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003529 /* change to EAPD mode */
3530 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3531 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3532
Kailang Yangdf694da2005-12-05 19:42:22 +01003533 /* Headphone output */
3534 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3535 /* Front output*/
3536 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3537 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3538
3539 /* Line In pin widget for input */
3540 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3541 /* CD pin widget for input */
3542 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3543 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3544 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3545
3546 /* change to EAPD mode */
3547 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3548 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3549
3550 { }
3551};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003552
3553/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003554 * LG m1 express dual
3555 *
3556 * Pin assignment:
3557 * Rear Line-In/Out (blue): 0x14
3558 * Build-in Mic-In: 0x15
3559 * Speaker-out: 0x17
3560 * HP-Out (green): 0x1b
3561 * Mic-In/Out (red): 0x19
3562 * SPDIF-Out: 0x1e
3563 */
3564
3565/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3566static hda_nid_t alc880_lg_dac_nids[3] = {
3567 0x05, 0x02, 0x03
3568};
3569
3570/* seems analog CD is not working */
3571static struct hda_input_mux alc880_lg_capture_source = {
3572 .num_items = 3,
3573 .items = {
3574 { "Mic", 0x1 },
3575 { "Line", 0x5 },
3576 { "Internal Mic", 0x6 },
3577 },
3578};
3579
3580/* 2,4,6 channel modes */
3581static struct hda_verb alc880_lg_ch2_init[] = {
3582 /* set line-in and mic-in to input */
3583 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3584 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3585 { }
3586};
3587
3588static struct hda_verb alc880_lg_ch4_init[] = {
3589 /* set line-in to out and mic-in to input */
3590 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3591 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3592 { }
3593};
3594
3595static struct hda_verb alc880_lg_ch6_init[] = {
3596 /* set line-in and mic-in to output */
3597 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3598 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3599 { }
3600};
3601
3602static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3603 { 2, alc880_lg_ch2_init },
3604 { 4, alc880_lg_ch4_init },
3605 { 6, alc880_lg_ch6_init },
3606};
3607
3608static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003609 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3610 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003611 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3612 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3613 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3614 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3615 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3616 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3617 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3618 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3619 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3620 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3621 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3622 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3623 {
3624 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3625 .name = "Channel Mode",
3626 .info = alc_ch_mode_info,
3627 .get = alc_ch_mode_get,
3628 .put = alc_ch_mode_put,
3629 },
3630 { } /* end */
3631};
3632
3633static struct hda_verb alc880_lg_init_verbs[] = {
3634 /* set capture source to mic-in */
3635 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3636 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3637 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3638 /* mute all amp mixer inputs */
3639 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003642 /* line-in to input */
3643 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3644 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3645 /* built-in mic */
3646 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3647 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3648 /* speaker-out */
3649 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3650 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3651 /* mic-in to input */
3652 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3653 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3654 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3655 /* HP-out */
3656 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3657 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3658 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3659 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003660 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003661 { }
3662};
3663
3664/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003665static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003666{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003667 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003668
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003669 spec->autocfg.hp_pins[0] = 0x1b;
3670 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003671}
3672
3673/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003674 * LG LW20
3675 *
3676 * Pin assignment:
3677 * Speaker-out: 0x14
3678 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003679 * Built-in Mic-In: 0x19
3680 * Line-In: 0x1b
3681 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003682 * SPDIF-Out: 0x1e
3683 */
3684
Takashi Iwaid6815182006-03-23 16:06:23 +01003685static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003686 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003687 .items = {
3688 { "Mic", 0x0 },
3689 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003690 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003691 },
3692};
3693
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003694#define alc880_lg_lw_modes alc880_threestack_modes
3695
Takashi Iwaid6815182006-03-23 16:06:23 +01003696static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003697 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3698 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3699 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3700 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3701 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3702 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3703 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3704 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3705 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3706 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3709 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3710 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003711 {
3712 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3713 .name = "Channel Mode",
3714 .info = alc_ch_mode_info,
3715 .get = alc_ch_mode_get,
3716 .put = alc_ch_mode_put,
3717 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003718 { } /* end */
3719};
3720
3721static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003722 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3723 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3724 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3725
Takashi Iwaid6815182006-03-23 16:06:23 +01003726 /* set capture source to mic-in */
3727 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3728 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3729 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003730 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003731 /* speaker-out */
3732 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3733 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3734 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003735 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3736 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3737 /* mic-in to input */
3738 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3739 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3740 /* built-in mic */
3741 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3742 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3743 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003744 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003745 { }
3746};
3747
3748/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003749static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003750{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003751 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003752
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003753 spec->autocfg.hp_pins[0] = 0x1b;
3754 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003755}
3756
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003757static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3758 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3759 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3760 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3761 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3762 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3763 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3764 { } /* end */
3765};
3766
3767static struct hda_input_mux alc880_medion_rim_capture_source = {
3768 .num_items = 2,
3769 .items = {
3770 { "Mic", 0x0 },
3771 { "Internal Mic", 0x1 },
3772 },
3773};
3774
3775static struct hda_verb alc880_medion_rim_init_verbs[] = {
3776 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3777
3778 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3779 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3780
3781 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3782 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3783 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3784 /* Mic2 (as headphone out) for HP output */
3785 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3786 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3787 /* Internal Speaker */
3788 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3789 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3790
3791 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3792 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3793
3794 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3795 { }
3796};
3797
3798/* toggle speaker-output according to the hp-jack state */
3799static void alc880_medion_rim_automute(struct hda_codec *codec)
3800{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003801 struct alc_spec *spec = codec->spec;
3802 alc_automute_amp(codec);
3803 /* toggle EAPD */
3804 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003805 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3806 else
3807 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3808}
3809
3810static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3811 unsigned int res)
3812{
3813 /* Looks like the unsol event is incompatible with the standard
3814 * definition. 4bit tag is placed at 28 bit!
3815 */
3816 if ((res >> 28) == ALC880_HP_EVENT)
3817 alc880_medion_rim_automute(codec);
3818}
3819
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003820static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003821{
3822 struct alc_spec *spec = codec->spec;
3823
3824 spec->autocfg.hp_pins[0] = 0x14;
3825 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003826}
3827
Takashi Iwaicb53c622007-08-10 17:21:45 +02003828#ifdef CONFIG_SND_HDA_POWER_SAVE
3829static struct hda_amp_list alc880_loopbacks[] = {
3830 { 0x0b, HDA_INPUT, 0 },
3831 { 0x0b, HDA_INPUT, 1 },
3832 { 0x0b, HDA_INPUT, 2 },
3833 { 0x0b, HDA_INPUT, 3 },
3834 { 0x0b, HDA_INPUT, 4 },
3835 { } /* end */
3836};
3837
3838static struct hda_amp_list alc880_lg_loopbacks[] = {
3839 { 0x0b, HDA_INPUT, 1 },
3840 { 0x0b, HDA_INPUT, 6 },
3841 { 0x0b, HDA_INPUT, 7 },
3842 { } /* end */
3843};
3844#endif
3845
Takashi Iwaid6815182006-03-23 16:06:23 +01003846/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003847 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003848 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003849
Linus Torvalds1da177e2005-04-16 15:20:36 -07003850static int alc_init(struct hda_codec *codec)
3851{
3852 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003853 unsigned int i;
3854
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003855 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003856 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003857
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003858 for (i = 0; i < spec->num_init_verbs; i++)
3859 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003860
3861 if (spec->init_hook)
3862 spec->init_hook(codec);
3863
Takashi Iwai58701122011-01-13 15:41:45 +01003864 alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT);
3865
Takashi Iwai9e5341b2010-09-21 09:57:06 +02003866 hda_call_check_power_status(codec, 0x01);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003867 return 0;
3868}
3869
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003870static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3871{
3872 struct alc_spec *spec = codec->spec;
3873
3874 if (spec->unsol_event)
3875 spec->unsol_event(codec, res);
3876}
3877
Takashi Iwaicb53c622007-08-10 17:21:45 +02003878#ifdef CONFIG_SND_HDA_POWER_SAVE
3879static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3880{
3881 struct alc_spec *spec = codec->spec;
3882 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3883}
3884#endif
3885
Linus Torvalds1da177e2005-04-16 15:20:36 -07003886/*
3887 * Analog playback callbacks
3888 */
3889static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3890 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003891 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003892{
3893 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003894 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3895 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003896}
3897
3898static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3899 struct hda_codec *codec,
3900 unsigned int stream_tag,
3901 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003902 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003903{
3904 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003905 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3906 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003907}
3908
3909static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3910 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003911 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003912{
3913 struct alc_spec *spec = codec->spec;
3914 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3915}
3916
3917/*
3918 * Digital out
3919 */
3920static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3921 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003922 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003923{
3924 struct alc_spec *spec = codec->spec;
3925 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3926}
3927
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003928static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3929 struct hda_codec *codec,
3930 unsigned int stream_tag,
3931 unsigned int format,
3932 struct snd_pcm_substream *substream)
3933{
3934 struct alc_spec *spec = codec->spec;
3935 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3936 stream_tag, format, substream);
3937}
3938
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003939static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3940 struct hda_codec *codec,
3941 struct snd_pcm_substream *substream)
3942{
3943 struct alc_spec *spec = codec->spec;
3944 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3945}
3946
Linus Torvalds1da177e2005-04-16 15:20:36 -07003947static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3948 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003949 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003950{
3951 struct alc_spec *spec = codec->spec;
3952 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3953}
3954
3955/*
3956 * Analog capture
3957 */
Takashi Iwai63300792008-01-24 15:31:36 +01003958static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003959 struct hda_codec *codec,
3960 unsigned int stream_tag,
3961 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003962 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003963{
3964 struct alc_spec *spec = codec->spec;
3965
Takashi Iwai63300792008-01-24 15:31:36 +01003966 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003967 stream_tag, 0, format);
3968 return 0;
3969}
3970
Takashi Iwai63300792008-01-24 15:31:36 +01003971static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003972 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003973 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003974{
3975 struct alc_spec *spec = codec->spec;
3976
Takashi Iwai888afa12008-03-18 09:57:50 +01003977 snd_hda_codec_cleanup_stream(codec,
3978 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003979 return 0;
3980}
3981
Takashi Iwai840b64c2010-07-13 22:49:01 +02003982/* analog capture with dynamic dual-adc changes */
3983static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3984 struct hda_codec *codec,
3985 unsigned int stream_tag,
3986 unsigned int format,
3987 struct snd_pcm_substream *substream)
3988{
3989 struct alc_spec *spec = codec->spec;
3990 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
3991 spec->cur_adc_stream_tag = stream_tag;
3992 spec->cur_adc_format = format;
3993 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
3994 return 0;
3995}
3996
3997static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3998 struct hda_codec *codec,
3999 struct snd_pcm_substream *substream)
4000{
4001 struct alc_spec *spec = codec->spec;
4002 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
4003 spec->cur_adc = 0;
4004 return 0;
4005}
4006
4007static struct hda_pcm_stream dualmic_pcm_analog_capture = {
4008 .substreams = 1,
4009 .channels_min = 2,
4010 .channels_max = 2,
4011 .nid = 0, /* fill later */
4012 .ops = {
4013 .prepare = dualmic_capture_pcm_prepare,
4014 .cleanup = dualmic_capture_pcm_cleanup
4015 },
4016};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004017
4018/*
4019 */
4020static struct hda_pcm_stream alc880_pcm_analog_playback = {
4021 .substreams = 1,
4022 .channels_min = 2,
4023 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004024 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004025 .ops = {
4026 .open = alc880_playback_pcm_open,
4027 .prepare = alc880_playback_pcm_prepare,
4028 .cleanup = alc880_playback_pcm_cleanup
4029 },
4030};
4031
4032static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01004033 .substreams = 1,
4034 .channels_min = 2,
4035 .channels_max = 2,
4036 /* NID is set in alc_build_pcms */
4037};
4038
4039static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
4040 .substreams = 1,
4041 .channels_min = 2,
4042 .channels_max = 2,
4043 /* NID is set in alc_build_pcms */
4044};
4045
4046static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
4047 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004048 .channels_min = 2,
4049 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004050 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004051 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01004052 .prepare = alc880_alt_capture_pcm_prepare,
4053 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004054 },
4055};
4056
4057static struct hda_pcm_stream alc880_pcm_digital_playback = {
4058 .substreams = 1,
4059 .channels_min = 2,
4060 .channels_max = 2,
4061 /* NID is set in alc_build_pcms */
4062 .ops = {
4063 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02004064 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01004065 .prepare = alc880_dig_playback_pcm_prepare,
4066 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004067 },
4068};
4069
4070static struct hda_pcm_stream alc880_pcm_digital_capture = {
4071 .substreams = 1,
4072 .channels_min = 2,
4073 .channels_max = 2,
4074 /* NID is set in alc_build_pcms */
4075};
4076
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004077/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01004078static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004079 .substreams = 0,
4080 .channels_min = 0,
4081 .channels_max = 0,
4082};
4083
Linus Torvalds1da177e2005-04-16 15:20:36 -07004084static int alc_build_pcms(struct hda_codec *codec)
4085{
4086 struct alc_spec *spec = codec->spec;
4087 struct hda_pcm *info = spec->pcm_rec;
4088 int i;
4089
4090 codec->num_pcms = 1;
4091 codec->pcm_info = info;
4092
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004093 if (spec->no_analog)
4094 goto skip_analog;
4095
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004096 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
4097 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004098 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01004099
Takashi Iwai4a471b72005-12-07 13:56:29 +01004100 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004101 if (snd_BUG_ON(!spec->multiout.dac_nids))
4102 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004103 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
4104 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
4105 }
4106 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004107 if (snd_BUG_ON(!spec->adc_nids))
4108 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004109 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
4110 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
4111 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004112
Takashi Iwai4a471b72005-12-07 13:56:29 +01004113 if (spec->channel_mode) {
4114 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
4115 for (i = 0; i < spec->num_channel_mode; i++) {
4116 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
4117 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
4118 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004119 }
4120 }
4121
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004122 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02004123 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004124 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004125 snprintf(spec->stream_name_digital,
4126 sizeof(spec->stream_name_digital),
4127 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02004128 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08004129 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004130 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004131 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01004132 if (spec->dig_out_type)
4133 info->pcm_type = spec->dig_out_type;
4134 else
4135 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004136 if (spec->multiout.dig_out_nid &&
4137 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004138 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
4139 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
4140 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004141 if (spec->dig_in_nid &&
4142 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004143 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
4144 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
4145 }
Takashi Iwai963f8032008-08-11 10:04:40 +02004146 /* FIXME: do we need this for all Realtek codec models? */
4147 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004148 }
4149
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004150 if (spec->no_analog)
4151 return 0;
4152
Takashi Iwaie08a0072006-09-07 17:52:14 +02004153 /* If the use of more than one ADC is requested for the current
4154 * model, configure a second analog capture-only PCM.
4155 */
4156 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01004157 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
4158 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02004159 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004160 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004161 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01004162 if (spec->alt_dac_nid) {
4163 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4164 *spec->stream_analog_alt_playback;
4165 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
4166 spec->alt_dac_nid;
4167 } else {
4168 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4169 alc_pcm_null_stream;
4170 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
4171 }
4172 if (spec->num_adc_nids > 1) {
4173 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4174 *spec->stream_analog_alt_capture;
4175 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
4176 spec->adc_nids[1];
4177 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
4178 spec->num_adc_nids - 1;
4179 } else {
4180 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4181 alc_pcm_null_stream;
4182 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004183 }
4184 }
4185
Linus Torvalds1da177e2005-04-16 15:20:36 -07004186 return 0;
4187}
4188
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004189static inline void alc_shutup(struct hda_codec *codec)
4190{
4191 snd_hda_shutup_pins(codec);
4192}
4193
Takashi Iwai603c4012008-07-30 15:01:44 +02004194static void alc_free_kctls(struct hda_codec *codec)
4195{
4196 struct alc_spec *spec = codec->spec;
4197
4198 if (spec->kctls.list) {
4199 struct snd_kcontrol_new *kctl = spec->kctls.list;
4200 int i;
4201 for (i = 0; i < spec->kctls.used; i++)
4202 kfree(kctl[i].name);
4203 }
4204 snd_array_free(&spec->kctls);
4205}
4206
Linus Torvalds1da177e2005-04-16 15:20:36 -07004207static void alc_free(struct hda_codec *codec)
4208{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004209 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004210
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004211 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004212 return;
4213
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004214 alc_shutup(codec);
Takashi Iwaicd372fb2011-03-03 14:40:14 +01004215 snd_hda_input_jack_free(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02004216 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004217 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004218 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004219}
4220
Hector Martinf5de24b2009-12-20 22:51:31 +01004221#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05004222static void alc_power_eapd(struct hda_codec *codec)
4223{
4224 /* We currently only handle front, HP */
4225 switch (codec->vendor_id) {
4226 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004227 set_eapd(codec, 0x0f, 0);
4228 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004229 break;
4230 case 0x10ec0262:
4231 case 0x10ec0267:
4232 case 0x10ec0268:
4233 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004234 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05004235 case 0x10ec0272:
4236 case 0x10ec0660:
4237 case 0x10ec0662:
4238 case 0x10ec0663:
4239 case 0x10ec0862:
4240 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004241 set_eapd(codec, 0x14, 0);
4242 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004243 break;
4244 }
4245}
4246
Hector Martinf5de24b2009-12-20 22:51:31 +01004247static int alc_suspend(struct hda_codec *codec, pm_message_t state)
4248{
4249 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004250 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004251 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05004252 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004253 return 0;
4254}
4255#endif
4256
Takashi Iwaie044c392008-10-27 16:56:24 +01004257#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01004258static int alc_resume(struct hda_codec *codec)
4259{
Takashi Iwaie044c392008-10-27 16:56:24 +01004260 codec->patch_ops.init(codec);
4261 snd_hda_codec_resume_amp(codec);
4262 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +02004263 hda_call_check_power_status(codec, 0x01);
Takashi Iwaie044c392008-10-27 16:56:24 +01004264 return 0;
4265}
Takashi Iwaie044c392008-10-27 16:56:24 +01004266#endif
4267
Linus Torvalds1da177e2005-04-16 15:20:36 -07004268/*
4269 */
4270static struct hda_codec_ops alc_patch_ops = {
4271 .build_controls = alc_build_controls,
4272 .build_pcms = alc_build_pcms,
4273 .init = alc_init,
4274 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004275 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004276#ifdef SND_HDA_NEEDS_RESUME
4277 .resume = alc_resume,
4278#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004279#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004280 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004281 .check_power_status = alc_check_power_status,
4282#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004283 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004284};
4285
Kailang Yangc027ddc2010-03-19 11:33:06 +01004286/* replace the codec chip_name with the given string */
4287static int alc_codec_rename(struct hda_codec *codec, const char *name)
4288{
4289 kfree(codec->chip_name);
4290 codec->chip_name = kstrdup(name, GFP_KERNEL);
4291 if (!codec->chip_name) {
4292 alc_free(codec);
4293 return -ENOMEM;
4294 }
4295 return 0;
4296}
4297
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004298/*
4299 * Test configuration for debugging
4300 *
4301 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4302 * enum controls.
4303 */
4304#ifdef CONFIG_SND_DEBUG
4305static hda_nid_t alc880_test_dac_nids[4] = {
4306 0x02, 0x03, 0x04, 0x05
4307};
4308
4309static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004310 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004311 .items = {
4312 { "In-1", 0x0 },
4313 { "In-2", 0x1 },
4314 { "In-3", 0x2 },
4315 { "In-4", 0x3 },
4316 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004317 { "Front", 0x5 },
4318 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004319 },
4320};
4321
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004322static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004323 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004324 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004325 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004326 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004327};
4328
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004329static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4330 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004331{
4332 static char *texts[] = {
4333 "N/A", "Line Out", "HP Out",
4334 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4335 };
4336 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4337 uinfo->count = 1;
4338 uinfo->value.enumerated.items = 8;
4339 if (uinfo->value.enumerated.item >= 8)
4340 uinfo->value.enumerated.item = 7;
4341 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4342 return 0;
4343}
4344
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004345static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4346 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004347{
4348 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4349 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4350 unsigned int pin_ctl, item = 0;
4351
4352 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4353 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4354 if (pin_ctl & AC_PINCTL_OUT_EN) {
4355 if (pin_ctl & AC_PINCTL_HP_EN)
4356 item = 2;
4357 else
4358 item = 1;
4359 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4360 switch (pin_ctl & AC_PINCTL_VREFEN) {
4361 case AC_PINCTL_VREF_HIZ: item = 3; break;
4362 case AC_PINCTL_VREF_50: item = 4; break;
4363 case AC_PINCTL_VREF_GRD: item = 5; break;
4364 case AC_PINCTL_VREF_80: item = 6; break;
4365 case AC_PINCTL_VREF_100: item = 7; break;
4366 }
4367 }
4368 ucontrol->value.enumerated.item[0] = item;
4369 return 0;
4370}
4371
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004372static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
4373 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004374{
4375 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4376 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4377 static unsigned int ctls[] = {
4378 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4379 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4380 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4381 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4382 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4383 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4384 };
4385 unsigned int old_ctl, new_ctl;
4386
4387 old_ctl = snd_hda_codec_read(codec, nid, 0,
4388 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4389 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4390 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004391 int val;
4392 snd_hda_codec_write_cache(codec, nid, 0,
4393 AC_VERB_SET_PIN_WIDGET_CONTROL,
4394 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004395 val = ucontrol->value.enumerated.item[0] >= 3 ?
4396 HDA_AMP_MUTE : 0;
4397 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4398 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004399 return 1;
4400 }
4401 return 0;
4402}
4403
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004404static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4405 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004406{
4407 static char *texts[] = {
4408 "Front", "Surround", "CLFE", "Side"
4409 };
4410 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4411 uinfo->count = 1;
4412 uinfo->value.enumerated.items = 4;
4413 if (uinfo->value.enumerated.item >= 4)
4414 uinfo->value.enumerated.item = 3;
4415 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4416 return 0;
4417}
4418
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004419static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4420 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004421{
4422 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4423 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4424 unsigned int sel;
4425
4426 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4427 ucontrol->value.enumerated.item[0] = sel & 3;
4428 return 0;
4429}
4430
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004431static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4432 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004433{
4434 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4435 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4436 unsigned int sel;
4437
4438 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4439 if (ucontrol->value.enumerated.item[0] != sel) {
4440 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004441 snd_hda_codec_write_cache(codec, nid, 0,
4442 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004443 return 1;
4444 }
4445 return 0;
4446}
4447
4448#define PIN_CTL_TEST(xname,nid) { \
4449 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4450 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004451 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004452 .info = alc_test_pin_ctl_info, \
4453 .get = alc_test_pin_ctl_get, \
4454 .put = alc_test_pin_ctl_put, \
4455 .private_value = nid \
4456 }
4457
4458#define PIN_SRC_TEST(xname,nid) { \
4459 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4460 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004461 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004462 .info = alc_test_pin_src_info, \
4463 .get = alc_test_pin_src_get, \
4464 .put = alc_test_pin_src_put, \
4465 .private_value = nid \
4466 }
4467
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004468static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004469 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4470 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4471 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4472 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004473 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4474 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4475 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4476 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004477 PIN_CTL_TEST("Front Pin Mode", 0x14),
4478 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4479 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4480 PIN_CTL_TEST("Side Pin Mode", 0x17),
4481 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4482 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4483 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4484 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4485 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4486 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4487 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4488 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4489 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4490 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4491 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4492 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4493 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4494 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4495 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4496 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4497 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4498 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004499 {
4500 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4501 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004502 .info = alc_ch_mode_info,
4503 .get = alc_ch_mode_get,
4504 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004505 },
4506 { } /* end */
4507};
4508
4509static struct hda_verb alc880_test_init_verbs[] = {
4510 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004511 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4512 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4513 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4514 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4515 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4516 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4517 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4518 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004519 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004520 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4521 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4522 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4523 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004524 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004525 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4526 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4527 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4528 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004529 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004530 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4531 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4532 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4533 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004534 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004535 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4536 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004537 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4538 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4539 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004540 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004541 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4542 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4543 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4544 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004545 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004546 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004547 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004548 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004549 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004550 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004551 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004552 /* Analog input/passthru */
4553 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4554 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4555 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4556 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4557 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004558 { }
4559};
4560#endif
4561
Linus Torvalds1da177e2005-04-16 15:20:36 -07004562/*
4563 */
4564
Takashi Iwaiea734962011-01-17 11:29:34 +01004565static const char * const alc880_models[ALC880_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004566 [ALC880_3ST] = "3stack",
4567 [ALC880_TCL_S700] = "tcl",
4568 [ALC880_3ST_DIG] = "3stack-digout",
4569 [ALC880_CLEVO] = "clevo",
4570 [ALC880_5ST] = "5stack",
4571 [ALC880_5ST_DIG] = "5stack-digout",
4572 [ALC880_W810] = "w810",
4573 [ALC880_Z71V] = "z71v",
4574 [ALC880_6ST] = "6stack",
4575 [ALC880_6ST_DIG] = "6stack-digout",
4576 [ALC880_ASUS] = "asus",
4577 [ALC880_ASUS_W1V] = "asus-w1v",
4578 [ALC880_ASUS_DIG] = "asus-dig",
4579 [ALC880_ASUS_DIG2] = "asus-dig2",
4580 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004581 [ALC880_UNIWILL_P53] = "uniwill-p53",
4582 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004583 [ALC880_F1734] = "F1734",
4584 [ALC880_LG] = "lg",
4585 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004586 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004587#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004588 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004589#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004590 [ALC880_AUTO] = "auto",
4591};
4592
4593static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004594 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004595 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4596 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4597 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4598 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4599 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4600 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4601 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4602 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004603 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4604 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004605 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4606 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4607 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4608 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4609 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4610 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4611 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4612 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4613 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4614 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004615 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004616 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4617 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4618 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004619 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004620 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004621 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4622 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004623 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4624 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004625 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4626 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4627 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4628 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004629 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4630 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004631 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004632 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004633 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004634 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004635 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4636 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004637 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004638 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004639 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004640 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004641 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004642 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004643 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004644 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004645 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004646 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
Daniel T Chen77c4d5c2010-12-02 22:45:45 -05004647 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004648 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004649 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004650 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4651 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4652 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4653 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004654 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4655 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004656 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004657 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004658 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4659 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004660 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4661 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4662 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004663 /* default Intel */
4664 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004665 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4666 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004667 {}
4668};
4669
Takashi Iwai16ded522005-06-10 19:58:24 +02004670/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004671 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004672 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004673static struct alc_config_preset alc880_presets[] = {
4674 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004675 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004676 .init_verbs = { alc880_volume_init_verbs,
4677 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004678 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004679 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004680 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4681 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004682 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004683 .input_mux = &alc880_capture_source,
4684 },
4685 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004686 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004687 .init_verbs = { alc880_volume_init_verbs,
4688 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004689 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004690 .dac_nids = alc880_dac_nids,
4691 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004692 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4693 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004694 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004695 .input_mux = &alc880_capture_source,
4696 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004697 [ALC880_TCL_S700] = {
4698 .mixers = { alc880_tcl_s700_mixer },
4699 .init_verbs = { alc880_volume_init_verbs,
4700 alc880_pin_tcl_S700_init_verbs,
4701 alc880_gpio2_init_verbs },
4702 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4703 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004704 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4705 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004706 .hp_nid = 0x03,
4707 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4708 .channel_mode = alc880_2_jack_modes,
4709 .input_mux = &alc880_capture_source,
4710 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004711 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004712 .mixers = { alc880_three_stack_mixer,
4713 alc880_five_stack_mixer},
4714 .init_verbs = { alc880_volume_init_verbs,
4715 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004716 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4717 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004718 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4719 .channel_mode = alc880_fivestack_modes,
4720 .input_mux = &alc880_capture_source,
4721 },
4722 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004723 .mixers = { alc880_three_stack_mixer,
4724 alc880_five_stack_mixer },
4725 .init_verbs = { alc880_volume_init_verbs,
4726 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004727 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4728 .dac_nids = alc880_dac_nids,
4729 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004730 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4731 .channel_mode = alc880_fivestack_modes,
4732 .input_mux = &alc880_capture_source,
4733 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004734 [ALC880_6ST] = {
4735 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004736 .init_verbs = { alc880_volume_init_verbs,
4737 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004738 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4739 .dac_nids = alc880_6st_dac_nids,
4740 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4741 .channel_mode = alc880_sixstack_modes,
4742 .input_mux = &alc880_6stack_capture_source,
4743 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004744 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004745 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004746 .init_verbs = { alc880_volume_init_verbs,
4747 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004748 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4749 .dac_nids = alc880_6st_dac_nids,
4750 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004751 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4752 .channel_mode = alc880_sixstack_modes,
4753 .input_mux = &alc880_6stack_capture_source,
4754 },
4755 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004756 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004757 .init_verbs = { alc880_volume_init_verbs,
4758 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004759 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004760 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4761 .dac_nids = alc880_w810_dac_nids,
4762 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004763 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4764 .channel_mode = alc880_w810_modes,
4765 .input_mux = &alc880_capture_source,
4766 },
4767 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004768 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004769 .init_verbs = { alc880_volume_init_verbs,
4770 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004771 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4772 .dac_nids = alc880_z71v_dac_nids,
4773 .dig_out_nid = ALC880_DIGOUT_NID,
4774 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004775 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4776 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004777 .input_mux = &alc880_capture_source,
4778 },
4779 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004780 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004781 .init_verbs = { alc880_volume_init_verbs,
4782 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004783 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4784 .dac_nids = alc880_f1734_dac_nids,
4785 .hp_nid = 0x02,
4786 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4787 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004788 .input_mux = &alc880_f1734_capture_source,
4789 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004790 .setup = alc880_uniwill_p53_setup,
4791 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004792 },
4793 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004794 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004795 .init_verbs = { alc880_volume_init_verbs,
4796 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004797 alc880_gpio1_init_verbs },
4798 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4799 .dac_nids = alc880_asus_dac_nids,
4800 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4801 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004802 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004803 .input_mux = &alc880_capture_source,
4804 },
4805 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004806 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004807 .init_verbs = { alc880_volume_init_verbs,
4808 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004809 alc880_gpio1_init_verbs },
4810 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4811 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004812 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004813 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4814 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004815 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004816 .input_mux = &alc880_capture_source,
4817 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004818 [ALC880_ASUS_DIG2] = {
4819 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004820 .init_verbs = { alc880_volume_init_verbs,
4821 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004822 alc880_gpio2_init_verbs }, /* use GPIO2 */
4823 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4824 .dac_nids = alc880_asus_dac_nids,
4825 .dig_out_nid = ALC880_DIGOUT_NID,
4826 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4827 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004828 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004829 .input_mux = &alc880_capture_source,
4830 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004831 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004832 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004833 .init_verbs = { alc880_volume_init_verbs,
4834 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004835 alc880_gpio1_init_verbs },
4836 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4837 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004838 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004839 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4840 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004841 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004842 .input_mux = &alc880_capture_source,
4843 },
4844 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004845 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004846 .init_verbs = { alc880_volume_init_verbs,
4847 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004848 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4849 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004850 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004851 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4852 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004853 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004854 .input_mux = &alc880_capture_source,
4855 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004856 [ALC880_UNIWILL] = {
4857 .mixers = { alc880_uniwill_mixer },
4858 .init_verbs = { alc880_volume_init_verbs,
4859 alc880_uniwill_init_verbs },
4860 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4861 .dac_nids = alc880_asus_dac_nids,
4862 .dig_out_nid = ALC880_DIGOUT_NID,
4863 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4864 .channel_mode = alc880_threestack_modes,
4865 .need_dac_fix = 1,
4866 .input_mux = &alc880_capture_source,
4867 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004868 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004869 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004870 },
4871 [ALC880_UNIWILL_P53] = {
4872 .mixers = { alc880_uniwill_p53_mixer },
4873 .init_verbs = { alc880_volume_init_verbs,
4874 alc880_uniwill_p53_init_verbs },
4875 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4876 .dac_nids = alc880_asus_dac_nids,
4877 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004878 .channel_mode = alc880_threestack_modes,
4879 .input_mux = &alc880_capture_source,
4880 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004881 .setup = alc880_uniwill_p53_setup,
4882 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004883 },
4884 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004885 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004886 .init_verbs = { alc880_volume_init_verbs,
4887 alc880_uniwill_p53_init_verbs,
4888 alc880_beep_init_verbs },
4889 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4890 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004891 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004892 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4893 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004894 .input_mux = &alc880_capture_source,
4895 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004896 .setup = alc880_uniwill_p53_setup,
4897 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004898 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004899 [ALC880_CLEVO] = {
4900 .mixers = { alc880_three_stack_mixer },
4901 .init_verbs = { alc880_volume_init_verbs,
4902 alc880_pin_clevo_init_verbs },
4903 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4904 .dac_nids = alc880_dac_nids,
4905 .hp_nid = 0x03,
4906 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4907 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004908 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004909 .input_mux = &alc880_capture_source,
4910 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004911 [ALC880_LG] = {
4912 .mixers = { alc880_lg_mixer },
4913 .init_verbs = { alc880_volume_init_verbs,
4914 alc880_lg_init_verbs },
4915 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4916 .dac_nids = alc880_lg_dac_nids,
4917 .dig_out_nid = ALC880_DIGOUT_NID,
4918 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4919 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004920 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004921 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004922 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004923 .setup = alc880_lg_setup,
4924 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004925#ifdef CONFIG_SND_HDA_POWER_SAVE
4926 .loopbacks = alc880_lg_loopbacks,
4927#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004928 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004929 [ALC880_LG_LW] = {
4930 .mixers = { alc880_lg_lw_mixer },
4931 .init_verbs = { alc880_volume_init_verbs,
4932 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004933 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004934 .dac_nids = alc880_dac_nids,
4935 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004936 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4937 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004938 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004939 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004940 .setup = alc880_lg_lw_setup,
4941 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004942 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004943 [ALC880_MEDION_RIM] = {
4944 .mixers = { alc880_medion_rim_mixer },
4945 .init_verbs = { alc880_volume_init_verbs,
4946 alc880_medion_rim_init_verbs,
4947 alc_gpio2_init_verbs },
4948 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4949 .dac_nids = alc880_dac_nids,
4950 .dig_out_nid = ALC880_DIGOUT_NID,
4951 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4952 .channel_mode = alc880_2_jack_modes,
4953 .input_mux = &alc880_medion_rim_capture_source,
4954 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004955 .setup = alc880_medion_rim_setup,
4956 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004957 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004958#ifdef CONFIG_SND_DEBUG
4959 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004960 .mixers = { alc880_test_mixer },
4961 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004962 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4963 .dac_nids = alc880_test_dac_nids,
4964 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004965 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4966 .channel_mode = alc880_test_modes,
4967 .input_mux = &alc880_test_capture_source,
4968 },
4969#endif
4970};
4971
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004972/*
4973 * Automatic parse of I/O pins from the BIOS configuration
4974 */
4975
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004976enum {
4977 ALC_CTL_WIDGET_VOL,
4978 ALC_CTL_WIDGET_MUTE,
4979 ALC_CTL_BIND_MUTE,
4980};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004981static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004982 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4983 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004984 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004985};
4986
4987/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004988static int add_control(struct alc_spec *spec, int type, const char *name,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004989 int cidx, unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004990{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004991 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004992
Takashi Iwai603c4012008-07-30 15:01:44 +02004993 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4994 knew = snd_array_new(&spec->kctls);
4995 if (!knew)
4996 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004997 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004998 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004999 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005000 return -ENOMEM;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005001 knew->index = cidx;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01005002 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01005003 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005004 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005005 return 0;
5006}
5007
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005008static int add_control_with_pfx(struct alc_spec *spec, int type,
5009 const char *pfx, const char *dir,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005010 const char *sfx, int cidx, unsigned long val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005011{
5012 char name[32];
5013 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005014 return add_control(spec, type, name, cidx, val);
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005015}
5016
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005017#define add_pb_vol_ctrl(spec, type, pfx, val) \
5018 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
5019#define add_pb_sw_ctrl(spec, type, pfx, val) \
5020 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
5021#define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
5022 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
5023#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
5024 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005025
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005026#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
5027#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
5028#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
5029#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005030#define alc880_idx_to_dac(nid) ((nid) + 0x02)
5031#define alc880_dac_to_idx(nid) ((nid) - 0x02)
5032#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
5033#define alc880_idx_to_selector(nid) ((nid) + 0x10)
5034#define ALC880_PIN_CD_NID 0x1c
5035
5036/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005037static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
5038 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005039{
5040 hda_nid_t nid;
5041 int assigned[4];
5042 int i, j;
5043
5044 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02005045 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005046
5047 /* check the pins hardwired to audio widget */
5048 for (i = 0; i < cfg->line_outs; i++) {
5049 nid = cfg->line_out_pins[i];
5050 if (alc880_is_fixed_pin(nid)) {
5051 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01005052 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005053 assigned[idx] = 1;
5054 }
5055 }
5056 /* left pins can be connect to any audio widget */
5057 for (i = 0; i < cfg->line_outs; i++) {
5058 nid = cfg->line_out_pins[i];
5059 if (alc880_is_fixed_pin(nid))
5060 continue;
5061 /* search for an empty channel */
5062 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005063 if (!assigned[j]) {
5064 spec->multiout.dac_nids[i] =
5065 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005066 assigned[j] = 1;
5067 break;
5068 }
5069 }
5070 }
5071 spec->multiout.num_dacs = cfg->line_outs;
5072 return 0;
5073}
5074
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005075static const char *alc_get_line_out_pfx(const struct auto_pin_cfg *cfg,
5076 bool can_be_master)
5077{
5078 if (!cfg->hp_outs && !cfg->speaker_outs && can_be_master)
5079 return "Master";
5080
5081 switch (cfg->line_out_type) {
5082 case AUTO_PIN_SPEAKER_OUT:
5083 return "Speaker";
5084 case AUTO_PIN_HP_OUT:
5085 return "Headphone";
5086 default:
5087 if (cfg->line_outs == 1)
5088 return "PCM";
5089 break;
5090 }
5091 return NULL;
5092}
5093
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005094/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01005095static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
5096 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005097{
Takashi Iwaiea734962011-01-17 11:29:34 +01005098 static const char * const chname[4] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005099 "Front", "Surround", NULL /*CLFE*/, "Side"
5100 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005101 const char *pfx = alc_get_line_out_pfx(cfg, false);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005102 hda_nid_t nid;
5103 int i, err;
5104
5105 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005106 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005107 continue;
5108 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005109 if (!pfx && i == 2) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005110 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005111 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5112 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005113 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
5114 HDA_OUTPUT));
5115 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005116 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005117 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5118 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005119 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
5120 HDA_OUTPUT));
5121 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005122 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005123 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5124 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005125 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
5126 HDA_INPUT));
5127 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005128 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005129 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5130 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005131 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
5132 HDA_INPUT));
5133 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005134 return err;
5135 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005136 const char *name = pfx;
5137 if (!name)
5138 name = chname[i];
5139 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5140 name, i,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005141 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
5142 HDA_OUTPUT));
5143 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005144 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005145 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5146 name, i,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005147 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
5148 HDA_INPUT));
5149 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005150 return err;
5151 }
5152 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005153 return 0;
5154}
5155
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005156/* add playback controls for speaker and HP outputs */
5157static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
5158 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005159{
5160 hda_nid_t nid;
5161 int err;
5162
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005163 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005164 return 0;
5165
5166 if (alc880_is_fixed_pin(pin)) {
5167 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01005168 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005169 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005170 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005171 else
5172 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005173 /* control HP volume/switch on the output mixer amp */
5174 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005175 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005176 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
5177 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005178 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005179 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005180 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
5181 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005182 return err;
5183 } else if (alc880_is_multi_pin(pin)) {
5184 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005185 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005186 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005187 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
5188 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005189 return err;
5190 }
5191 return 0;
5192}
5193
5194/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005195static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005196 const char *ctlname, int ctlidx,
Kailang Yangdf694da2005-12-05 19:42:22 +01005197 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005198{
Kailang Yangdf694da2005-12-05 19:42:22 +01005199 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005200
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005201 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005202 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5203 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005204 return err;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005205 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005206 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5207 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005208 return err;
5209 return 0;
5210}
5211
Takashi Iwai05f5f472009-08-25 13:10:18 +02005212static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005213{
Takashi Iwai05f5f472009-08-25 13:10:18 +02005214 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
5215 return (pincap & AC_PINCAP_IN) != 0;
5216}
5217
5218/* create playback/capture controls for input pins */
5219static int alc_auto_create_input_ctls(struct hda_codec *codec,
5220 const struct auto_pin_cfg *cfg,
5221 hda_nid_t mixer,
5222 hda_nid_t cap1, hda_nid_t cap2)
5223{
5224 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005225 struct hda_input_mux *imux = &spec->private_imux[0];
David Henningsson5322bf22011-01-05 11:03:56 +01005226 int i, err, idx, type_idx = 0;
5227 const char *prev_label = NULL;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005228
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005229 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02005230 hda_nid_t pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005231 const char *label;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005232
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005233 pin = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005234 if (!alc_is_input_pin(codec, pin))
5235 continue;
5236
David Henningsson5322bf22011-01-05 11:03:56 +01005237 label = hda_get_autocfg_input_label(codec, cfg, i);
5238 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005239 type_idx++;
5240 else
5241 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +01005242 prev_label = label;
5243
Takashi Iwai05f5f472009-08-25 13:10:18 +02005244 if (mixer) {
5245 idx = get_connection_index(codec, mixer, pin);
5246 if (idx >= 0) {
5247 err = new_analog_input(spec, pin,
Takashi Iwai10a20af2010-09-09 16:28:02 +02005248 label, type_idx,
5249 idx, mixer);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005250 if (err < 0)
5251 return err;
5252 }
5253 }
5254
5255 if (!cap1)
5256 continue;
5257 idx = get_connection_index(codec, cap1, pin);
5258 if (idx < 0 && cap2)
5259 idx = get_connection_index(codec, cap2, pin);
Takashi Iwai10a20af2010-09-09 16:28:02 +02005260 if (idx >= 0)
5261 snd_hda_add_imux_item(imux, label, idx, NULL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005262 }
5263 return 0;
5264}
5265
Takashi Iwai05f5f472009-08-25 13:10:18 +02005266static int alc880_auto_create_input_ctls(struct hda_codec *codec,
5267 const struct auto_pin_cfg *cfg)
5268{
5269 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
5270}
5271
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005272static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
5273 unsigned int pin_type)
5274{
5275 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5276 pin_type);
5277 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01005278 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5279 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005280}
5281
Kailang Yangdf694da2005-12-05 19:42:22 +01005282static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
5283 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005284 int dac_idx)
5285{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005286 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005287 /* need the manual connection? */
5288 if (alc880_is_multi_pin(nid)) {
5289 struct alc_spec *spec = codec->spec;
5290 int idx = alc880_multi_pin_idx(nid);
5291 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
5292 AC_VERB_SET_CONNECT_SEL,
5293 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
5294 }
5295}
5296
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005297static int get_pin_type(int line_out_type)
5298{
5299 if (line_out_type == AUTO_PIN_HP_OUT)
5300 return PIN_HP;
5301 else
5302 return PIN_OUT;
5303}
5304
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005305static void alc880_auto_init_multi_out(struct hda_codec *codec)
5306{
5307 struct alc_spec *spec = codec->spec;
5308 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005309
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005310 for (i = 0; i < spec->autocfg.line_outs; i++) {
5311 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005312 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5313 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005314 }
5315}
5316
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005317static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005318{
5319 struct alc_spec *spec = codec->spec;
5320 hda_nid_t pin;
5321
Takashi Iwai82bc9552006-03-21 11:24:42 +01005322 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005323 if (pin) /* connect to front */
5324 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005325 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005326 if (pin) /* connect to front */
5327 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5328}
5329
5330static void alc880_auto_init_analog_input(struct hda_codec *codec)
5331{
5332 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005333 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005334 int i;
5335
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005336 for (i = 0; i < cfg->num_inputs; i++) {
5337 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005338 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02005339 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005340 if (nid != ALC880_PIN_CD_NID &&
5341 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005342 snd_hda_codec_write(codec, nid, 0,
5343 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005344 AMP_OUT_MUTE);
5345 }
5346 }
5347}
5348
Takashi Iwai7f311a42010-04-09 17:32:23 +02005349static void alc880_auto_init_input_src(struct hda_codec *codec)
5350{
5351 struct alc_spec *spec = codec->spec;
5352 int c;
5353
5354 for (c = 0; c < spec->num_adc_nids; c++) {
5355 unsigned int mux_idx;
5356 const struct hda_input_mux *imux;
5357 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5358 imux = &spec->input_mux[mux_idx];
5359 if (!imux->num_items && mux_idx > 0)
5360 imux = &spec->input_mux[0];
5361 if (imux)
5362 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5363 AC_VERB_SET_CONNECT_SEL,
5364 imux->items[0].index);
5365 }
5366}
5367
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005368/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005369/* return 1 if successful, 0 if the proper config is not found,
5370 * or a negative error code
5371 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005372static int alc880_parse_auto_config(struct hda_codec *codec)
5373{
5374 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005375 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005376 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005377
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005378 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5379 alc880_ignore);
5380 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005381 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005382 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005383 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005384
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005385 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5386 if (err < 0)
5387 return err;
5388 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5389 if (err < 0)
5390 return err;
5391 err = alc880_auto_create_extra_out(spec,
5392 spec->autocfg.speaker_pins[0],
5393 "Speaker");
5394 if (err < 0)
5395 return err;
5396 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5397 "Headphone");
5398 if (err < 0)
5399 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005400 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005401 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005402 return err;
5403
5404 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5405
Takashi Iwai757899a2010-07-30 10:48:14 +02005406 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005407
Takashi Iwai603c4012008-07-30 15:01:44 +02005408 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005409 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005410
Takashi Iwaid88897e2008-10-31 15:01:37 +01005411 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005412
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005413 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005414 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005415
Kailang Yang6227cdc2010-02-25 08:36:52 +01005416 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005417
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005418 return 1;
5419}
5420
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005421/* additional initialization for auto-configuration model */
5422static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005423{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005424 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005425 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005426 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005427 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005428 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005429 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005430 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005431 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005432}
5433
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005434/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5435 * one of two digital mic pins, e.g. on ALC272
5436 */
5437static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005438{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005439 struct alc_spec *spec = codec->spec;
5440 int i;
5441
5442 for (i = 0; i < spec->num_adc_nids; i++) {
5443 hda_nid_t cap = spec->capsrc_nids ?
5444 spec->capsrc_nids[i] : spec->adc_nids[i];
5445 int iidx, eidx;
5446
5447 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5448 if (iidx < 0)
5449 continue;
5450 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5451 if (eidx < 0)
5452 continue;
5453 spec->int_mic.mux_idx = iidx;
5454 spec->ext_mic.mux_idx = eidx;
5455 if (spec->capsrc_nids)
5456 spec->capsrc_nids += i;
5457 spec->adc_nids += i;
5458 spec->num_adc_nids = 1;
5459 return;
5460 }
5461 snd_printd(KERN_INFO "hda_codec: %s: "
5462 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5463 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5464 spec->auto_mic = 0; /* disable auto-mic to be sure */
5465}
5466
Takashi Iwai748cce42010-08-04 07:37:39 +02005467/* select or unmute the given capsrc route */
5468static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5469 int idx)
5470{
5471 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5472 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5473 HDA_AMP_MUTE, 0);
5474 } else {
5475 snd_hda_codec_write_cache(codec, cap, 0,
5476 AC_VERB_SET_CONNECT_SEL, idx);
5477 }
5478}
5479
Takashi Iwai840b64c2010-07-13 22:49:01 +02005480/* set the default connection to that pin */
5481static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5482{
5483 struct alc_spec *spec = codec->spec;
5484 int i;
5485
5486 for (i = 0; i < spec->num_adc_nids; i++) {
5487 hda_nid_t cap = spec->capsrc_nids ?
5488 spec->capsrc_nids[i] : spec->adc_nids[i];
5489 int idx;
5490
5491 idx = get_connection_index(codec, cap, pin);
5492 if (idx < 0)
5493 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005494 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005495 return i; /* return the found index */
5496 }
5497 return -1; /* not found */
5498}
5499
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005500/* choose the ADC/MUX containing the input pin and initialize the setup */
5501static void fixup_single_adc(struct hda_codec *codec)
5502{
5503 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005504 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005505 int i;
5506
5507 /* search for the input pin; there must be only one */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005508 if (cfg->num_inputs != 1)
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005509 return;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005510 i = init_capsrc_for_pin(codec, cfg->inputs[0].pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005511 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005512 /* use only this ADC */
5513 if (spec->capsrc_nids)
5514 spec->capsrc_nids += i;
5515 spec->adc_nids += i;
5516 spec->num_adc_nids = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005517 }
5518}
5519
Takashi Iwai840b64c2010-07-13 22:49:01 +02005520/* initialize dual adcs */
5521static void fixup_dual_adc_switch(struct hda_codec *codec)
5522{
5523 struct alc_spec *spec = codec->spec;
5524 init_capsrc_for_pin(codec, spec->ext_mic.pin);
5525 init_capsrc_for_pin(codec, spec->int_mic.pin);
5526}
5527
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005528static void set_capture_mixer(struct hda_codec *codec)
5529{
5530 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005531 static struct snd_kcontrol_new *caps[2][3] = {
5532 { alc_capture_mixer_nosrc1,
5533 alc_capture_mixer_nosrc2,
5534 alc_capture_mixer_nosrc3 },
5535 { alc_capture_mixer1,
5536 alc_capture_mixer2,
5537 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005538 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005539 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005540 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005541 int num_adcs = spec->num_adc_nids;
5542 if (spec->dual_adc_switch)
5543 fixup_dual_adc_switch(codec);
5544 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005545 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005546 else if (spec->input_mux) {
5547 if (spec->input_mux->num_items > 1)
5548 mux = 1;
5549 else if (spec->input_mux->num_items == 1)
5550 fixup_single_adc(codec);
5551 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005552 if (spec->dual_adc_switch)
5553 num_adcs = 1;
5554 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005555 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005556}
5557
Takashi Iwai66946352010-03-29 17:21:45 +02005558/* fill adc_nids (and capsrc_nids) containing all active input pins */
5559static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5560 int num_nids)
5561{
5562 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005563 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai66946352010-03-29 17:21:45 +02005564 int n;
5565 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5566
5567 for (n = 0; n < num_nids; n++) {
5568 hda_nid_t adc, cap;
5569 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5570 int nconns, i, j;
5571
5572 adc = nids[n];
5573 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5574 continue;
5575 cap = adc;
5576 nconns = snd_hda_get_connections(codec, cap, conn,
5577 ARRAY_SIZE(conn));
5578 if (nconns == 1) {
5579 cap = conn[0];
5580 nconns = snd_hda_get_connections(codec, cap, conn,
5581 ARRAY_SIZE(conn));
5582 }
5583 if (nconns <= 0)
5584 continue;
5585 if (!fallback_adc) {
5586 fallback_adc = adc;
5587 fallback_cap = cap;
5588 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005589 for (i = 0; i < cfg->num_inputs; i++) {
5590 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai66946352010-03-29 17:21:45 +02005591 for (j = 0; j < nconns; j++) {
5592 if (conn[j] == nid)
5593 break;
5594 }
5595 if (j >= nconns)
5596 break;
5597 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005598 if (i >= cfg->num_inputs) {
Takashi Iwai66946352010-03-29 17:21:45 +02005599 int num_adcs = spec->num_adc_nids;
5600 spec->private_adc_nids[num_adcs] = adc;
5601 spec->private_capsrc_nids[num_adcs] = cap;
5602 spec->num_adc_nids++;
5603 spec->adc_nids = spec->private_adc_nids;
5604 if (adc != cap)
5605 spec->capsrc_nids = spec->private_capsrc_nids;
5606 }
5607 }
5608 if (!spec->num_adc_nids) {
5609 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005610 " using fallback 0x%x\n",
5611 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005612 spec->private_adc_nids[0] = fallback_adc;
5613 spec->adc_nids = spec->private_adc_nids;
5614 if (fallback_adc != fallback_cap) {
5615 spec->private_capsrc_nids[0] = fallback_cap;
5616 spec->capsrc_nids = spec->private_adc_nids;
5617 }
5618 }
5619}
5620
Takashi Iwai67d634c2009-11-16 15:35:59 +01005621#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005622#define set_beep_amp(spec, nid, idx, dir) \
5623 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005624
5625static struct snd_pci_quirk beep_white_list[] = {
5626 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005627 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005628 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005629 {}
5630};
5631
5632static inline int has_cdefine_beep(struct hda_codec *codec)
5633{
5634 struct alc_spec *spec = codec->spec;
5635 const struct snd_pci_quirk *q;
5636 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5637 if (q)
5638 return q->value;
5639 return spec->cdefine.enable_pcbeep;
5640}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005641#else
5642#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005643#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005644#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005645
5646/*
5647 * OK, here we have finally the patch for ALC880
5648 */
5649
Linus Torvalds1da177e2005-04-16 15:20:36 -07005650static int patch_alc880(struct hda_codec *codec)
5651{
5652 struct alc_spec *spec;
5653 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005654 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005655
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005656 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005657 if (spec == NULL)
5658 return -ENOMEM;
5659
5660 codec->spec = spec;
5661
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005662 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5663 alc880_models,
5664 alc880_cfg_tbl);
5665 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005666 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5667 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005668 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005669 }
5670
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005671 if (board_config == ALC880_AUTO) {
5672 /* automatic parse from the BIOS config */
5673 err = alc880_parse_auto_config(codec);
5674 if (err < 0) {
5675 alc_free(codec);
5676 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005677 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005678 printk(KERN_INFO
5679 "hda_codec: Cannot set up configuration "
5680 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005681 board_config = ALC880_3ST;
5682 }
5683 }
5684
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005685 err = snd_hda_attach_beep_device(codec, 0x1);
5686 if (err < 0) {
5687 alc_free(codec);
5688 return err;
5689 }
5690
Kailang Yangdf694da2005-12-05 19:42:22 +01005691 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005692 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005693
Linus Torvalds1da177e2005-04-16 15:20:36 -07005694 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5695 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005696 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005697
Linus Torvalds1da177e2005-04-16 15:20:36 -07005698 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5699 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5700
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005701 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005702 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005703 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005704 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005705 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005706 if (wcap != AC_WID_AUD_IN) {
5707 spec->adc_nids = alc880_adc_nids_alt;
5708 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005709 } else {
5710 spec->adc_nids = alc880_adc_nids;
5711 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005712 }
5713 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005714 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005715 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005716
Takashi Iwai2134ea42008-01-10 16:53:55 +01005717 spec->vmaster_nid = 0x0c;
5718
Linus Torvalds1da177e2005-04-16 15:20:36 -07005719 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005720 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005721 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005722#ifdef CONFIG_SND_HDA_POWER_SAVE
5723 if (!spec->loopback.amplist)
5724 spec->loopback.amplist = alc880_loopbacks;
5725#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005726
5727 return 0;
5728}
5729
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005730
Linus Torvalds1da177e2005-04-16 15:20:36 -07005731/*
5732 * ALC260 support
5733 */
5734
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005735static hda_nid_t alc260_dac_nids[1] = {
5736 /* front */
5737 0x02,
5738};
5739
5740static hda_nid_t alc260_adc_nids[1] = {
5741 /* ADC0 */
5742 0x04,
5743};
5744
Kailang Yangdf694da2005-12-05 19:42:22 +01005745static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005746 /* ADC1 */
5747 0x05,
5748};
5749
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005750/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5751 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5752 */
5753static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005754 /* ADC0, ADC1 */
5755 0x04, 0x05
5756};
5757
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005758#define ALC260_DIGOUT_NID 0x03
5759#define ALC260_DIGIN_NID 0x06
5760
5761static struct hda_input_mux alc260_capture_source = {
5762 .num_items = 4,
5763 .items = {
5764 { "Mic", 0x0 },
5765 { "Front Mic", 0x1 },
5766 { "Line", 0x2 },
5767 { "CD", 0x4 },
5768 },
5769};
5770
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005771/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005772 * headphone jack and the internal CD lines since these are the only pins at
5773 * which audio can appear. For flexibility, also allow the option of
5774 * recording the mixer output on the second ADC (ADC0 doesn't have a
5775 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005776 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005777static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5778 {
5779 .num_items = 3,
5780 .items = {
5781 { "Mic/Line", 0x0 },
5782 { "CD", 0x4 },
5783 { "Headphone", 0x2 },
5784 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005785 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005786 {
5787 .num_items = 4,
5788 .items = {
5789 { "Mic/Line", 0x0 },
5790 { "CD", 0x4 },
5791 { "Headphone", 0x2 },
5792 { "Mixer", 0x5 },
5793 },
5794 },
5795
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005796};
5797
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005798/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5799 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005800 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005801static struct hda_input_mux alc260_acer_capture_sources[2] = {
5802 {
5803 .num_items = 4,
5804 .items = {
5805 { "Mic", 0x0 },
5806 { "Line", 0x2 },
5807 { "CD", 0x4 },
5808 { "Headphone", 0x5 },
5809 },
5810 },
5811 {
5812 .num_items = 5,
5813 .items = {
5814 { "Mic", 0x0 },
5815 { "Line", 0x2 },
5816 { "CD", 0x4 },
5817 { "Headphone", 0x6 },
5818 { "Mixer", 0x5 },
5819 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005820 },
5821};
Michael Schwingencc959482009-02-22 18:58:45 +01005822
5823/* Maxdata Favorit 100XS */
5824static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5825 {
5826 .num_items = 2,
5827 .items = {
5828 { "Line/Mic", 0x0 },
5829 { "CD", 0x4 },
5830 },
5831 },
5832 {
5833 .num_items = 3,
5834 .items = {
5835 { "Line/Mic", 0x0 },
5836 { "CD", 0x4 },
5837 { "Mixer", 0x5 },
5838 },
5839 },
5840};
5841
Linus Torvalds1da177e2005-04-16 15:20:36 -07005842/*
5843 * This is just place-holder, so there's something for alc_build_pcms to look
5844 * at when it calculates the maximum number of channels. ALC260 has no mixer
5845 * element which allows changing the channel mode, so the verb list is
5846 * never used.
5847 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005848static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005849 { 2, NULL },
5850};
5851
Kailang Yangdf694da2005-12-05 19:42:22 +01005852
5853/* Mixer combinations
5854 *
5855 * basic: base_output + input + pc_beep + capture
5856 * HP: base_output + input + capture_alt
5857 * HP_3013: hp_3013 + input + capture
5858 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005859 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005860 */
5861
5862static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005863 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005864 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005865 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5866 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5867 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5868 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5869 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005870};
Kailang Yangdf694da2005-12-05 19:42:22 +01005871
5872static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005873 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5874 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5875 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5876 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5877 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5878 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5879 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5880 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005881 { } /* end */
5882};
5883
Takashi Iwaibec15c32008-01-28 18:16:30 +01005884/* update HP, line and mono out pins according to the master switch */
5885static void alc260_hp_master_update(struct hda_codec *codec,
5886 hda_nid_t hp, hda_nid_t line,
5887 hda_nid_t mono)
5888{
5889 struct alc_spec *spec = codec->spec;
5890 unsigned int val = spec->master_sw ? PIN_HP : 0;
5891 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005892 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005893 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005894 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005895 val);
5896 /* mono (speaker) depending on the HP jack sense */
5897 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005898 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005899 val);
5900}
5901
5902static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5903 struct snd_ctl_elem_value *ucontrol)
5904{
5905 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5906 struct alc_spec *spec = codec->spec;
5907 *ucontrol->value.integer.value = spec->master_sw;
5908 return 0;
5909}
5910
5911static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5912 struct snd_ctl_elem_value *ucontrol)
5913{
5914 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5915 struct alc_spec *spec = codec->spec;
5916 int val = !!*ucontrol->value.integer.value;
5917 hda_nid_t hp, line, mono;
5918
5919 if (val == spec->master_sw)
5920 return 0;
5921 spec->master_sw = val;
5922 hp = (kcontrol->private_value >> 16) & 0xff;
5923 line = (kcontrol->private_value >> 8) & 0xff;
5924 mono = kcontrol->private_value & 0xff;
5925 alc260_hp_master_update(codec, hp, line, mono);
5926 return 1;
5927}
5928
5929static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5930 {
5931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5932 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005933 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005934 .info = snd_ctl_boolean_mono_info,
5935 .get = alc260_hp_master_sw_get,
5936 .put = alc260_hp_master_sw_put,
5937 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5938 },
5939 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5940 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5941 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5942 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5943 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5944 HDA_OUTPUT),
5945 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5946 { } /* end */
5947};
5948
5949static struct hda_verb alc260_hp_unsol_verbs[] = {
5950 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5951 {},
5952};
5953
5954static void alc260_hp_automute(struct hda_codec *codec)
5955{
5956 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005957
Wu Fengguang864f92b2009-11-18 12:38:02 +08005958 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005959 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5960}
5961
5962static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5963{
5964 if ((res >> 26) == ALC880_HP_EVENT)
5965 alc260_hp_automute(codec);
5966}
5967
Kailang Yangdf694da2005-12-05 19:42:22 +01005968static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005969 {
5970 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5971 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005972 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005973 .info = snd_ctl_boolean_mono_info,
5974 .get = alc260_hp_master_sw_get,
5975 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005976 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005977 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005978 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5979 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5980 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5981 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5982 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5983 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005984 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5985 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005986 { } /* end */
5987};
5988
Kailang Yang3f878302008-08-26 13:02:23 +02005989static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5990 .ops = &snd_hda_bind_vol,
5991 .values = {
5992 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5993 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5994 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5995 0
5996 },
5997};
5998
5999static struct hda_bind_ctls alc260_dc7600_bind_switch = {
6000 .ops = &snd_hda_bind_sw,
6001 .values = {
6002 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
6003 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
6004 0
6005 },
6006};
6007
6008static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
6009 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
6010 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
6011 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
6012 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
6013 { } /* end */
6014};
6015
Takashi Iwaibec15c32008-01-28 18:16:30 +01006016static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
6017 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6018 {},
6019};
6020
6021static void alc260_hp_3013_automute(struct hda_codec *codec)
6022{
6023 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006024
Wu Fengguang864f92b2009-11-18 12:38:02 +08006025 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01006026 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01006027}
6028
6029static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
6030 unsigned int res)
6031{
6032 if ((res >> 26) == ALC880_HP_EVENT)
6033 alc260_hp_3013_automute(codec);
6034}
6035
Kailang Yang3f878302008-08-26 13:02:23 +02006036static void alc260_hp_3012_automute(struct hda_codec *codec)
6037{
Wu Fengguang864f92b2009-11-18 12:38:02 +08006038 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02006039
Kailang Yang3f878302008-08-26 13:02:23 +02006040 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6041 bits);
6042 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6043 bits);
6044 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6045 bits);
6046}
6047
6048static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
6049 unsigned int res)
6050{
6051 if ((res >> 26) == ALC880_HP_EVENT)
6052 alc260_hp_3012_automute(codec);
6053}
6054
6055/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006056 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
6057 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006058static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006059 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006060 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006061 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006062 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6063 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6064 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
6065 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006066 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006067 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6068 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006069 { } /* end */
6070};
6071
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006072/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
6073 * versions of the ALC260 don't act on requests to enable mic bias from NID
6074 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
6075 * datasheet doesn't mention this restriction. At this stage it's not clear
6076 * whether this behaviour is intentional or is a hardware bug in chip
6077 * revisions available in early 2006. Therefore for now allow the
6078 * "Headphone Jack Mode" control to span all choices, but if it turns out
6079 * that the lack of mic bias for this NID is intentional we could change the
6080 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6081 *
6082 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
6083 * don't appear to make the mic bias available from the "line" jack, even
6084 * though the NID used for this jack (0x14) can supply it. The theory is
6085 * that perhaps Acer have included blocking capacitors between the ALC260
6086 * and the output jack. If this turns out to be the case for all such
6087 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
6088 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01006089 *
6090 * The C20x Tablet series have a mono internal speaker which is controlled
6091 * via the chip's Mono sum widget and pin complex, so include the necessary
6092 * controls for such models. On models without a "mono speaker" the control
6093 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006094 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006095static struct snd_kcontrol_new alc260_acer_mixer[] = {
6096 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6097 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006098 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006099 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01006100 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006101 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01006102 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006103 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6104 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6105 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6106 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6107 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6108 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6109 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6110 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006111 { } /* end */
6112};
6113
Michael Schwingencc959482009-02-22 18:58:45 +01006114/* Maxdata Favorit 100XS: one output and one input (0x12) jack
6115 */
6116static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
6117 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6118 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
6119 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
6120 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6121 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6122 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6123 { } /* end */
6124};
6125
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006126/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
6127 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
6128 */
6129static struct snd_kcontrol_new alc260_will_mixer[] = {
6130 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6131 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6132 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6133 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6134 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6135 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6136 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6137 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6138 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6139 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006140 { } /* end */
6141};
6142
6143/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
6144 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
6145 */
6146static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
6147 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6148 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6149 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6150 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6151 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6152 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
6153 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
6154 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6155 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6156 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6157 { } /* end */
6158};
6159
Kailang Yangdf694da2005-12-05 19:42:22 +01006160/*
6161 * initialization verbs
6162 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006163static struct hda_verb alc260_init_verbs[] = {
6164 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006165 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006166 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006167 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006168 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006169 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006170 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006171 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006172 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02006173 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006174 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01006175 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006176 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02006177 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006178 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02006179 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006180 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02006181 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6182 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02006183 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006184 /* set connection select to line in (default select for this ADC) */
6185 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02006186 /* mute capture amp left and right */
6187 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6188 /* set connection select to line in (default select for this ADC) */
6189 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02006190 /* set vol=0 Line-Out mixer amp left and right */
6191 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6192 /* unmute pin widget amp left and right (no gain on this amp) */
6193 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6194 /* set vol=0 HP mixer amp left and right */
6195 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6196 /* unmute pin widget amp left and right (no gain on this amp) */
6197 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6198 /* set vol=0 Mono mixer amp left and right */
6199 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6200 /* unmute pin widget amp left and right (no gain on this amp) */
6201 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6202 /* unmute LINE-2 out pin */
6203 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006204 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6205 * Line In 2 = 0x03
6206 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006207 /* mute analog inputs */
6208 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6209 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6210 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6211 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6212 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006213 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006214 /* mute Front out path */
6215 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6216 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6217 /* mute Headphone out path */
6218 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6219 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6220 /* mute Mono out path */
6221 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6222 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006223 { }
6224};
6225
Takashi Iwai474167d2006-05-17 17:17:43 +02006226#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01006227static struct hda_verb alc260_hp_init_verbs[] = {
6228 /* Headphone and output */
6229 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6230 /* mono output */
6231 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6232 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6233 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6234 /* Mic2 (front panel) pin widget for input and vref at 80% */
6235 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6236 /* Line In pin widget for input */
6237 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6238 /* Line-2 pin widget for output */
6239 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6240 /* CD pin widget for input */
6241 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6242 /* unmute amp left and right */
6243 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6244 /* set connection select to line in (default select for this ADC) */
6245 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6246 /* unmute Line-Out mixer amp left and right (volume = 0) */
6247 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6248 /* mute pin widget amp left and right (no gain on this amp) */
6249 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6250 /* unmute HP mixer amp left and right (volume = 0) */
6251 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6252 /* mute pin widget amp left and right (no gain on this amp) */
6253 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006254 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6255 * Line In 2 = 0x03
6256 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006257 /* mute analog inputs */
6258 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6259 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6260 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6261 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6262 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006263 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6264 /* Unmute Front out path */
6265 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6266 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6267 /* Unmute Headphone out path */
6268 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6269 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6270 /* Unmute Mono out path */
6271 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6272 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6273 { }
6274};
Takashi Iwai474167d2006-05-17 17:17:43 +02006275#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006276
6277static struct hda_verb alc260_hp_3013_init_verbs[] = {
6278 /* Line out and output */
6279 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6280 /* mono output */
6281 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6282 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6283 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6284 /* Mic2 (front panel) pin widget for input and vref at 80% */
6285 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6286 /* Line In pin widget for input */
6287 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6288 /* Headphone pin widget for output */
6289 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6290 /* CD pin widget for input */
6291 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6292 /* unmute amp left and right */
6293 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6294 /* set connection select to line in (default select for this ADC) */
6295 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6296 /* unmute Line-Out mixer amp left and right (volume = 0) */
6297 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6298 /* mute pin widget amp left and right (no gain on this amp) */
6299 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6300 /* unmute HP mixer amp left and right (volume = 0) */
6301 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6302 /* mute pin widget amp left and right (no gain on this amp) */
6303 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006304 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6305 * Line In 2 = 0x03
6306 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006307 /* mute analog inputs */
6308 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6309 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6310 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6311 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6312 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006313 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6314 /* Unmute Front out path */
6315 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6316 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6317 /* Unmute Headphone out path */
6318 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6319 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6320 /* Unmute Mono out path */
6321 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6322 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6323 { }
6324};
6325
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006326/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006327 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6328 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006329 */
6330static struct hda_verb alc260_fujitsu_init_verbs[] = {
6331 /* Disable all GPIOs */
6332 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6333 /* Internal speaker is connected to headphone pin */
6334 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6335 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6336 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006337 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6338 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6339 /* Ensure all other unused pins are disabled and muted. */
6340 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6341 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006342 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006343 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006344 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006345 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6346 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6347 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006348
Jonathan Woithef7ace402006-02-28 11:46:14 +01006349 /* Disable digital (SPDIF) pins */
6350 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6351 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006352
Kailang Yangea1fb292008-08-26 12:58:38 +02006353 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006354 * when acting as an output.
6355 */
6356 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6357
6358 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006359 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6360 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6361 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6362 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6363 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6364 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6365 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6366 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6367 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006368
Jonathan Woithef7ace402006-02-28 11:46:14 +01006369 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6370 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6371 /* Unmute Line1 pin widget output buffer since it starts as an output.
6372 * If the pin mode is changed by the user the pin mode control will
6373 * take care of enabling the pin's input/output buffers as needed.
6374 * Therefore there's no need to enable the input buffer at this
6375 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006376 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006377 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006378 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006379 * mixer ctrl)
6380 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006381 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006382
Jonathan Woithef7ace402006-02-28 11:46:14 +01006383 /* Mute capture amp left and right */
6384 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006385 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006386 * in (on mic1 pin)
6387 */
6388 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006389
Jonathan Woithef7ace402006-02-28 11:46:14 +01006390 /* Do the same for the second ADC: mute capture input amp and
6391 * set ADC connection to line in (on mic1 pin)
6392 */
6393 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6394 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006395
Jonathan Woithef7ace402006-02-28 11:46:14 +01006396 /* Mute all inputs to mixer widget (even unconnected ones) */
6397 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6398 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6399 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6400 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6401 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6402 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6403 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6404 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006405
6406 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006407};
6408
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006409/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6410 * similar laptops (adapted from Fujitsu init verbs).
6411 */
6412static struct hda_verb alc260_acer_init_verbs[] = {
6413 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6414 * the headphone jack. Turn this on and rely on the standard mute
6415 * methods whenever the user wants to turn these outputs off.
6416 */
6417 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6418 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6419 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6420 /* Internal speaker/Headphone jack is connected to Line-out pin */
6421 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6422 /* Internal microphone/Mic jack is connected to Mic1 pin */
6423 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6424 /* Line In jack is connected to Line1 pin */
6425 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006426 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6427 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006428 /* Ensure all other unused pins are disabled and muted. */
6429 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6430 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006431 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6432 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6433 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6434 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6435 /* Disable digital (SPDIF) pins */
6436 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6437 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6438
Kailang Yangea1fb292008-08-26 12:58:38 +02006439 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006440 * bus when acting as outputs.
6441 */
6442 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6443 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6444
6445 /* Start with output sum widgets muted and their output gains at min */
6446 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6447 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6448 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6449 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6450 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6451 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6452 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6453 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6454 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6455
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006456 /* Unmute Line-out pin widget amp left and right
6457 * (no equiv mixer ctrl)
6458 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006459 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006460 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6461 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006462 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6463 * inputs. If the pin mode is changed by the user the pin mode control
6464 * will take care of enabling the pin's input/output buffers as needed.
6465 * Therefore there's no need to enable the input buffer at this
6466 * stage.
6467 */
6468 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6469 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6470
6471 /* Mute capture amp left and right */
6472 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6473 /* Set ADC connection select to match default mixer setting - mic
6474 * (on mic1 pin)
6475 */
6476 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6477
6478 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006479 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006480 */
6481 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006482 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006483
6484 /* Mute all inputs to mixer widget (even unconnected ones) */
6485 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6486 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6487 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6488 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6489 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6490 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6491 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6492 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6493
6494 { }
6495};
6496
Michael Schwingencc959482009-02-22 18:58:45 +01006497/* Initialisation sequence for Maxdata Favorit 100XS
6498 * (adapted from Acer init verbs).
6499 */
6500static struct hda_verb alc260_favorit100_init_verbs[] = {
6501 /* GPIO 0 enables the output jack.
6502 * Turn this on and rely on the standard mute
6503 * methods whenever the user wants to turn these outputs off.
6504 */
6505 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6506 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6507 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6508 /* Line/Mic input jack is connected to Mic1 pin */
6509 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6510 /* Ensure all other unused pins are disabled and muted. */
6511 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6512 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6513 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6514 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6515 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6516 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6517 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6518 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6519 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6520 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6521 /* Disable digital (SPDIF) pins */
6522 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6523 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6524
6525 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6526 * bus when acting as outputs.
6527 */
6528 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6529 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6530
6531 /* Start with output sum widgets muted and their output gains at min */
6532 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6533 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6534 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6535 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6536 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6537 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6538 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6539 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6540 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6541
6542 /* Unmute Line-out pin widget amp left and right
6543 * (no equiv mixer ctrl)
6544 */
6545 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6546 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6547 * inputs. If the pin mode is changed by the user the pin mode control
6548 * will take care of enabling the pin's input/output buffers as needed.
6549 * Therefore there's no need to enable the input buffer at this
6550 * stage.
6551 */
6552 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6553
6554 /* Mute capture amp left and right */
6555 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6556 /* Set ADC connection select to match default mixer setting - mic
6557 * (on mic1 pin)
6558 */
6559 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6560
6561 /* Do similar with the second ADC: mute capture input amp and
6562 * set ADC connection to mic to match ALSA's default state.
6563 */
6564 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6565 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6566
6567 /* Mute all inputs to mixer widget (even unconnected ones) */
6568 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6569 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6570 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6571 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6572 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6573 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6574 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6575 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6576
6577 { }
6578};
6579
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006580static struct hda_verb alc260_will_verbs[] = {
6581 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6582 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6583 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6584 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6585 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6586 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6587 {}
6588};
6589
6590static struct hda_verb alc260_replacer_672v_verbs[] = {
6591 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6592 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6593 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6594
6595 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6596 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6597 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6598
6599 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6600 {}
6601};
6602
6603/* toggle speaker-output according to the hp-jack state */
6604static void alc260_replacer_672v_automute(struct hda_codec *codec)
6605{
6606 unsigned int present;
6607
6608 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006609 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006610 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006611 snd_hda_codec_write_cache(codec, 0x01, 0,
6612 AC_VERB_SET_GPIO_DATA, 1);
6613 snd_hda_codec_write_cache(codec, 0x0f, 0,
6614 AC_VERB_SET_PIN_WIDGET_CONTROL,
6615 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006616 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006617 snd_hda_codec_write_cache(codec, 0x01, 0,
6618 AC_VERB_SET_GPIO_DATA, 0);
6619 snd_hda_codec_write_cache(codec, 0x0f, 0,
6620 AC_VERB_SET_PIN_WIDGET_CONTROL,
6621 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006622 }
6623}
6624
6625static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6626 unsigned int res)
6627{
6628 if ((res >> 26) == ALC880_HP_EVENT)
6629 alc260_replacer_672v_automute(codec);
6630}
6631
Kailang Yang3f878302008-08-26 13:02:23 +02006632static struct hda_verb alc260_hp_dc7600_verbs[] = {
6633 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6634 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6635 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6636 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6637 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6638 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6639 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6640 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6641 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6642 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6643 {}
6644};
6645
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006646/* Test configuration for debugging, modelled after the ALC880 test
6647 * configuration.
6648 */
6649#ifdef CONFIG_SND_DEBUG
6650static hda_nid_t alc260_test_dac_nids[1] = {
6651 0x02,
6652};
6653static hda_nid_t alc260_test_adc_nids[2] = {
6654 0x04, 0x05,
6655};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006656/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006657 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006658 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006659 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006660static struct hda_input_mux alc260_test_capture_sources[2] = {
6661 {
6662 .num_items = 7,
6663 .items = {
6664 { "MIC1 pin", 0x0 },
6665 { "MIC2 pin", 0x1 },
6666 { "LINE1 pin", 0x2 },
6667 { "LINE2 pin", 0x3 },
6668 { "CD pin", 0x4 },
6669 { "LINE-OUT pin", 0x5 },
6670 { "HP-OUT pin", 0x6 },
6671 },
6672 },
6673 {
6674 .num_items = 8,
6675 .items = {
6676 { "MIC1 pin", 0x0 },
6677 { "MIC2 pin", 0x1 },
6678 { "LINE1 pin", 0x2 },
6679 { "LINE2 pin", 0x3 },
6680 { "CD pin", 0x4 },
6681 { "Mixer", 0x5 },
6682 { "LINE-OUT pin", 0x6 },
6683 { "HP-OUT pin", 0x7 },
6684 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006685 },
6686};
6687static struct snd_kcontrol_new alc260_test_mixer[] = {
6688 /* Output driver widgets */
6689 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6690 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6691 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6692 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6693 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6694 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6695
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006696 /* Modes for retasking pin widgets
6697 * Note: the ALC260 doesn't seem to act on requests to enable mic
6698 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6699 * mention this restriction. At this stage it's not clear whether
6700 * this behaviour is intentional or is a hardware bug in chip
6701 * revisions available at least up until early 2006. Therefore for
6702 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6703 * choices, but if it turns out that the lack of mic bias for these
6704 * NIDs is intentional we could change their modes from
6705 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6706 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006707 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6708 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6709 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6710 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6711 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6712 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6713
6714 /* Loopback mixer controls */
6715 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6716 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6717 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6718 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6719 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6720 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6721 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6722 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6723 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6724 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006725 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6726 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6727 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6728 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006729
6730 /* Controls for GPIO pins, assuming they are configured as outputs */
6731 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6732 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6733 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6734 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6735
Jonathan Woithe92621f12006-02-28 11:47:47 +01006736 /* Switches to allow the digital IO pins to be enabled. The datasheet
6737 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006738 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006739 */
6740 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6741 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6742
Jonathan Woithef8225f62008-01-08 12:16:54 +01006743 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6744 * this output to turn on an external amplifier.
6745 */
6746 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6747 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6748
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006749 { } /* end */
6750};
6751static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006752 /* Enable all GPIOs as outputs with an initial value of 0 */
6753 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6754 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6755 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6756
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006757 /* Enable retasking pins as output, initially without power amp */
6758 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6759 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6760 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6761 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6762 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6763 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6764
Jonathan Woithe92621f12006-02-28 11:47:47 +01006765 /* Disable digital (SPDIF) pins initially, but users can enable
6766 * them via a mixer switch. In the case of SPDIF-out, this initverb
6767 * payload also sets the generation to 0, output to be in "consumer"
6768 * PCM format, copyright asserted, no pre-emphasis and no validity
6769 * control.
6770 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006771 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6772 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6773
Kailang Yangea1fb292008-08-26 12:58:38 +02006774 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006775 * OUT1 sum bus when acting as an output.
6776 */
6777 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6778 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6779 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6780 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6781
6782 /* Start with output sum widgets muted and their output gains at min */
6783 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6784 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6785 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6786 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6787 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6788 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6789 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6790 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6791 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6792
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006793 /* Unmute retasking pin widget output buffers since the default
6794 * state appears to be output. As the pin mode is changed by the
6795 * user the pin mode control will take care of enabling the pin's
6796 * input/output buffers as needed.
6797 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006798 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6799 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6800 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6801 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6802 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6803 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6804 /* Also unmute the mono-out pin widget */
6805 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6806
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006807 /* Mute capture amp left and right */
6808 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006809 /* Set ADC connection select to match default mixer setting (mic1
6810 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006811 */
6812 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6813
6814 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006815 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006816 */
6817 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6818 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6819
6820 /* Mute all inputs to mixer widget (even unconnected ones) */
6821 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6822 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6823 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6824 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6825 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6826 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6827 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6828 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6829
6830 { }
6831};
6832#endif
6833
Takashi Iwai63300792008-01-24 15:31:36 +01006834#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6835#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006836
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006837#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6838#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6839
Kailang Yangdf694da2005-12-05 19:42:22 +01006840/*
6841 * for BIOS auto-configuration
6842 */
6843
6844static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006845 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006846{
6847 hda_nid_t nid_vol;
6848 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006849 int err;
6850
6851 if (nid >= 0x0f && nid < 0x11) {
6852 nid_vol = nid - 0x7;
6853 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6854 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6855 } else if (nid == 0x11) {
6856 nid_vol = nid - 0x7;
6857 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6858 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6859 } else if (nid >= 0x12 && nid <= 0x15) {
6860 nid_vol = 0x08;
6861 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6862 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6863 } else
6864 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006865
Takashi Iwai863b4512008-10-21 17:01:47 +02006866 if (!(*vol_bits & (1 << nid_vol))) {
6867 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006868 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006869 if (err < 0)
6870 return err;
6871 *vol_bits |= (1 << nid_vol);
6872 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006873 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006874 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006875 return err;
6876 return 1;
6877}
6878
6879/* add playback controls from the parsed DAC table */
6880static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6881 const struct auto_pin_cfg *cfg)
6882{
6883 hda_nid_t nid;
6884 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006885 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006886
6887 spec->multiout.num_dacs = 1;
6888 spec->multiout.dac_nids = spec->private_dac_nids;
6889 spec->multiout.dac_nids[0] = 0x02;
6890
6891 nid = cfg->line_out_pins[0];
6892 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006893 const char *pfx;
6894 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6895 pfx = "Master";
6896 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6897 pfx = "Speaker";
6898 else
6899 pfx = "Front";
6900 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006901 if (err < 0)
6902 return err;
6903 }
6904
Takashi Iwai82bc9552006-03-21 11:24:42 +01006905 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006906 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006907 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006908 if (err < 0)
6909 return err;
6910 }
6911
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006912 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006913 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006914 err = alc260_add_playback_controls(spec, nid, "Headphone",
6915 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006916 if (err < 0)
6917 return err;
6918 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006919 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006920}
6921
6922/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006923static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006924 const struct auto_pin_cfg *cfg)
6925{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006926 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006927}
6928
6929static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6930 hda_nid_t nid, int pin_type,
6931 int sel_idx)
6932{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006933 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006934 /* need the manual connection? */
6935 if (nid >= 0x12) {
6936 int idx = nid - 0x12;
6937 snd_hda_codec_write(codec, idx + 0x0b, 0,
6938 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006939 }
6940}
6941
6942static void alc260_auto_init_multi_out(struct hda_codec *codec)
6943{
6944 struct alc_spec *spec = codec->spec;
6945 hda_nid_t nid;
6946
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006947 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006948 if (nid) {
6949 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6950 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6951 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006952
Takashi Iwai82bc9552006-03-21 11:24:42 +01006953 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006954 if (nid)
6955 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6956
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006957 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006958 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006959 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006960}
Kailang Yangdf694da2005-12-05 19:42:22 +01006961
6962#define ALC260_PIN_CD_NID 0x16
6963static void alc260_auto_init_analog_input(struct hda_codec *codec)
6964{
6965 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006966 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +01006967 int i;
6968
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006969 for (i = 0; i < cfg->num_inputs; i++) {
6970 hda_nid_t nid = cfg->inputs[i].pin;
Kailang Yangdf694da2005-12-05 19:42:22 +01006971 if (nid >= 0x12) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02006972 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006973 if (nid != ALC260_PIN_CD_NID &&
6974 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006975 snd_hda_codec_write(codec, nid, 0,
6976 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006977 AMP_OUT_MUTE);
6978 }
6979 }
6980}
6981
Takashi Iwai7f311a42010-04-09 17:32:23 +02006982#define alc260_auto_init_input_src alc880_auto_init_input_src
6983
Kailang Yangdf694da2005-12-05 19:42:22 +01006984/*
6985 * generic initialization of ADC, input mixers and output mixers
6986 */
6987static struct hda_verb alc260_volume_init_verbs[] = {
6988 /*
6989 * Unmute ADC0-1 and set the default input to mic-in
6990 */
6991 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6992 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6993 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6994 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006995
Kailang Yangdf694da2005-12-05 19:42:22 +01006996 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6997 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006998 * Note: PASD motherboards uses the Line In 2 as the input for
6999 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007000 */
7001 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007002 /* mute analog inputs */
7003 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7004 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7005 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7006 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7007 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007008
7009 /*
7010 * Set up output mixers (0x08 - 0x0a)
7011 */
7012 /* set vol=0 to output mixers */
7013 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7014 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7015 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7016 /* set up input amps for analog loopback */
7017 /* Amp Indices: DAC = 0, mixer = 1 */
7018 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7019 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7020 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7021 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7022 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7023 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02007024
Kailang Yangdf694da2005-12-05 19:42:22 +01007025 { }
7026};
7027
7028static int alc260_parse_auto_config(struct hda_codec *codec)
7029{
7030 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007031 int err;
7032 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
7033
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007034 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7035 alc260_ignore);
7036 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007037 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007038 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
7039 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01007040 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02007041 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01007042 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02007043 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007044 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007045 return err;
7046
7047 spec->multiout.max_channels = 2;
7048
Takashi Iwai0852d7a2009-02-11 11:35:15 +01007049 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007050 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02007051 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01007052 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01007053
Takashi Iwaid88897e2008-10-31 15:01:37 +01007054 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01007055
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007056 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007057 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007058
Kailang Yang6227cdc2010-02-25 08:36:52 +01007059 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02007060
Kailang Yangdf694da2005-12-05 19:42:22 +01007061 return 1;
7062}
7063
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007064/* additional initialization for auto-configuration model */
7065static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007066{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007067 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007068 alc260_auto_init_multi_out(codec);
7069 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02007070 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02007071 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007072 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007073 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007074}
7075
Takashi Iwaicb53c622007-08-10 17:21:45 +02007076#ifdef CONFIG_SND_HDA_POWER_SAVE
7077static struct hda_amp_list alc260_loopbacks[] = {
7078 { 0x07, HDA_INPUT, 0 },
7079 { 0x07, HDA_INPUT, 1 },
7080 { 0x07, HDA_INPUT, 2 },
7081 { 0x07, HDA_INPUT, 3 },
7082 { 0x07, HDA_INPUT, 4 },
7083 { } /* end */
7084};
7085#endif
7086
Kailang Yangdf694da2005-12-05 19:42:22 +01007087/*
Takashi Iwaifc091762010-08-04 23:53:36 +02007088 * Pin config fixes
7089 */
7090enum {
7091 PINFIX_HP_DC5750,
7092};
7093
Takashi Iwaifc091762010-08-04 23:53:36 +02007094static const struct alc_fixup alc260_fixups[] = {
7095 [PINFIX_HP_DC5750] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007096 .type = ALC_FIXUP_PINS,
7097 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +02007098 { 0x11, 0x90130110 }, /* speaker */
7099 { }
7100 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007101 },
7102};
7103
7104static struct snd_pci_quirk alc260_fixup_tbl[] = {
7105 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
7106 {}
7107};
7108
7109/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007110 * ALC260 configurations
7111 */
Takashi Iwaiea734962011-01-17 11:29:34 +01007112static const char * const alc260_models[ALC260_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007113 [ALC260_BASIC] = "basic",
7114 [ALC260_HP] = "hp",
7115 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02007116 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007117 [ALC260_FUJITSU_S702X] = "fujitsu",
7118 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007119 [ALC260_WILL] = "will",
7120 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01007121 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007122#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007123 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007124#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007125 [ALC260_AUTO] = "auto",
7126};
7127
7128static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01007129 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05007130 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007131 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01007132 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01007133 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01007134 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007135 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02007136 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02007137 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007138 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
7139 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
7140 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
7141 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
7142 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
7143 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
7144 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
7145 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
7146 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007147 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007148 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02007149 {}
7150};
7151
Kailang Yangdf694da2005-12-05 19:42:22 +01007152static struct alc_config_preset alc260_presets[] = {
7153 [ALC260_BASIC] = {
7154 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007155 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007156 .init_verbs = { alc260_init_verbs },
7157 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7158 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007159 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01007160 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007161 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7162 .channel_mode = alc260_modes,
7163 .input_mux = &alc260_capture_source,
7164 },
7165 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01007166 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007167 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007168 .init_verbs = { alc260_init_verbs,
7169 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007170 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7171 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007172 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7173 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007174 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7175 .channel_mode = alc260_modes,
7176 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007177 .unsol_event = alc260_hp_unsol_event,
7178 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007179 },
Kailang Yang3f878302008-08-26 13:02:23 +02007180 [ALC260_HP_DC7600] = {
7181 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007182 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02007183 .init_verbs = { alc260_init_verbs,
7184 alc260_hp_dc7600_verbs },
7185 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7186 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007187 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7188 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02007189 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7190 .channel_mode = alc260_modes,
7191 .input_mux = &alc260_capture_source,
7192 .unsol_event = alc260_hp_3012_unsol_event,
7193 .init_hook = alc260_hp_3012_automute,
7194 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007195 [ALC260_HP_3013] = {
7196 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007197 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007198 .init_verbs = { alc260_hp_3013_init_verbs,
7199 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007200 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7201 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007202 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7203 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007204 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7205 .channel_mode = alc260_modes,
7206 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007207 .unsol_event = alc260_hp_3013_unsol_event,
7208 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007209 },
7210 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007211 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007212 .init_verbs = { alc260_fujitsu_init_verbs },
7213 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7214 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01007215 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7216 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007217 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7218 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007219 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
7220 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01007221 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007222 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007223 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007224 .init_verbs = { alc260_acer_init_verbs },
7225 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7226 .dac_nids = alc260_dac_nids,
7227 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7228 .adc_nids = alc260_dual_adc_nids,
7229 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7230 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007231 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
7232 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007233 },
Michael Schwingencc959482009-02-22 18:58:45 +01007234 [ALC260_FAVORIT100] = {
7235 .mixers = { alc260_favorit100_mixer },
7236 .init_verbs = { alc260_favorit100_init_verbs },
7237 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7238 .dac_nids = alc260_dac_nids,
7239 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7240 .adc_nids = alc260_dual_adc_nids,
7241 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7242 .channel_mode = alc260_modes,
7243 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
7244 .input_mux = alc260_favorit100_capture_sources,
7245 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007246 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007247 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007248 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
7249 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7250 .dac_nids = alc260_dac_nids,
7251 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7252 .adc_nids = alc260_adc_nids,
7253 .dig_out_nid = ALC260_DIGOUT_NID,
7254 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7255 .channel_mode = alc260_modes,
7256 .input_mux = &alc260_capture_source,
7257 },
7258 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007259 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007260 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
7261 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7262 .dac_nids = alc260_dac_nids,
7263 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7264 .adc_nids = alc260_adc_nids,
7265 .dig_out_nid = ALC260_DIGOUT_NID,
7266 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7267 .channel_mode = alc260_modes,
7268 .input_mux = &alc260_capture_source,
7269 .unsol_event = alc260_replacer_672v_unsol_event,
7270 .init_hook = alc260_replacer_672v_automute,
7271 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007272#ifdef CONFIG_SND_DEBUG
7273 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007274 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007275 .init_verbs = { alc260_test_init_verbs },
7276 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
7277 .dac_nids = alc260_test_dac_nids,
7278 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
7279 .adc_nids = alc260_test_adc_nids,
7280 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7281 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007282 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7283 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007284 },
7285#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007286};
7287
Linus Torvalds1da177e2005-04-16 15:20:36 -07007288static int patch_alc260(struct hda_codec *codec)
7289{
7290 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007291 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007292
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007293 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007294 if (spec == NULL)
7295 return -ENOMEM;
7296
7297 codec->spec = spec;
7298
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007299 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7300 alc260_models,
7301 alc260_cfg_tbl);
7302 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007303 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007304 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007305 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007306 }
7307
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007308 if (board_config == ALC260_AUTO) {
7309 alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups);
7310 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
7311 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007312
Kailang Yangdf694da2005-12-05 19:42:22 +01007313 if (board_config == ALC260_AUTO) {
7314 /* automatic parse from the BIOS config */
7315 err = alc260_parse_auto_config(codec);
7316 if (err < 0) {
7317 alc_free(codec);
7318 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007319 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007320 printk(KERN_INFO
7321 "hda_codec: Cannot set up configuration "
7322 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007323 board_config = ALC260_BASIC;
7324 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007325 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007326
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007327 err = snd_hda_attach_beep_device(codec, 0x1);
7328 if (err < 0) {
7329 alc_free(codec);
7330 return err;
7331 }
7332
Kailang Yangdf694da2005-12-05 19:42:22 +01007333 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007334 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007335
Linus Torvalds1da177e2005-04-16 15:20:36 -07007336 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7337 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307338 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007339
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007340 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7341 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7342
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007343 if (!spec->adc_nids && spec->input_mux) {
7344 /* check whether NID 0x04 is valid */
7345 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007346 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007347 /* get type */
7348 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7349 spec->adc_nids = alc260_adc_nids_alt;
7350 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7351 } else {
7352 spec->adc_nids = alc260_adc_nids;
7353 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7354 }
7355 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007356 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007357 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007358
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007359 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaifc091762010-08-04 23:53:36 +02007360
Takashi Iwai2134ea42008-01-10 16:53:55 +01007361 spec->vmaster_nid = 0x08;
7362
Linus Torvalds1da177e2005-04-16 15:20:36 -07007363 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007364 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007365 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007366#ifdef CONFIG_SND_HDA_POWER_SAVE
7367 if (!spec->loopback.amplist)
7368 spec->loopback.amplist = alc260_loopbacks;
7369#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007370
7371 return 0;
7372}
7373
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007374
Linus Torvalds1da177e2005-04-16 15:20:36 -07007375/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007376 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007377 *
7378 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7379 * configuration. Each pin widget can choose any input DACs and a mixer.
7380 * Each ADC is connected from a mixer of all inputs. This makes possible
7381 * 6-channel independent captures.
7382 *
7383 * In addition, an independent DAC for the multi-playback (not used in this
7384 * driver yet).
7385 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007386#define ALC882_DIGOUT_NID 0x06
7387#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007388#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7389#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7390#define ALC1200_DIGOUT_NID 0x10
7391
Linus Torvalds1da177e2005-04-16 15:20:36 -07007392
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007393static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007394 { 8, NULL }
7395};
7396
Takashi Iwai4953550a2009-06-30 15:28:30 +02007397/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007398static hda_nid_t alc882_dac_nids[4] = {
7399 /* front, rear, clfe, rear_surr */
7400 0x02, 0x03, 0x04, 0x05
7401};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007402#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007403
Takashi Iwai4953550a2009-06-30 15:28:30 +02007404/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007405#define alc882_adc_nids alc880_adc_nids
7406#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007407#define alc883_adc_nids alc882_adc_nids_alt
7408static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7409static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7410#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007411
Takashi Iwaie1406342008-02-11 18:32:32 +01007412static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7413static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007414#define alc883_capsrc_nids alc882_capsrc_nids_alt
7415static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7416#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007417
Linus Torvalds1da177e2005-04-16 15:20:36 -07007418/* input MUX */
7419/* FIXME: should be a matrix-type input source selection */
7420
7421static struct hda_input_mux alc882_capture_source = {
7422 .num_items = 4,
7423 .items = {
7424 { "Mic", 0x0 },
7425 { "Front Mic", 0x1 },
7426 { "Line", 0x2 },
7427 { "CD", 0x4 },
7428 },
7429};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007430
Takashi Iwai4953550a2009-06-30 15:28:30 +02007431#define alc883_capture_source alc882_capture_source
7432
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007433static struct hda_input_mux alc889_capture_source = {
7434 .num_items = 3,
7435 .items = {
7436 { "Front Mic", 0x0 },
7437 { "Mic", 0x3 },
7438 { "Line", 0x2 },
7439 },
7440};
7441
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007442static struct hda_input_mux mb5_capture_source = {
7443 .num_items = 3,
7444 .items = {
7445 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307446 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007447 { "CD", 0x4 },
7448 },
7449};
7450
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007451static struct hda_input_mux macmini3_capture_source = {
7452 .num_items = 2,
7453 .items = {
7454 { "Line", 0x2 },
7455 { "CD", 0x4 },
7456 },
7457};
7458
Takashi Iwai4953550a2009-06-30 15:28:30 +02007459static struct hda_input_mux alc883_3stack_6ch_intel = {
7460 .num_items = 4,
7461 .items = {
7462 { "Mic", 0x1 },
7463 { "Front Mic", 0x0 },
7464 { "Line", 0x2 },
7465 { "CD", 0x4 },
7466 },
7467};
7468
7469static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7470 .num_items = 2,
7471 .items = {
7472 { "Mic", 0x1 },
7473 { "Line", 0x2 },
7474 },
7475};
7476
7477static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7478 .num_items = 4,
7479 .items = {
7480 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007481 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007482 { "Line", 0x2 },
7483 { "CD", 0x4 },
7484 },
7485};
7486
7487static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7488 .num_items = 2,
7489 .items = {
7490 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007491 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007492 },
7493};
7494
7495static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7496 .num_items = 3,
7497 .items = {
7498 { "Mic", 0x0 },
7499 { "Front Mic", 0x1 },
7500 { "Line", 0x4 },
7501 },
7502};
7503
7504static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7505 .num_items = 2,
7506 .items = {
7507 { "Mic", 0x0 },
7508 { "Line", 0x2 },
7509 },
7510};
7511
7512static struct hda_input_mux alc889A_mb31_capture_source = {
7513 .num_items = 2,
7514 .items = {
7515 { "Mic", 0x0 },
7516 /* Front Mic (0x01) unused */
7517 { "Line", 0x2 },
7518 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007519 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007520 },
7521};
7522
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007523static struct hda_input_mux alc889A_imac91_capture_source = {
7524 .num_items = 2,
7525 .items = {
7526 { "Mic", 0x01 },
7527 { "Line", 0x2 }, /* Not sure! */
7528 },
7529};
7530
Takashi Iwai4953550a2009-06-30 15:28:30 +02007531/*
7532 * 2ch mode
7533 */
7534static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7535 { 2, NULL }
7536};
7537
Kailang Yangdf694da2005-12-05 19:42:22 +01007538/*
Kailang Yang272a5272007-05-14 11:00:38 +02007539 * 2ch mode
7540 */
7541static struct hda_verb alc882_3ST_ch2_init[] = {
7542 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7543 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7544 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7545 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7546 { } /* end */
7547};
7548
7549/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007550 * 4ch mode
7551 */
7552static struct hda_verb alc882_3ST_ch4_init[] = {
7553 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7554 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7555 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7556 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7557 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7558 { } /* end */
7559};
7560
7561/*
Kailang Yang272a5272007-05-14 11:00:38 +02007562 * 6ch mode
7563 */
7564static struct hda_verb alc882_3ST_ch6_init[] = {
7565 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7566 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7567 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7568 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7569 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7570 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7571 { } /* end */
7572};
7573
Takashi Iwai4953550a2009-06-30 15:28:30 +02007574static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007575 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007576 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007577 { 6, alc882_3ST_ch6_init },
7578};
7579
Takashi Iwai4953550a2009-06-30 15:28:30 +02007580#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7581
Kailang Yang272a5272007-05-14 11:00:38 +02007582/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307583 * 2ch mode
7584 */
7585static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7586 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7587 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7588 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7589 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7590 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7591 { } /* end */
7592};
7593
7594/*
7595 * 4ch mode
7596 */
7597static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7598 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7599 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7600 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7601 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7602 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7603 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7604 { } /* end */
7605};
7606
7607/*
7608 * 6ch mode
7609 */
7610static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7611 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7612 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7613 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7614 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7615 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7616 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7617 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7618 { } /* end */
7619};
7620
7621static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7622 { 2, alc883_3ST_ch2_clevo_init },
7623 { 4, alc883_3ST_ch4_clevo_init },
7624 { 6, alc883_3ST_ch6_clevo_init },
7625};
7626
7627
7628/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007629 * 6ch mode
7630 */
7631static struct hda_verb alc882_sixstack_ch6_init[] = {
7632 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7633 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7634 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7635 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7636 { } /* end */
7637};
7638
7639/*
7640 * 8ch mode
7641 */
7642static struct hda_verb alc882_sixstack_ch8_init[] = {
7643 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7644 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7645 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7646 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7647 { } /* end */
7648};
7649
7650static struct hda_channel_mode alc882_sixstack_modes[2] = {
7651 { 6, alc882_sixstack_ch6_init },
7652 { 8, alc882_sixstack_ch8_init },
7653};
7654
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007655
7656/* Macbook Air 2,1 */
7657
7658static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7659 { 2, NULL },
7660};
7661
Takashi Iwai87350ad2007-08-16 18:19:38 +02007662/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007663 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007664 */
7665
7666/*
7667 * 2ch mode
7668 */
7669static struct hda_verb alc885_mbp_ch2_init[] = {
7670 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7671 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7672 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7673 { } /* end */
7674};
7675
7676/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007677 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007678 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007679static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007680 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7681 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7682 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7683 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7684 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7685 { } /* end */
7686};
7687
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007688static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007689 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007690 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007691};
7692
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007693/*
7694 * 2ch
7695 * Speakers/Woofer/HP = Front
7696 * LineIn = Input
7697 */
7698static struct hda_verb alc885_mb5_ch2_init[] = {
7699 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7700 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7701 { } /* end */
7702};
7703
7704/*
7705 * 6ch mode
7706 * Speakers/HP = Front
7707 * Woofer = LFE
7708 * LineIn = Surround
7709 */
7710static struct hda_verb alc885_mb5_ch6_init[] = {
7711 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7712 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7713 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7714 { } /* end */
7715};
7716
7717static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7718 { 2, alc885_mb5_ch2_init },
7719 { 6, alc885_mb5_ch6_init },
7720};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007721
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007722#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007723
7724/*
7725 * 2ch mode
7726 */
7727static struct hda_verb alc883_4ST_ch2_init[] = {
7728 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7729 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7730 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7731 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7732 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7733 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7734 { } /* end */
7735};
7736
7737/*
7738 * 4ch mode
7739 */
7740static struct hda_verb alc883_4ST_ch4_init[] = {
7741 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7742 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7743 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7744 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7745 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7746 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7747 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7748 { } /* end */
7749};
7750
7751/*
7752 * 6ch mode
7753 */
7754static struct hda_verb alc883_4ST_ch6_init[] = {
7755 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7756 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7757 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7758 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7759 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7760 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7761 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7762 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7763 { } /* end */
7764};
7765
7766/*
7767 * 8ch mode
7768 */
7769static struct hda_verb alc883_4ST_ch8_init[] = {
7770 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7771 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7772 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7773 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7774 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7775 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7776 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7777 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7778 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7779 { } /* end */
7780};
7781
7782static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7783 { 2, alc883_4ST_ch2_init },
7784 { 4, alc883_4ST_ch4_init },
7785 { 6, alc883_4ST_ch6_init },
7786 { 8, alc883_4ST_ch8_init },
7787};
7788
7789
7790/*
7791 * 2ch mode
7792 */
7793static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7794 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7795 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7796 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7797 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7798 { } /* end */
7799};
7800
7801/*
7802 * 4ch mode
7803 */
7804static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7805 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7806 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7807 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7808 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7809 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7810 { } /* end */
7811};
7812
7813/*
7814 * 6ch mode
7815 */
7816static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7817 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7818 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7819 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7820 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7821 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7822 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7823 { } /* end */
7824};
7825
7826static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7827 { 2, alc883_3ST_ch2_intel_init },
7828 { 4, alc883_3ST_ch4_intel_init },
7829 { 6, alc883_3ST_ch6_intel_init },
7830};
7831
7832/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007833 * 2ch mode
7834 */
7835static struct hda_verb alc889_ch2_intel_init[] = {
7836 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7837 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7838 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7839 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7840 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7841 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7842 { } /* end */
7843};
7844
7845/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007846 * 6ch mode
7847 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007848static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007849 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7850 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7851 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7852 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7853 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007854 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7855 { } /* end */
7856};
7857
7858/*
7859 * 8ch mode
7860 */
7861static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007862 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7863 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7864 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7865 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7866 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007867 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7868 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007869 { } /* end */
7870};
7871
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007872static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7873 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007874 { 6, alc889_ch6_intel_init },
7875 { 8, alc889_ch8_intel_init },
7876};
7877
7878/*
7879 * 6ch mode
7880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007881static struct hda_verb alc883_sixstack_ch6_init[] = {
7882 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7883 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7884 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7885 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7886 { } /* end */
7887};
7888
7889/*
7890 * 8ch mode
7891 */
7892static struct hda_verb alc883_sixstack_ch8_init[] = {
7893 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7894 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7895 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7896 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7897 { } /* end */
7898};
7899
7900static struct hda_channel_mode alc883_sixstack_modes[2] = {
7901 { 6, alc883_sixstack_ch6_init },
7902 { 8, alc883_sixstack_ch8_init },
7903};
7904
7905
Linus Torvalds1da177e2005-04-16 15:20:36 -07007906/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7907 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7908 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007909static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007910 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007911 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007912 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007913 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007914 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7915 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007916 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7917 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007918 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007919 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007920 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7921 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7922 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7923 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7924 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7925 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007926 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007927 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7928 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007929 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007930 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007931 { } /* end */
7932};
7933
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007934/* Macbook Air 2,1 same control for HP and internal Speaker */
7935
7936static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7937 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7938 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7939 { }
7940};
7941
7942
Takashi Iwai87350ad2007-08-16 18:19:38 +02007943static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007944 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7945 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7946 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7947 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7948 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007949 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7950 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007951 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7952 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007953 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
7954 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007955 { } /* end */
7956};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007957
7958static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007959 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7960 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7961 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7962 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7963 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7964 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307965 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7966 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09307967 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7968 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7970 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007971 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
7972 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0x00, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007973 { } /* end */
7974};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007975
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007976static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7977 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7978 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7979 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7980 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7981 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7982 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7983 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7984 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7985 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7986 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007987 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007988 { } /* end */
7989};
7990
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007991static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007992 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7993 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007994 { } /* end */
7995};
7996
7997
Kailang Yangbdd148a2007-05-08 15:19:08 +02007998static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7999 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8000 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8001 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8002 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8003 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8004 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8005 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008006 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008007 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008008 { } /* end */
8009};
8010
Kailang Yang272a5272007-05-14 11:00:38 +02008011static struct snd_kcontrol_new alc882_targa_mixer[] = {
8012 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8013 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8014 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8015 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8016 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8017 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8018 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8019 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8020 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008021 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008022 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8023 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008024 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008025 { } /* end */
8026};
8027
8028/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
8029 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
8030 */
8031static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
8032 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8033 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8034 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8035 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8036 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8037 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8038 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8039 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8040 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
8041 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
8042 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8043 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008044 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008045 { } /* end */
8046};
8047
Takashi Iwai914759b2007-09-06 14:52:04 +02008048static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
8049 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8050 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8051 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8052 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8053 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8054 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8055 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8056 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008057 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008058 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008059 { } /* end */
8060};
8061
Kailang Yangdf694da2005-12-05 19:42:22 +01008062static struct snd_kcontrol_new alc882_chmode_mixer[] = {
8063 {
8064 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8065 .name = "Channel Mode",
8066 .info = alc_ch_mode_info,
8067 .get = alc_ch_mode_get,
8068 .put = alc_ch_mode_put,
8069 },
8070 { } /* end */
8071};
8072
Takashi Iwai4953550a2009-06-30 15:28:30 +02008073static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07008074 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008075 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8076 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008077 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008078 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8079 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008080 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008081 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8082 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008083 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008084 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8085 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008086
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008087 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008088 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008089 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008090 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008091 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008092 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008093 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008094 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008095 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008096 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008097 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008098 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008099 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008100 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008101 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008102 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008103 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008104 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008105 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8106 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008107 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008108 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8109 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008110 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008111 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8112 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8113 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8114 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8115 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008116 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008117 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008118
8119 /* FIXME: use matrix-type input source selection */
8120 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008121 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008122 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008123 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008124 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02008125 /* ADC2: mute amp left and right */
8126 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008127 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02008128 /* ADC3: mute amp left and right */
8129 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008130 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008131
8132 { }
8133};
8134
Takashi Iwai4953550a2009-06-30 15:28:30 +02008135static struct hda_verb alc882_adc1_init_verbs[] = {
8136 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8137 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8138 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8139 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8140 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8141 /* ADC1: mute amp left and right */
8142 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8143 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8144 { }
8145};
8146
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008147static struct hda_verb alc882_eapd_verbs[] = {
8148 /* change to EAPD mode */
8149 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008150 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008151 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008152};
8153
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008154static struct hda_verb alc889_eapd_verbs[] = {
8155 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8156 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8157 { }
8158};
8159
Wu Fengguang6732bd02009-07-30 09:19:14 +02008160static struct hda_verb alc_hp15_unsol_verbs[] = {
8161 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8162 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8163 {}
8164};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008165
8166static struct hda_verb alc885_init_verbs[] = {
8167 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01008168 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8169 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008170 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008171 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8172 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008173 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008174 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8175 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008176 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008177 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8178 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008179
8180 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02008181 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008182 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8183 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8184 /* Front Pin: output 0 (0x0c) */
8185 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8186 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8187 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8188 /* Rear Pin: output 1 (0x0d) */
8189 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8190 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8191 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
8192 /* CLFE Pin: output 2 (0x0e) */
8193 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8194 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8195 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8196 /* Side Pin: output 3 (0x0f) */
8197 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8198 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8199 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8200 /* Mic (rear) pin: input vref at 80% */
8201 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8202 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8203 /* Front Mic pin: input vref at 80% */
8204 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8205 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8206 /* Line In pin: input */
8207 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8208 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8209
8210 /* Mixer elements: 0x18, , 0x1a, 0x1b */
8211 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01008212 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008213 /* Input mixer2 */
8214 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008215 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008216 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008217 /* ADC2: mute amp left and right */
8218 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8219 /* ADC3: mute amp left and right */
8220 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8221
8222 { }
8223};
8224
8225static struct hda_verb alc885_init_input_verbs[] = {
8226 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8227 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8228 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8229 { }
8230};
8231
8232
8233/* Unmute Selector 24h and set the default input to front mic */
8234static struct hda_verb alc889_init_input_verbs[] = {
8235 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8236 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8237 { }
8238};
8239
8240
Takashi Iwai4953550a2009-06-30 15:28:30 +02008241#define alc883_init_verbs alc882_base_init_verbs
8242
Tobin Davis9102cd12006-12-15 10:02:12 +01008243/* Mac Pro test */
8244static struct snd_kcontrol_new alc882_macpro_mixer[] = {
8245 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8246 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8247 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
8248 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8249 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008250 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01008251 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
8252 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008253 */
Tobin Davis9102cd12006-12-15 10:02:12 +01008254 { } /* end */
8255};
8256
8257static struct hda_verb alc882_macpro_init_verbs[] = {
8258 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8259 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8260 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8261 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8262 /* Front Pin: output 0 (0x0c) */
8263 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8264 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8265 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8266 /* Front Mic pin: input vref at 80% */
8267 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8268 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8269 /* Speaker: output */
8270 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8271 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8272 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
8273 /* Headphone output (output 0 - 0x0c) */
8274 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8275 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8276 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8277
8278 /* FIXME: use matrix-type input source selection */
8279 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8280 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8281 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8282 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8283 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8284 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8285 /* Input mixer2 */
8286 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8287 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8288 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8289 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8290 /* Input mixer3 */
8291 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8292 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8293 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8294 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8295 /* ADC1: mute amp left and right */
8296 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8297 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8298 /* ADC2: mute amp left and right */
8299 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8300 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8301 /* ADC3: mute amp left and right */
8302 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8303 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8304
8305 { }
8306};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008307
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008308/* Macbook 5,1 */
8309static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008310 /* DACs */
8311 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8312 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8313 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8314 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008315 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008316 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8317 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8318 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008319 /* Surround mixer */
8320 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8321 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8322 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8323 /* LFE mixer */
8324 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8325 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8326 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8327 /* HP mixer */
8328 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8329 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8330 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8331 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008332 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8333 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008334 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8335 /* LFE Pin (0x0e) */
8336 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8337 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8338 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8339 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008340 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8341 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008342 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308343 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008344 /* Front Mic pin: input vref at 80% */
8345 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8346 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8347 /* Line In pin */
8348 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8349 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8350
Alex Murrayb8f171e2010-06-14 12:08:43 +09308351 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8352 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8353 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008354 { }
8355};
8356
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008357/* Macmini 3,1 */
8358static struct hda_verb alc885_macmini3_init_verbs[] = {
8359 /* DACs */
8360 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8361 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8362 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8363 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8364 /* Front mixer */
8365 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8366 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8367 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8368 /* Surround mixer */
8369 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8370 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8371 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8372 /* LFE mixer */
8373 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8374 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8375 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8376 /* HP mixer */
8377 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8378 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8379 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8380 /* Front Pin (0x0c) */
8381 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8382 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8383 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8384 /* LFE Pin (0x0e) */
8385 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8386 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8387 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8388 /* HP Pin (0x0f) */
8389 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8390 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8391 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8392 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8393 /* Line In pin */
8394 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8395 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8396
8397 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8398 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8399 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8400 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8401 { }
8402};
8403
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008404
8405static struct hda_verb alc885_mba21_init_verbs[] = {
8406 /*Internal and HP Speaker Mixer*/
8407 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8408 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8409 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8410 /*Internal Speaker Pin (0x0c)*/
8411 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8412 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8413 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8414 /* HP Pin: output 0 (0x0e) */
8415 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8416 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8417 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8418 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8419 /* Line in (is hp when jack connected)*/
8420 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8421 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8422
8423 { }
8424 };
8425
8426
Takashi Iwai87350ad2007-08-16 18:19:38 +02008427/* Macbook Pro rev3 */
8428static struct hda_verb alc885_mbp3_init_verbs[] = {
8429 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8430 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8431 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8432 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8433 /* Rear mixer */
8434 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8435 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8436 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008437 /* HP mixer */
8438 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8439 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8440 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008441 /* Front Pin: output 0 (0x0c) */
8442 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8443 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8444 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008445 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008446 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008447 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8448 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008449 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8450 /* Mic (rear) pin: input vref at 80% */
8451 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8452 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8453 /* Front Mic pin: input vref at 80% */
8454 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8455 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8456 /* Line In pin: use output 1 when in LineOut mode */
8457 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8458 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8459 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8460
8461 /* FIXME: use matrix-type input source selection */
8462 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8463 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8464 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8465 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8466 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8467 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8468 /* Input mixer2 */
8469 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8470 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8471 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8472 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8473 /* Input mixer3 */
8474 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8475 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8476 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8477 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8478 /* ADC1: mute amp left and right */
8479 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8480 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8481 /* ADC2: mute amp left and right */
8482 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8483 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8484 /* ADC3: mute amp left and right */
8485 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8486 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8487
8488 { }
8489};
8490
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008491/* iMac 9,1 */
8492static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008493 /* Internal Speaker Pin (0x0c) */
8494 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8495 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8496 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8497 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8498 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8499 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8500 /* HP Pin: Rear */
8501 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8502 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8503 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8504 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8505 /* Line in Rear */
8506 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8507 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8508 /* Front Mic pin: input vref at 80% */
8509 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8510 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008511 /* Rear mixer */
8512 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8513 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8514 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008515 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8516 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8517 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8518 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8519 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008520 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8521 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8522 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8523 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008524 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008525 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8526 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8527 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8528 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008529 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008530 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8531 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8532 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8533 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008534 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008535 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8536 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008537 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008538 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8539 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008540 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008541 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8542 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008543 { }
8544};
8545
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008546/* iMac 24 mixer. */
8547static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8548 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8549 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8550 { } /* end */
8551};
8552
8553/* iMac 24 init verbs. */
8554static struct hda_verb alc885_imac24_init_verbs[] = {
8555 /* Internal speakers: output 0 (0x0c) */
8556 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8557 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8558 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8559 /* Internal speakers: output 0 (0x0c) */
8560 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8561 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8562 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8563 /* Headphone: output 0 (0x0c) */
8564 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8565 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8566 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8567 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8568 /* Front Mic: input vref at 80% */
8569 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8570 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8571 { }
8572};
8573
8574/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008575static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008576{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008577 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008578
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008579 spec->autocfg.hp_pins[0] = 0x14;
8580 spec->autocfg.speaker_pins[0] = 0x18;
8581 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008582}
8583
Takashi Iwai9d54f082010-02-22 08:34:40 +01008584#define alc885_mb5_setup alc885_imac24_setup
8585#define alc885_macmini3_setup alc885_imac24_setup
8586
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008587/* Macbook Air 2,1 */
8588static void alc885_mba21_setup(struct hda_codec *codec)
8589{
8590 struct alc_spec *spec = codec->spec;
8591
8592 spec->autocfg.hp_pins[0] = 0x14;
8593 spec->autocfg.speaker_pins[0] = 0x18;
8594}
8595
8596
8597
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008598static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008599{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008600 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008601
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008602 spec->autocfg.hp_pins[0] = 0x15;
8603 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008604}
8605
Takashi Iwai9d54f082010-02-22 08:34:40 +01008606static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308607{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008608 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308609
Takashi Iwai9d54f082010-02-22 08:34:40 +01008610 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008611 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008612 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008613}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008614
Kailang Yang272a5272007-05-14 11:00:38 +02008615static struct hda_verb alc882_targa_verbs[] = {
8616 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8617 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8618
8619 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8620 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008621
Kailang Yang272a5272007-05-14 11:00:38 +02008622 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8623 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8624 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8625
8626 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008627 { } /* end */
8628};
8629
8630/* toggle speaker-output according to the hp-jack state */
8631static void alc882_targa_automute(struct hda_codec *codec)
8632{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008633 struct alc_spec *spec = codec->spec;
8634 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008635 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008636 spec->jack_present ? 1 : 3);
8637}
8638
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008639static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008640{
8641 struct alc_spec *spec = codec->spec;
8642
8643 spec->autocfg.hp_pins[0] = 0x14;
8644 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008645}
8646
8647static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8648{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008649 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008650 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008651}
8652
8653static struct hda_verb alc882_asus_a7j_verbs[] = {
8654 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8655 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8656
8657 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8658 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8659 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008660
Kailang Yang272a5272007-05-14 11:00:38 +02008661 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8662 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8663 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8664
8665 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8666 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8667 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8668 { } /* end */
8669};
8670
Takashi Iwai914759b2007-09-06 14:52:04 +02008671static struct hda_verb alc882_asus_a7m_verbs[] = {
8672 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8673 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8674
8675 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8676 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8677 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008678
Takashi Iwai914759b2007-09-06 14:52:04 +02008679 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8680 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8681 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8682
8683 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8684 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8685 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8686 { } /* end */
8687};
8688
Tobin Davis9102cd12006-12-15 10:02:12 +01008689static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8690{
8691 unsigned int gpiostate, gpiomask, gpiodir;
8692
8693 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8694 AC_VERB_GET_GPIO_DATA, 0);
8695
8696 if (!muted)
8697 gpiostate |= (1 << pin);
8698 else
8699 gpiostate &= ~(1 << pin);
8700
8701 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8702 AC_VERB_GET_GPIO_MASK, 0);
8703 gpiomask |= (1 << pin);
8704
8705 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8706 AC_VERB_GET_GPIO_DIRECTION, 0);
8707 gpiodir |= (1 << pin);
8708
8709
8710 snd_hda_codec_write(codec, codec->afg, 0,
8711 AC_VERB_SET_GPIO_MASK, gpiomask);
8712 snd_hda_codec_write(codec, codec->afg, 0,
8713 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8714
8715 msleep(1);
8716
8717 snd_hda_codec_write(codec, codec->afg, 0,
8718 AC_VERB_SET_GPIO_DATA, gpiostate);
8719}
8720
Takashi Iwai7debbe52007-08-16 15:01:03 +02008721/* set up GPIO at initialization */
8722static void alc885_macpro_init_hook(struct hda_codec *codec)
8723{
8724 alc882_gpio_mute(codec, 0, 0);
8725 alc882_gpio_mute(codec, 1, 0);
8726}
8727
8728/* set up GPIO and update auto-muting at initialization */
8729static void alc885_imac24_init_hook(struct hda_codec *codec)
8730{
8731 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008732 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008733}
8734
Kailang Yangdf694da2005-12-05 19:42:22 +01008735/*
8736 * generic initialization of ADC, input mixers and output mixers
8737 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008738static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008739 /*
8740 * Unmute ADC0-2 and set the default input to mic-in
8741 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008742 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8743 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8744 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8745 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8746
Kailang Yangdf694da2005-12-05 19:42:22 +01008747 /*
8748 * Set up output mixers (0x0c - 0x0f)
8749 */
8750 /* set vol=0 to output mixers */
8751 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8752 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8753 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8754 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8755 /* set up input amps for analog loopback */
8756 /* Amp Indices: DAC = 0, mixer = 1 */
8757 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8758 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8759 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8760 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8761 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8762 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8763 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8764 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8765 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8766 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8767
8768 /* FIXME: use matrix-type input source selection */
8769 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008770 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008771 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008772 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008773 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008774 { }
8775};
8776
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008777/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8778static struct hda_verb alc889A_mb31_ch2_init[] = {
8779 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8780 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8781 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8782 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8783 { } /* end */
8784};
8785
8786/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8787static struct hda_verb alc889A_mb31_ch4_init[] = {
8788 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8789 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8790 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8791 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8792 { } /* end */
8793};
8794
8795/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8796static struct hda_verb alc889A_mb31_ch5_init[] = {
8797 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8798 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8799 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8800 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8801 { } /* end */
8802};
8803
8804/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8805static struct hda_verb alc889A_mb31_ch6_init[] = {
8806 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8807 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8808 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8809 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8810 { } /* end */
8811};
8812
8813static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8814 { 2, alc889A_mb31_ch2_init },
8815 { 4, alc889A_mb31_ch4_init },
8816 { 5, alc889A_mb31_ch5_init },
8817 { 6, alc889A_mb31_ch6_init },
8818};
8819
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008820static struct hda_verb alc883_medion_eapd_verbs[] = {
8821 /* eanable EAPD on medion laptop */
8822 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8823 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8824 { }
8825};
8826
Takashi Iwai4953550a2009-06-30 15:28:30 +02008827#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008828
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008829static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8830 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8831 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8832 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8833 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8834 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8835 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8836 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8837 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008838 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008839 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8840 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008841 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008842 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008843 { } /* end */
8844};
8845
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008846static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008847 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8848 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8849 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8850 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8851 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008852 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008853 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008854 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008855 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008856 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008857 { } /* end */
8858};
8859
Jiang zhefb97dc62008-03-06 11:07:11 +01008860static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8861 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8862 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8863 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8864 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8865 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008866 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008867 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008868 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008869 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008870 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008871 { } /* end */
8872};
8873
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008874static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8875 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8876 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8877 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8878 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8879 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8880 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8881 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8882 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008883 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008884 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8885 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008886 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008887 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008888 { } /* end */
8889};
8890
8891static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8892 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8893 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8894 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8895 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8896 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8897 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8898 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8899 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8900 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8901 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8902 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8903 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8904 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8905 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008906 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008907 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8908 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008909 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008910 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008911 { } /* end */
8912};
8913
Jiang zhe17bba1b2008-06-04 12:11:07 +02008914static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8915 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8916 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8917 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8918 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8919 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8920 HDA_OUTPUT),
8921 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8922 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8923 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8924 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8925 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8926 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8927 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8928 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8929 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008930 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008931 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8932 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008933 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008934 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008935 { } /* end */
8936};
8937
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008938static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8939 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8940 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8941 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8942 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8943 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8944 HDA_OUTPUT),
8945 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8946 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8947 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8948 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8949 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8950 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8951 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8952 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008954 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008955 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8956 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008957 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008958 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8959 { } /* end */
8960};
8961
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008962static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008963 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008964 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008965 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008966 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008967 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8968 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008969 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8970 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008971 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8972 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8973 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8974 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8975 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8976 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008977 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008978 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8979 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008980 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008981 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008982 { } /* end */
8983};
8984
Sasha Alexandrc2592492009-06-16 14:52:54 -04008985static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008986 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008987 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008988 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008989 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008990 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8991 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8992 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8993 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8994 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8995 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8996 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8997 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8998 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8999 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9000 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009001 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009002 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009003 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009004};
Kailang Yangccc656c2006-10-17 12:32:26 +02009005
Sasha Alexandrc2592492009-06-16 14:52:54 -04009006static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009007 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009008 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009009 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009010 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009011 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9012 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9013 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009014 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009015 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009016 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009017 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009018 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009019 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009020};
Kailang Yangccc656c2006-10-17 12:32:26 +02009021
Takashi Iwaib99dba32009-09-17 18:23:00 +02009022static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
9023 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9024 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009025 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009026 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009027 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009028 { } /* end */
9029};
9030
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009031static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
9032 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9033 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009034 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9035 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009036 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9037 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009038 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009039 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009040 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009041};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009042
Kailang Yang272a5272007-05-14 11:00:38 +02009043static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
9044 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9045 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
9046 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9047 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9048 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9049 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9050 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009051 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9052 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02009053 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02009054};
Kailang Yang272a5272007-05-14 11:00:38 +02009055
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009056static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
9057 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9058 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9059 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9060 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
9061 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
9062 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
9063 { } /* end */
9064};
9065
9066static struct hda_verb alc883_medion_wim2160_verbs[] = {
9067 /* Unmute front mixer */
9068 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9069 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9070
9071 /* Set speaker pin to front mixer */
9072 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9073
9074 /* Init headphone pin */
9075 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9076 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9077 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9078 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9079
9080 { } /* end */
9081};
9082
9083/* toggle speaker-output according to the hp-jack state */
9084static void alc883_medion_wim2160_setup(struct hda_codec *codec)
9085{
9086 struct alc_spec *spec = codec->spec;
9087
9088 spec->autocfg.hp_pins[0] = 0x1a;
9089 spec->autocfg.speaker_pins[0] = 0x15;
9090}
9091
Tobin Davis2880a862007-08-07 11:50:26 +02009092static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02009093 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9094 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009095 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009096 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9097 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009098 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009099 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009100 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009101 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02009102};
Tobin Davis2880a862007-08-07 11:50:26 +02009103
Tony Vroond2fd4b02009-06-21 00:40:10 +01009104static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
9105 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009106 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01009107 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9108 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009109 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9110 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9111 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009112 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009113 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9114 { } /* end */
9115};
9116
Kailang Yange2757d52008-08-26 13:17:46 +02009117static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
9118 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9119 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9120 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9121 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
9122 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
9123 0x0d, 1, 0x0, HDA_OUTPUT),
9124 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
9125 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
9126 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
9127 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9128 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009129 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9130 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9131 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9132 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9133 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009134 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009135 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9136 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009137 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009138 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009139 { } /* end */
9140};
9141
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009142static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
9143 /* Output mixers */
9144 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
9145 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
9146 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
9147 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
9148 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
9149 HDA_OUTPUT),
9150 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
9151 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
9152 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
9153 /* Output switches */
9154 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
9155 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
9156 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
9157 /* Boost mixers */
David Henningsson5f99f862011-01-04 15:24:24 +01009158 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
9159 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009160 /* Input mixers */
9161 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
9162 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
9163 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9164 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9165 { } /* end */
9166};
9167
Guido Günther3e1647c2009-06-05 00:47:26 +02009168static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
9169 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9170 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9171 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9172 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009173 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Guido Günther3e1647c2009-06-05 00:47:26 +02009174 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9175 { } /* end */
9176};
9177
Kailang Yange2757d52008-08-26 13:17:46 +02009178static struct hda_bind_ctls alc883_bind_cap_vol = {
9179 .ops = &snd_hda_bind_vol,
9180 .values = {
9181 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9182 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9183 0
9184 },
9185};
9186
9187static struct hda_bind_ctls alc883_bind_cap_switch = {
9188 .ops = &snd_hda_bind_sw,
9189 .values = {
9190 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9191 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9192 0
9193 },
9194};
9195
9196static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
9197 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9198 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9199 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9200 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9201 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9202 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009203 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009204 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009205 { } /* end */
9206};
9207
9208static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009209 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
9210 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
9211 {
9212 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9213 /* .name = "Capture Source", */
9214 .name = "Input Source",
9215 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009216 .info = alc_mux_enum_info,
9217 .get = alc_mux_enum_get,
9218 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02009219 },
9220 { } /* end */
9221};
9222
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009223static struct snd_kcontrol_new alc883_chmode_mixer[] = {
9224 {
9225 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9226 .name = "Channel Mode",
9227 .info = alc_ch_mode_info,
9228 .get = alc_ch_mode_get,
9229 .put = alc_ch_mode_put,
9230 },
9231 { } /* end */
9232};
9233
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009234/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009235static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009236{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009237 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009238
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009239 spec->autocfg.hp_pins[0] = 0x15;
9240 spec->autocfg.speaker_pins[0] = 0x14;
9241 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009242}
9243
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009244static struct hda_verb alc883_mitac_verbs[] = {
9245 /* HP */
9246 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9247 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9248 /* Subwoofer */
9249 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9250 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9251
9252 /* enable unsolicited event */
9253 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9254 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
9255
9256 { } /* end */
9257};
9258
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309259static struct hda_verb alc883_clevo_m540r_verbs[] = {
9260 /* HP */
9261 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9262 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9263 /* Int speaker */
9264 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9265
9266 /* enable unsolicited event */
9267 /*
9268 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9269 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9270 */
9271
9272 { } /* end */
9273};
9274
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009275static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009276 /* HP */
9277 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9278 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9279 /* Int speaker */
9280 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9281 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9282
9283 /* enable unsolicited event */
9284 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009285 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009286
9287 { } /* end */
9288};
9289
Jiang zhefb97dc62008-03-06 11:07:11 +01009290static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9291 /* HP */
9292 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9293 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9294 /* Subwoofer */
9295 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9296 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9297
9298 /* enable unsolicited event */
9299 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9300
9301 { } /* end */
9302};
9303
Sasha Alexandrc2592492009-06-16 14:52:54 -04009304static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009305 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9306 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9307
9308 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9309 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009310
David Heidelberger64a8be72009-06-08 16:15:18 +02009311/* Connect Line-Out side jack (SPDIF) to Side */
9312 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9313 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9314 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9315/* Connect Mic jack to CLFE */
9316 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9317 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9318 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9319/* Connect Line-in jack to Surround */
9320 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9321 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9322 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9323/* Connect HP out jack to Front */
9324 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9325 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9326 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009327
9328 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009329
9330 { } /* end */
9331};
9332
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009333static struct hda_verb alc883_lenovo_101e_verbs[] = {
9334 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9335 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9336 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9337 { } /* end */
9338};
9339
Kailang Yang272a5272007-05-14 11:00:38 +02009340static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9341 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9342 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9343 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9344 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9345 { } /* end */
9346};
9347
9348static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
9349 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9350 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9351 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9352 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9353 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9354 { } /* end */
9355};
9356
Kailang Yang189609a2007-08-20 11:31:23 +02009357static struct hda_verb alc883_haier_w66_verbs[] = {
9358 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9359 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9360
9361 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9362
9363 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9364 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9365 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9366 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9367 { } /* end */
9368};
9369
Kailang Yange2757d52008-08-26 13:17:46 +02009370static struct hda_verb alc888_lenovo_sky_verbs[] = {
9371 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9372 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9373 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9374 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9375 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9376 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9377 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9378 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9379 { } /* end */
9380};
9381
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009382static struct hda_verb alc888_6st_dell_verbs[] = {
9383 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9384 { }
9385};
9386
Guido Günther3e1647c2009-06-05 00:47:26 +02009387static struct hda_verb alc883_vaiott_verbs[] = {
9388 /* HP */
9389 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9390 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9391
9392 /* enable unsolicited event */
9393 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9394
9395 { } /* end */
9396};
9397
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009398static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009399{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009400 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009401
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009402 spec->autocfg.hp_pins[0] = 0x1b;
9403 spec->autocfg.speaker_pins[0] = 0x14;
9404 spec->autocfg.speaker_pins[1] = 0x16;
9405 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009406}
9407
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009408static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009409 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009410 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9411 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009412 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009413 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009414};
9415
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009416/*
9417 * 2ch mode
9418 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009419static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009420 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9421 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9422 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9423 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009424 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009425};
9426
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009427/*
9428 * 4ch mode
9429 */
9430static struct hda_verb alc888_3st_hp_4ch_init[] = {
9431 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9432 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9433 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9434 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9435 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9436 { } /* end */
9437};
9438
9439/*
9440 * 6ch mode
9441 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009442static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009443 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9444 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009445 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009446 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9447 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009448 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9449 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009450};
9451
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009452static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009453 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009454 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009455 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009456};
9457
Kailang Yang272a5272007-05-14 11:00:38 +02009458/* toggle front-jack and RCA according to the hp-jack state */
9459static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9460{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009461 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02009462
Takashi Iwai47fd8302007-08-10 17:11:07 +02009463 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9464 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9465 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9466 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009467}
9468
9469/* toggle RCA according to the front-jack state */
9470static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9471{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009472 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009473
Takashi Iwai47fd8302007-08-10 17:11:07 +02009474 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9475 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009476}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009477
Kailang Yang272a5272007-05-14 11:00:38 +02009478static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9479 unsigned int res)
9480{
9481 if ((res >> 26) == ALC880_HP_EVENT)
9482 alc888_lenovo_ms7195_front_automute(codec);
9483 if ((res >> 26) == ALC880_FRONT_EVENT)
9484 alc888_lenovo_ms7195_rca_automute(codec);
9485}
9486
Kailang Yang272a5272007-05-14 11:00:38 +02009487/* toggle speaker-output according to the hp-jack state */
Takashi Iwaidc4271702010-11-29 07:42:59 +01009488static void alc883_lenovo_nb0763_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009489{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009490 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009491
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009492 spec->autocfg.hp_pins[0] = 0x14;
9493 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009494}
9495
Kailang Yangccc656c2006-10-17 12:32:26 +02009496/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009497#define alc883_targa_init_hook alc882_targa_init_hook
9498#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009499
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009500static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009501{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009502 struct alc_spec *spec = codec->spec;
9503
9504 spec->autocfg.hp_pins[0] = 0x15;
9505 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009506}
9507
9508static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9509{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009510 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01009511 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009512}
9513
9514static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009515 unsigned int res)
9516{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009517 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009518 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01009519 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009520 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009521 default:
9522 alc_automute_amp_unsol_event(codec, res);
9523 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009524 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009525}
9526
Jiang zhefb97dc62008-03-06 11:07:11 +01009527/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009528static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009529{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009530 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009531
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009532 spec->autocfg.hp_pins[0] = 0x14;
9533 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009534}
9535
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009536static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009537{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009538 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009539
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009540 spec->autocfg.hp_pins[0] = 0x1b;
9541 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009542}
9543
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009544static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9545{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009546 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009547
Takashi Iwai47fd8302007-08-10 17:11:07 +02009548 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9549 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009550}
9551
9552static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9553{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009554 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009555
Takashi Iwai47fd8302007-08-10 17:11:07 +02009556 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9557 HDA_AMP_MUTE, bits);
9558 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9559 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009560}
9561
9562static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9563 unsigned int res)
9564{
9565 if ((res >> 26) == ALC880_HP_EVENT)
9566 alc883_lenovo_101e_all_automute(codec);
9567 if ((res >> 26) == ALC880_FRONT_EVENT)
9568 alc883_lenovo_101e_ispeaker_automute(codec);
9569}
9570
Takashi Iwai676a9b52007-08-16 15:23:35 +02009571/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009572static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009573{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009574 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009575
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009576 spec->autocfg.hp_pins[0] = 0x14;
9577 spec->autocfg.speaker_pins[0] = 0x15;
9578 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009579}
9580
Kailang Yangd1a991a2007-08-15 16:21:59 +02009581static struct hda_verb alc883_acer_eapd_verbs[] = {
9582 /* HP Pin: output 0 (0x0c) */
9583 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9584 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9585 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9586 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009587 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9588 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009589 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009590 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9591 /* eanable EAPD on medion laptop */
9592 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9593 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009594 /* enable unsolicited event */
9595 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009596 { }
9597};
9598
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009599static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009600{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009601 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009602
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009603 spec->autocfg.hp_pins[0] = 0x1b;
9604 spec->autocfg.speaker_pins[0] = 0x14;
9605 spec->autocfg.speaker_pins[1] = 0x15;
9606 spec->autocfg.speaker_pins[2] = 0x16;
9607 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009608}
9609
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009610static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009611{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009612 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009613
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009614 spec->autocfg.hp_pins[0] = 0x1b;
9615 spec->autocfg.speaker_pins[0] = 0x14;
9616 spec->autocfg.speaker_pins[1] = 0x15;
9617 spec->autocfg.speaker_pins[2] = 0x16;
9618 spec->autocfg.speaker_pins[3] = 0x17;
9619 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009620}
9621
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009622static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009623{
9624 struct alc_spec *spec = codec->spec;
9625
9626 spec->autocfg.hp_pins[0] = 0x15;
9627 spec->autocfg.speaker_pins[0] = 0x14;
9628 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009629}
9630
Kailang Yange2757d52008-08-26 13:17:46 +02009631static struct hda_verb alc888_asus_m90v_verbs[] = {
9632 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9633 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9634 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9635 /* enable unsolicited event */
9636 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9637 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9638 { } /* end */
9639};
9640
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009641static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009642{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009643 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009644
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009645 spec->autocfg.hp_pins[0] = 0x1b;
9646 spec->autocfg.speaker_pins[0] = 0x14;
9647 spec->autocfg.speaker_pins[1] = 0x15;
9648 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009649 spec->ext_mic.pin = 0x18;
9650 spec->int_mic.pin = 0x19;
9651 spec->ext_mic.mux_idx = 0;
9652 spec->int_mic.mux_idx = 1;
9653 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009654}
9655
9656static struct hda_verb alc888_asus_eee1601_verbs[] = {
9657 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9658 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9659 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9660 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9661 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9662 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9663 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9664 /* enable unsolicited event */
9665 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9666 { } /* end */
9667};
9668
Kailang Yange2757d52008-08-26 13:17:46 +02009669static void alc883_eee1601_inithook(struct hda_codec *codec)
9670{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009671 struct alc_spec *spec = codec->spec;
9672
9673 spec->autocfg.hp_pins[0] = 0x14;
9674 spec->autocfg.speaker_pins[0] = 0x1b;
9675 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009676}
9677
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009678static struct hda_verb alc889A_mb31_verbs[] = {
9679 /* Init rear pin (used as headphone output) */
9680 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9681 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9682 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9683 /* Init line pin (used as output in 4ch and 6ch mode) */
9684 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9685 /* Init line 2 pin (used as headphone out by default) */
9686 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9687 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9688 { } /* end */
9689};
9690
9691/* Mute speakers according to the headphone jack state */
9692static void alc889A_mb31_automute(struct hda_codec *codec)
9693{
9694 unsigned int present;
9695
9696 /* Mute only in 2ch or 4ch mode */
9697 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9698 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009699 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009700 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9701 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9702 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9703 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9704 }
9705}
9706
9707static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9708{
9709 if ((res >> 26) == ALC880_HP_EVENT)
9710 alc889A_mb31_automute(codec);
9711}
9712
Takashi Iwai4953550a2009-06-30 15:28:30 +02009713
Takashi Iwaicb53c622007-08-10 17:21:45 +02009714#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009715#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009716#endif
9717
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009718/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009719#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9720#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9721#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9722#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9723
9724static hda_nid_t alc883_slave_dig_outs[] = {
9725 ALC1200_DIGOUT_NID, 0,
9726};
9727
9728static hda_nid_t alc1200_slave_dig_outs[] = {
9729 ALC883_DIGOUT_NID, 0,
9730};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009731
9732/*
9733 * configuration and preset
9734 */
Takashi Iwaiea734962011-01-17 11:29:34 +01009735static const char * const alc882_models[ALC882_MODEL_LAST] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009736 [ALC882_3ST_DIG] = "3stack-dig",
9737 [ALC882_6ST_DIG] = "6stack-dig",
9738 [ALC882_ARIMA] = "arima",
9739 [ALC882_W2JC] = "w2jc",
9740 [ALC882_TARGA] = "targa",
9741 [ALC882_ASUS_A7J] = "asus-a7j",
9742 [ALC882_ASUS_A7M] = "asus-a7m",
9743 [ALC885_MACPRO] = "macpro",
9744 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009745 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009746 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009747 [ALC885_MBP3] = "mbp3",
9748 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009749 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009750 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009751 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9752 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009753 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009754 [ALC883_TARGA_DIG] = "targa-dig",
9755 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009756 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009757 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009758 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009759 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009760 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009761 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009762 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009763 [ALC883_MEDION] = "medion",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009764 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009765 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009766 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009767 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9768 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009769 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009770 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009771 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009772 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009773 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309774 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009775 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009776 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009777 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009778 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009779 [ALC889A_INTEL] = "intel-alc889a",
9780 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009781 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009782 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009783 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009784 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009785};
9786
Takashi Iwai4953550a2009-06-30 15:28:30 +02009787static struct snd_pci_quirk alc882_cfg_tbl[] = {
9788 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9789
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009790 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009791 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009792 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009793 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9794 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009795 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009796 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9797 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009798 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009799 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009800 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9801 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009802 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9803 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009804 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9805 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009806 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009807 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009808 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009809 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009810 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9811 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009812 /* default Acer -- disabled as it causes more problems.
9813 * model=auto should work fine now
9814 */
9815 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009816
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009817 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009818
Tobin Davisfebe3372007-06-12 11:27:46 +02009819 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009820 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9821 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009822 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009823 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009824 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009825
9826 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9827 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9828 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009829 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009830 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9831 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9832 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009833 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009834 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009835 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009836 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009837
9838 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009839 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009840 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009841 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009842 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9843 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009844 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009845 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009846 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9847
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009848 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9849 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9850 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009851 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009852 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009853 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009854 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009855 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009856 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9857 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9858 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9859 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9860 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9861 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009862 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009863 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9864 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9865 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009866 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009867 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009868 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9869 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009870 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009871 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009872 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009873 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009874 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009875 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009876 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009877 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009878 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009879
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009880 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009881 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009882 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9883 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309884 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009885 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009886 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009887 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009888 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009889 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009890 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009891 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009892 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009893 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009894 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009895 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9896 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009897 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Takashi Iwai959973b2008-11-05 11:30:56 +01009898 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009899 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009900 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009901
Jiang zhe17bba1b2008-06-04 12:11:07 +02009902 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9903 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009904 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009905 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9906 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9907 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009908 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009909
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009910 {}
9911};
9912
Takashi Iwai4953550a2009-06-30 15:28:30 +02009913/* codec SSID table for Intel Mac */
9914static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9915 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9916 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9917 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9918 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9919 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9920 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9921 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009922 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009923 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009924 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009925 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009926 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9927 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9928 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009929 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009930 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +10009931 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009932 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9933 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009934 */
9935 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009936 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009937 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009938 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009939};
9940
Takashi Iwai4953550a2009-06-30 15:28:30 +02009941static struct alc_config_preset alc882_presets[] = {
9942 [ALC882_3ST_DIG] = {
9943 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009944 .init_verbs = { alc882_base_init_verbs,
9945 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009946 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9947 .dac_nids = alc882_dac_nids,
9948 .dig_out_nid = ALC882_DIGOUT_NID,
9949 .dig_in_nid = ALC882_DIGIN_NID,
9950 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9951 .channel_mode = alc882_ch_modes,
9952 .need_dac_fix = 1,
9953 .input_mux = &alc882_capture_source,
9954 },
9955 [ALC882_6ST_DIG] = {
9956 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009957 .init_verbs = { alc882_base_init_verbs,
9958 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009959 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9960 .dac_nids = alc882_dac_nids,
9961 .dig_out_nid = ALC882_DIGOUT_NID,
9962 .dig_in_nid = ALC882_DIGIN_NID,
9963 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9964 .channel_mode = alc882_sixstack_modes,
9965 .input_mux = &alc882_capture_source,
9966 },
9967 [ALC882_ARIMA] = {
9968 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009969 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9970 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009971 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9972 .dac_nids = alc882_dac_nids,
9973 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9974 .channel_mode = alc882_sixstack_modes,
9975 .input_mux = &alc882_capture_source,
9976 },
9977 [ALC882_W2JC] = {
9978 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009979 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9980 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009981 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9982 .dac_nids = alc882_dac_nids,
9983 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9984 .channel_mode = alc880_threestack_modes,
9985 .need_dac_fix = 1,
9986 .input_mux = &alc882_capture_source,
9987 .dig_out_nid = ALC882_DIGOUT_NID,
9988 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009989 [ALC885_MBA21] = {
9990 .mixers = { alc885_mba21_mixer },
9991 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9992 .num_dacs = 2,
9993 .dac_nids = alc882_dac_nids,
9994 .channel_mode = alc885_mba21_ch_modes,
9995 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9996 .input_mux = &alc882_capture_source,
9997 .unsol_event = alc_automute_amp_unsol_event,
9998 .setup = alc885_mba21_setup,
9999 .init_hook = alc_automute_amp,
10000 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010001 [ALC885_MBP3] = {
10002 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
10003 .init_verbs = { alc885_mbp3_init_verbs,
10004 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010005 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010006 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010007 .hp_nid = 0x04,
10008 .channel_mode = alc885_mbp_4ch_modes,
10009 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010010 .input_mux = &alc882_capture_source,
10011 .dig_out_nid = ALC882_DIGOUT_NID,
10012 .dig_in_nid = ALC882_DIGIN_NID,
10013 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010014 .setup = alc885_mbp3_setup,
10015 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010016 },
10017 [ALC885_MB5] = {
10018 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
10019 .init_verbs = { alc885_mb5_init_verbs,
10020 alc880_gpio1_init_verbs },
10021 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10022 .dac_nids = alc882_dac_nids,
10023 .channel_mode = alc885_mb5_6ch_modes,
10024 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
10025 .input_mux = &mb5_capture_source,
10026 .dig_out_nid = ALC882_DIGOUT_NID,
10027 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010028 .unsol_event = alc_automute_amp_unsol_event,
10029 .setup = alc885_mb5_setup,
10030 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010031 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010032 [ALC885_MACMINI3] = {
10033 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
10034 .init_verbs = { alc885_macmini3_init_verbs,
10035 alc880_gpio1_init_verbs },
10036 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10037 .dac_nids = alc882_dac_nids,
10038 .channel_mode = alc885_macmini3_6ch_modes,
10039 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
10040 .input_mux = &macmini3_capture_source,
10041 .dig_out_nid = ALC882_DIGOUT_NID,
10042 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010043 .unsol_event = alc_automute_amp_unsol_event,
10044 .setup = alc885_macmini3_setup,
10045 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010046 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010047 [ALC885_MACPRO] = {
10048 .mixers = { alc882_macpro_mixer },
10049 .init_verbs = { alc882_macpro_init_verbs },
10050 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10051 .dac_nids = alc882_dac_nids,
10052 .dig_out_nid = ALC882_DIGOUT_NID,
10053 .dig_in_nid = ALC882_DIGIN_NID,
10054 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10055 .channel_mode = alc882_ch_modes,
10056 .input_mux = &alc882_capture_source,
10057 .init_hook = alc885_macpro_init_hook,
10058 },
10059 [ALC885_IMAC24] = {
10060 .mixers = { alc885_imac24_mixer },
10061 .init_verbs = { alc885_imac24_init_verbs },
10062 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10063 .dac_nids = alc882_dac_nids,
10064 .dig_out_nid = ALC882_DIGOUT_NID,
10065 .dig_in_nid = ALC882_DIGIN_NID,
10066 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10067 .channel_mode = alc882_ch_modes,
10068 .input_mux = &alc882_capture_source,
10069 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010070 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010071 .init_hook = alc885_imac24_init_hook,
10072 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010073 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010074 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010075 .init_verbs = { alc885_imac91_init_verbs,
10076 alc880_gpio1_init_verbs },
10077 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10078 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010079 .channel_mode = alc885_mba21_ch_modes,
10080 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10081 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010082 .dig_out_nid = ALC882_DIGOUT_NID,
10083 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010084 .unsol_event = alc_automute_amp_unsol_event,
10085 .setup = alc885_imac91_setup,
10086 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010087 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010088 [ALC882_TARGA] = {
10089 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010090 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +020010091 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010092 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10093 .dac_nids = alc882_dac_nids,
10094 .dig_out_nid = ALC882_DIGOUT_NID,
10095 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10096 .adc_nids = alc882_adc_nids,
10097 .capsrc_nids = alc882_capsrc_nids,
10098 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10099 .channel_mode = alc882_3ST_6ch_modes,
10100 .need_dac_fix = 1,
10101 .input_mux = &alc882_capture_source,
10102 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010103 .setup = alc882_targa_setup,
10104 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010105 },
10106 [ALC882_ASUS_A7J] = {
10107 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010108 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10109 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010110 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10111 .dac_nids = alc882_dac_nids,
10112 .dig_out_nid = ALC882_DIGOUT_NID,
10113 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10114 .adc_nids = alc882_adc_nids,
10115 .capsrc_nids = alc882_capsrc_nids,
10116 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10117 .channel_mode = alc882_3ST_6ch_modes,
10118 .need_dac_fix = 1,
10119 .input_mux = &alc882_capture_source,
10120 },
10121 [ALC882_ASUS_A7M] = {
10122 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010123 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10124 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010125 alc882_asus_a7m_verbs },
10126 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10127 .dac_nids = alc882_dac_nids,
10128 .dig_out_nid = ALC882_DIGOUT_NID,
10129 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10130 .channel_mode = alc880_threestack_modes,
10131 .need_dac_fix = 1,
10132 .input_mux = &alc882_capture_source,
10133 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010134 [ALC883_3ST_2ch_DIG] = {
10135 .mixers = { alc883_3ST_2ch_mixer },
10136 .init_verbs = { alc883_init_verbs },
10137 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10138 .dac_nids = alc883_dac_nids,
10139 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010140 .dig_in_nid = ALC883_DIGIN_NID,
10141 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10142 .channel_mode = alc883_3ST_2ch_modes,
10143 .input_mux = &alc883_capture_source,
10144 },
10145 [ALC883_3ST_6ch_DIG] = {
10146 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10147 .init_verbs = { alc883_init_verbs },
10148 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10149 .dac_nids = alc883_dac_nids,
10150 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010151 .dig_in_nid = ALC883_DIGIN_NID,
10152 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10153 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010154 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010155 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010156 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010157 [ALC883_3ST_6ch] = {
10158 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10159 .init_verbs = { alc883_init_verbs },
10160 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10161 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010162 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10163 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010164 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010165 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010166 },
Jiang zhe17bba1b2008-06-04 12:11:07 +020010167 [ALC883_3ST_6ch_INTEL] = {
10168 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
10169 .init_verbs = { alc883_init_verbs },
10170 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10171 .dac_nids = alc883_dac_nids,
10172 .dig_out_nid = ALC883_DIGOUT_NID,
10173 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010174 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +020010175 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
10176 .channel_mode = alc883_3ST_6ch_intel_modes,
10177 .need_dac_fix = 1,
10178 .input_mux = &alc883_3stack_6ch_intel,
10179 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010180 [ALC889A_INTEL] = {
10181 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020010182 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
10183 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010184 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10185 .dac_nids = alc883_dac_nids,
10186 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10187 .adc_nids = alc889_adc_nids,
10188 .dig_out_nid = ALC883_DIGOUT_NID,
10189 .dig_in_nid = ALC883_DIGIN_NID,
10190 .slave_dig_outs = alc883_slave_dig_outs,
10191 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10192 .channel_mode = alc889_8ch_intel_modes,
10193 .capsrc_nids = alc889_capsrc_nids,
10194 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010195 .setup = alc889_automute_setup,
10196 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010197 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010198 .need_dac_fix = 1,
10199 },
10200 [ALC889_INTEL] = {
10201 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
10202 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010203 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010204 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10205 .dac_nids = alc883_dac_nids,
10206 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10207 .adc_nids = alc889_adc_nids,
10208 .dig_out_nid = ALC883_DIGOUT_NID,
10209 .dig_in_nid = ALC883_DIGIN_NID,
10210 .slave_dig_outs = alc883_slave_dig_outs,
10211 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10212 .channel_mode = alc889_8ch_intel_modes,
10213 .capsrc_nids = alc889_capsrc_nids,
10214 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010215 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010216 .init_hook = alc889_intel_init_hook,
10217 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010218 .need_dac_fix = 1,
10219 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010220 [ALC883_6ST_DIG] = {
10221 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10222 .init_verbs = { alc883_init_verbs },
10223 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10224 .dac_nids = alc883_dac_nids,
10225 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010226 .dig_in_nid = ALC883_DIGIN_NID,
10227 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10228 .channel_mode = alc883_sixstack_modes,
10229 .input_mux = &alc883_capture_source,
10230 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010231 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010232 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010233 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10234 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010235 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10236 .dac_nids = alc883_dac_nids,
10237 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010238 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10239 .channel_mode = alc883_3ST_6ch_modes,
10240 .need_dac_fix = 1,
10241 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010242 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010243 .setup = alc882_targa_setup,
10244 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010245 },
10246 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010247 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010248 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10249 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010250 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10251 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010252 .adc_nids = alc883_adc_nids_alt,
10253 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010254 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010255 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010256 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10257 .channel_mode = alc883_3ST_2ch_modes,
10258 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010259 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010260 .setup = alc882_targa_setup,
10261 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010262 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010263 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010264 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10265 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010266 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010267 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010268 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10269 .dac_nids = alc883_dac_nids,
10270 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10271 .adc_nids = alc883_adc_nids_rev,
10272 .capsrc_nids = alc883_capsrc_nids_rev,
10273 .dig_out_nid = ALC883_DIGOUT_NID,
10274 .dig_in_nid = ALC883_DIGIN_NID,
10275 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10276 .channel_mode = alc883_4ST_8ch_modes,
10277 .need_dac_fix = 1,
10278 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010279 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010280 .setup = alc882_targa_setup,
10281 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010282 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010283 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010284 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010285 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10286 * and the headphone jack. Turn this on and rely on the
10287 * standard mute methods whenever the user wants to turn
10288 * these outputs off.
10289 */
10290 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10291 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10292 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010293 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10294 .channel_mode = alc883_3ST_2ch_modes,
10295 .input_mux = &alc883_capture_source,
10296 },
Tobin Davis2880a862007-08-07 11:50:26 +020010297 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010298 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010299 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010300 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10301 .dac_nids = alc883_dac_nids,
10302 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010303 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10304 .channel_mode = alc883_3ST_2ch_modes,
10305 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010306 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010307 .setup = alc883_acer_aspire_setup,
10308 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010309 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010310 [ALC888_ACER_ASPIRE_4930G] = {
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +010010311 .mixers = { alc888_acer_aspire_4930g_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010312 alc883_chmode_mixer },
10313 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10314 alc888_acer_aspire_4930g_verbs },
10315 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10316 .dac_nids = alc883_dac_nids,
10317 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10318 .adc_nids = alc883_adc_nids_rev,
10319 .capsrc_nids = alc883_capsrc_nids_rev,
10320 .dig_out_nid = ALC883_DIGOUT_NID,
10321 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10322 .channel_mode = alc883_3ST_6ch_modes,
10323 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010324 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010325 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010326 ARRAY_SIZE(alc888_2_capture_sources),
10327 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010328 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010329 .setup = alc888_acer_aspire_4930g_setup,
10330 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010331 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010332 [ALC888_ACER_ASPIRE_6530G] = {
10333 .mixers = { alc888_acer_aspire_6530_mixer },
10334 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10335 alc888_acer_aspire_6530g_verbs },
10336 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10337 .dac_nids = alc883_dac_nids,
10338 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10339 .adc_nids = alc883_adc_nids_rev,
10340 .capsrc_nids = alc883_capsrc_nids_rev,
10341 .dig_out_nid = ALC883_DIGOUT_NID,
10342 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10343 .channel_mode = alc883_3ST_2ch_modes,
10344 .num_mux_defs =
10345 ARRAY_SIZE(alc888_2_capture_sources),
10346 .input_mux = alc888_acer_aspire_6530_sources,
10347 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010348 .setup = alc888_acer_aspire_6530g_setup,
10349 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010350 },
Hector Martin3b315d72009-06-02 10:54:19 +020010351 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010352 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010353 alc883_chmode_mixer },
10354 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010355 alc889_acer_aspire_8930g_verbs,
10356 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010357 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10358 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010359 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10360 .adc_nids = alc889_adc_nids,
10361 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010362 .dig_out_nid = ALC883_DIGOUT_NID,
10363 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10364 .channel_mode = alc883_3ST_6ch_modes,
10365 .need_dac_fix = 1,
10366 .const_channel_count = 6,
10367 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010368 ARRAY_SIZE(alc889_capture_sources),
10369 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +020010370 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010371 .setup = alc889_acer_aspire_8930g_setup,
10372 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +010010373#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010374 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010375#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010376 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010377 [ALC888_ACER_ASPIRE_7730G] = {
10378 .mixers = { alc883_3ST_6ch_mixer,
10379 alc883_chmode_mixer },
10380 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10381 alc888_acer_aspire_7730G_verbs },
10382 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10383 .dac_nids = alc883_dac_nids,
10384 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10385 .adc_nids = alc883_adc_nids_rev,
10386 .capsrc_nids = alc883_capsrc_nids_rev,
10387 .dig_out_nid = ALC883_DIGOUT_NID,
10388 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10389 .channel_mode = alc883_3ST_6ch_modes,
10390 .need_dac_fix = 1,
10391 .const_channel_count = 6,
10392 .input_mux = &alc883_capture_source,
10393 .unsol_event = alc_automute_amp_unsol_event,
Denis Kuplyakovd9477202010-11-24 06:01:09 +010010394 .setup = alc888_acer_aspire_7730g_setup,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010395 .init_hook = alc_automute_amp,
10396 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010397 [ALC883_MEDION] = {
10398 .mixers = { alc883_fivestack_mixer,
10399 alc883_chmode_mixer },
10400 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010401 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010402 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10403 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010404 .adc_nids = alc883_adc_nids_alt,
10405 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010406 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010407 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10408 .channel_mode = alc883_sixstack_modes,
10409 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010410 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010411 [ALC883_MEDION_WIM2160] = {
10412 .mixers = { alc883_medion_wim2160_mixer },
10413 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10414 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10415 .dac_nids = alc883_dac_nids,
10416 .dig_out_nid = ALC883_DIGOUT_NID,
10417 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10418 .adc_nids = alc883_adc_nids,
10419 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10420 .channel_mode = alc883_3ST_2ch_modes,
10421 .input_mux = &alc883_capture_source,
10422 .unsol_event = alc_automute_amp_unsol_event,
10423 .setup = alc883_medion_wim2160_setup,
10424 .init_hook = alc_automute_amp,
10425 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010426 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010427 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010428 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10429 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10430 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010431 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10432 .channel_mode = alc883_3ST_2ch_modes,
10433 .input_mux = &alc883_capture_source,
10434 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010435 [ALC883_CLEVO_M540R] = {
10436 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10437 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10438 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10439 .dac_nids = alc883_dac_nids,
10440 .dig_out_nid = ALC883_DIGOUT_NID,
10441 .dig_in_nid = ALC883_DIGIN_NID,
10442 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10443 .channel_mode = alc883_3ST_6ch_clevo_modes,
10444 .need_dac_fix = 1,
10445 .input_mux = &alc883_capture_source,
10446 /* This machine has the hardware HP auto-muting, thus
10447 * we need no software mute via unsol event
10448 */
10449 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010450 [ALC883_CLEVO_M720] = {
10451 .mixers = { alc883_clevo_m720_mixer },
10452 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010453 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10454 .dac_nids = alc883_dac_nids,
10455 .dig_out_nid = ALC883_DIGOUT_NID,
10456 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10457 .channel_mode = alc883_3ST_2ch_modes,
10458 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010459 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010460 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010461 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010462 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010463 [ALC883_LENOVO_101E_2ch] = {
10464 .mixers = { alc883_lenovo_101e_2ch_mixer},
10465 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10466 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10467 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010468 .adc_nids = alc883_adc_nids_alt,
10469 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010470 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010471 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10472 .channel_mode = alc883_3ST_2ch_modes,
10473 .input_mux = &alc883_lenovo_101e_capture_source,
10474 .unsol_event = alc883_lenovo_101e_unsol_event,
10475 .init_hook = alc883_lenovo_101e_all_automute,
10476 },
Kailang Yang272a5272007-05-14 11:00:38 +020010477 [ALC883_LENOVO_NB0763] = {
10478 .mixers = { alc883_lenovo_nb0763_mixer },
10479 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10480 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10481 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010482 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10483 .channel_mode = alc883_3ST_2ch_modes,
10484 .need_dac_fix = 1,
10485 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010486 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwaidc4271702010-11-29 07:42:59 +010010487 .setup = alc883_lenovo_nb0763_setup,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010488 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010489 },
10490 [ALC888_LENOVO_MS7195_DIG] = {
10491 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10492 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10493 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10494 .dac_nids = alc883_dac_nids,
10495 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010496 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10497 .channel_mode = alc883_3ST_6ch_modes,
10498 .need_dac_fix = 1,
10499 .input_mux = &alc883_capture_source,
10500 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10501 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010502 },
10503 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010504 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010505 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10506 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10507 .dac_nids = alc883_dac_nids,
10508 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010509 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10510 .channel_mode = alc883_3ST_2ch_modes,
10511 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010512 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010513 .setup = alc883_haier_w66_setup,
10514 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010515 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010516 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010517 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010518 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010519 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10520 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010521 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10522 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010523 .need_dac_fix = 1,
10524 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010525 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010526 .setup = alc888_3st_hp_setup,
10527 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010528 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010529 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010530 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010531 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10532 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10533 .dac_nids = alc883_dac_nids,
10534 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010535 .dig_in_nid = ALC883_DIGIN_NID,
10536 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10537 .channel_mode = alc883_sixstack_modes,
10538 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010539 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010540 .setup = alc888_6st_dell_setup,
10541 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010542 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010543 [ALC883_MITAC] = {
10544 .mixers = { alc883_mitac_mixer },
10545 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10546 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10547 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010548 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10549 .channel_mode = alc883_3ST_2ch_modes,
10550 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010551 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010552 .setup = alc883_mitac_setup,
10553 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010554 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010555 [ALC883_FUJITSU_PI2515] = {
10556 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10557 .init_verbs = { alc883_init_verbs,
10558 alc883_2ch_fujitsu_pi2515_verbs},
10559 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10560 .dac_nids = alc883_dac_nids,
10561 .dig_out_nid = ALC883_DIGOUT_NID,
10562 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10563 .channel_mode = alc883_3ST_2ch_modes,
10564 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010565 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010566 .setup = alc883_2ch_fujitsu_pi2515_setup,
10567 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010568 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010569 [ALC888_FUJITSU_XA3530] = {
10570 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10571 .init_verbs = { alc883_init_verbs,
10572 alc888_fujitsu_xa3530_verbs },
10573 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10574 .dac_nids = alc883_dac_nids,
10575 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10576 .adc_nids = alc883_adc_nids_rev,
10577 .capsrc_nids = alc883_capsrc_nids_rev,
10578 .dig_out_nid = ALC883_DIGOUT_NID,
10579 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10580 .channel_mode = alc888_4ST_8ch_intel_modes,
10581 .num_mux_defs =
10582 ARRAY_SIZE(alc888_2_capture_sources),
10583 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010584 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010585 .setup = alc888_fujitsu_xa3530_setup,
10586 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010587 },
Kailang Yange2757d52008-08-26 13:17:46 +020010588 [ALC888_LENOVO_SKY] = {
10589 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10590 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10591 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10592 .dac_nids = alc883_dac_nids,
10593 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010594 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10595 .channel_mode = alc883_sixstack_modes,
10596 .need_dac_fix = 1,
10597 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010598 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010599 .setup = alc888_lenovo_sky_setup,
10600 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010601 },
10602 [ALC888_ASUS_M90V] = {
10603 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10604 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10605 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10606 .dac_nids = alc883_dac_nids,
10607 .dig_out_nid = ALC883_DIGOUT_NID,
10608 .dig_in_nid = ALC883_DIGIN_NID,
10609 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10610 .channel_mode = alc883_3ST_6ch_modes,
10611 .need_dac_fix = 1,
10612 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010613 .unsol_event = alc_sku_unsol_event,
10614 .setup = alc883_mode2_setup,
10615 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010616 },
10617 [ALC888_ASUS_EEE1601] = {
10618 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010619 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010620 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10621 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10622 .dac_nids = alc883_dac_nids,
10623 .dig_out_nid = ALC883_DIGOUT_NID,
10624 .dig_in_nid = ALC883_DIGIN_NID,
10625 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10626 .channel_mode = alc883_3ST_2ch_modes,
10627 .need_dac_fix = 1,
10628 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010629 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010630 .init_hook = alc883_eee1601_inithook,
10631 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010632 [ALC1200_ASUS_P5Q] = {
10633 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10634 .init_verbs = { alc883_init_verbs },
10635 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10636 .dac_nids = alc883_dac_nids,
10637 .dig_out_nid = ALC1200_DIGOUT_NID,
10638 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010639 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010640 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10641 .channel_mode = alc883_sixstack_modes,
10642 .input_mux = &alc883_capture_source,
10643 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010644 [ALC889A_MB31] = {
10645 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10646 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10647 alc880_gpio1_init_verbs },
10648 .adc_nids = alc883_adc_nids,
10649 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010650 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010651 .dac_nids = alc883_dac_nids,
10652 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10653 .channel_mode = alc889A_mb31_6ch_modes,
10654 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10655 .input_mux = &alc889A_mb31_capture_source,
10656 .dig_out_nid = ALC883_DIGOUT_NID,
10657 .unsol_event = alc889A_mb31_unsol_event,
10658 .init_hook = alc889A_mb31_automute,
10659 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010660 [ALC883_SONY_VAIO_TT] = {
10661 .mixers = { alc883_vaiott_mixer },
10662 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10663 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10664 .dac_nids = alc883_dac_nids,
10665 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10666 .channel_mode = alc883_3ST_2ch_modes,
10667 .input_mux = &alc883_capture_source,
10668 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010669 .setup = alc883_vaiott_setup,
10670 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010671 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010672};
10673
10674
10675/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010676 * Pin config fixes
10677 */
10678enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010679 PINFIX_ABIT_AW9D_MAX,
David Henningsson32eea382011-03-04 13:37:50 +010010680 PINFIX_LENOVO_Y530,
Takashi Iwai954a29c2010-07-30 10:55:44 +020010681 PINFIX_PB_M5210,
David Henningssonc3d226a2010-10-14 15:42:08 +020010682 PINFIX_ACER_ASPIRE_7736,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010683};
10684
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010685static const struct alc_fixup alc882_fixups[] = {
10686 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010687 .type = ALC_FIXUP_PINS,
10688 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020010689 { 0x15, 0x01080104 }, /* side */
10690 { 0x16, 0x01011012 }, /* rear */
10691 { 0x17, 0x01016011 }, /* clfe */
10692 { }
10693 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010694 },
David Henningsson32eea382011-03-04 13:37:50 +010010695 [PINFIX_LENOVO_Y530] = {
10696 .type = ALC_FIXUP_PINS,
10697 .v.pins = (const struct alc_pincfg[]) {
10698 { 0x15, 0x99130112 }, /* rear int speakers */
10699 { 0x16, 0x99130111 }, /* subwoofer */
10700 { }
10701 }
10702 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010703 [PINFIX_PB_M5210] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010704 .type = ALC_FIXUP_VERBS,
10705 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020010706 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10707 {}
10708 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020010709 },
David Henningssonc3d226a2010-10-14 15:42:08 +020010710 [PINFIX_ACER_ASPIRE_7736] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010711 .type = ALC_FIXUP_SKU,
10712 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonc3d226a2010-10-14 15:42:08 +020010713 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010714};
10715
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010716static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010717 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
David Henningsson32eea382011-03-04 13:37:50 +010010718 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", PINFIX_LENOVO_Y530),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010719 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
David Henningssonc3d226a2010-10-14 15:42:08 +020010720 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010721 {}
10722};
10723
10724/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010725 * BIOS auto configuration
10726 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010727static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10728 const struct auto_pin_cfg *cfg)
10729{
10730 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10731}
10732
Takashi Iwai4953550a2009-06-30 15:28:30 +020010733static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010734 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010735 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010736{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010737 int idx;
10738
Takashi Iwai489008c2010-04-07 09:06:00 +020010739 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010740 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010741
Takashi Iwai489008c2010-04-07 09:06:00 +020010742 if (dac == 0x25)
10743 idx = 4;
10744 else if (dac >= 0x02 && dac <= 0x05)
10745 idx = dac - 2;
10746 else
10747 return;
10748 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010749}
10750
Takashi Iwai4953550a2009-06-30 15:28:30 +020010751static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010752{
10753 struct alc_spec *spec = codec->spec;
10754 int i;
10755
10756 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010757 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010758 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010759 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010760 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010761 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010762 }
10763}
10764
Takashi Iwai4953550a2009-06-30 15:28:30 +020010765static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010766{
10767 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010768 hda_nid_t pin, dac;
Takashi Iwai5855fb82010-09-16 18:24:02 +020010769 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010770
Takashi Iwai5855fb82010-09-16 18:24:02 +020010771 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
10772 pin = spec->autocfg.hp_pins[i];
10773 if (!pin)
10774 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010775 dac = spec->multiout.hp_nid;
10776 if (!dac)
10777 dac = spec->multiout.dac_nids[0]; /* to front */
10778 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10779 }
Takashi Iwai5855fb82010-09-16 18:24:02 +020010780 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
10781 pin = spec->autocfg.speaker_pins[i];
10782 if (!pin)
10783 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010784 dac = spec->multiout.extra_out_nid[0];
10785 if (!dac)
10786 dac = spec->multiout.dac_nids[0]; /* to front */
10787 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10788 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010789}
10790
Takashi Iwai4953550a2009-06-30 15:28:30 +020010791static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010792{
10793 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010794 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010795 int i;
10796
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010797 for (i = 0; i < cfg->num_inputs; i++) {
10798 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai30ea0982010-09-16 18:47:56 +020010799 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010800 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10801 snd_hda_codec_write(codec, nid, 0,
10802 AC_VERB_SET_AMP_GAIN_MUTE,
10803 AMP_OUT_MUTE);
10804 }
10805}
10806
10807static void alc882_auto_init_input_src(struct hda_codec *codec)
10808{
10809 struct alc_spec *spec = codec->spec;
10810 int c;
10811
10812 for (c = 0; c < spec->num_adc_nids; c++) {
10813 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10814 hda_nid_t nid = spec->capsrc_nids[c];
10815 unsigned int mux_idx;
10816 const struct hda_input_mux *imux;
10817 int conns, mute, idx, item;
10818
10819 conns = snd_hda_get_connections(codec, nid, conn_list,
10820 ARRAY_SIZE(conn_list));
10821 if (conns < 0)
10822 continue;
10823 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10824 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010825 if (!imux->num_items && mux_idx > 0)
10826 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010827 for (idx = 0; idx < conns; idx++) {
10828 /* if the current connection is the selected one,
10829 * unmute it as default - otherwise mute it
10830 */
10831 mute = AMP_IN_MUTE(idx);
10832 for (item = 0; item < imux->num_items; item++) {
10833 if (imux->items[item].index == idx) {
10834 if (spec->cur_mux[c] == item)
10835 mute = AMP_IN_UNMUTE(idx);
10836 break;
10837 }
10838 }
10839 /* check if we have a selector or mixer
10840 * we could check for the widget type instead, but
10841 * just check for Amp-In presence (in case of mixer
10842 * without amp-in there is something wrong, this
10843 * function shouldn't be used or capsrc nid is wrong)
10844 */
10845 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010846 snd_hda_codec_write(codec, nid, 0,
10847 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010848 mute);
10849 else if (mute != AMP_IN_MUTE(idx))
10850 snd_hda_codec_write(codec, nid, 0,
10851 AC_VERB_SET_CONNECT_SEL,
10852 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010853 }
10854 }
10855}
10856
Takashi Iwai4953550a2009-06-30 15:28:30 +020010857/* add mic boosts if needed */
10858static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010859{
10860 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010861 struct auto_pin_cfg *cfg = &spec->autocfg;
David Henningsson5322bf22011-01-05 11:03:56 +010010862 int i, err;
Takashi Iwai53e8c322010-12-17 15:23:41 +010010863 int type_idx = 0;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010864 hda_nid_t nid;
David Henningsson5322bf22011-01-05 11:03:56 +010010865 const char *prev_label = NULL;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010866
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010867 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020010868 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010869 break;
10870 nid = cfg->inputs[i].pin;
10871 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
David Henningsson5322bf22011-01-05 11:03:56 +010010872 const char *label;
10873 char boost_label[32];
10874
10875 label = hda_get_autocfg_input_label(codec, cfg, i);
10876 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai53e8c322010-12-17 15:23:41 +010010877 type_idx++;
10878 else
10879 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +010010880 prev_label = label;
10881
10882 snprintf(boost_label, sizeof(boost_label),
10883 "%s Boost Volume", label);
10884 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10885 boost_label, type_idx,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010886 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010887 if (err < 0)
10888 return err;
10889 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010890 }
10891 return 0;
10892}
10893
10894/* almost identical with ALC880 parser... */
10895static int alc882_parse_auto_config(struct hda_codec *codec)
10896{
10897 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010898 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020010899 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010900
Takashi Iwai05f5f472009-08-25 13:10:18 +020010901 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10902 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010903 if (err < 0)
10904 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010905 if (!spec->autocfg.line_outs)
10906 return 0; /* can't find valid BIOS pin config */
10907
10908 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10909 if (err < 0)
10910 return err;
Takashi Iwai569ed342011-01-19 10:14:46 +010010911 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010912 if (err < 0)
10913 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010914 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10915 "Headphone");
10916 if (err < 0)
10917 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010918 err = alc880_auto_create_extra_out(spec,
10919 spec->autocfg.speaker_pins[0],
10920 "Speaker");
10921 if (err < 0)
10922 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010923 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10924 if (err < 0)
10925 return err;
10926
10927 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10928
Takashi Iwai757899a2010-07-30 10:48:14 +020010929 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010930
10931 if (spec->kctls.list)
10932 add_mixer(spec, spec->kctls.list);
10933
10934 add_verb(spec, alc883_auto_init_verbs);
10935 /* if ADC 0x07 is available, initialize it, too */
10936 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10937 add_verb(spec, alc882_adc1_init_verbs);
10938
10939 spec->num_mux_defs = 1;
10940 spec->input_mux = &spec->private_imux[0];
10941
Kailang Yang6227cdc2010-02-25 08:36:52 +010010942 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010943
10944 err = alc_auto_add_mic_boost(codec);
10945 if (err < 0)
10946 return err;
10947
Takashi Iwai776e1842007-08-29 15:07:11 +020010948 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010949}
10950
10951/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010952static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010953{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010954 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010955 alc882_auto_init_multi_out(codec);
10956 alc882_auto_init_hp_out(codec);
10957 alc882_auto_init_analog_input(codec);
10958 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020010959 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010960 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010961 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010962}
10963
Takashi Iwai4953550a2009-06-30 15:28:30 +020010964static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010965{
10966 struct alc_spec *spec;
10967 int err, board_config;
10968
10969 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10970 if (spec == NULL)
10971 return -ENOMEM;
10972
10973 codec->spec = spec;
10974
Takashi Iwai4953550a2009-06-30 15:28:30 +020010975 switch (codec->vendor_id) {
10976 case 0x10ec0882:
10977 case 0x10ec0885:
10978 break;
10979 default:
10980 /* ALC883 and variants */
10981 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10982 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010983 }
10984
Takashi Iwai4953550a2009-06-30 15:28:30 +020010985 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10986 alc882_models,
10987 alc882_cfg_tbl);
10988
10989 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10990 board_config = snd_hda_check_board_codec_sid_config(codec,
10991 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10992
10993 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010994 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010995 codec->chip_name);
10996 board_config = ALC882_AUTO;
10997 }
10998
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010999 if (board_config == ALC882_AUTO) {
11000 alc_pick_fixup(codec, NULL, alc882_fixup_tbl, alc882_fixups);
11001 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
11002 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011003
David Henningsson90622912010-10-14 14:50:18 +020011004 alc_auto_parse_customize_define(codec);
11005
Takashi Iwai4953550a2009-06-30 15:28:30 +020011006 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011007 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020011008 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011009 if (err < 0) {
11010 alc_free(codec);
11011 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011012 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011013 printk(KERN_INFO
11014 "hda_codec: Cannot set up configuration "
11015 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020011016 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011017 }
11018 }
11019
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011020 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020011021 err = snd_hda_attach_beep_device(codec, 0x1);
11022 if (err < 0) {
11023 alc_free(codec);
11024 return err;
11025 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011026 }
11027
Takashi Iwai4953550a2009-06-30 15:28:30 +020011028 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011029 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011030
Takashi Iwai4953550a2009-06-30 15:28:30 +020011031 spec->stream_analog_playback = &alc882_pcm_analog_playback;
11032 spec->stream_analog_capture = &alc882_pcm_analog_capture;
11033 /* FIXME: setup DAC5 */
11034 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
11035 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
11036
11037 spec->stream_digital_playback = &alc882_pcm_digital_playback;
11038 spec->stream_digital_capture = &alc882_pcm_digital_capture;
11039
Takashi Iwai4953550a2009-06-30 15:28:30 +020011040 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011041 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011042 spec->num_adc_nids = 0;
11043 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011044 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011045 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011046 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020011047 hda_nid_t nid = alc882_adc_nids[i];
11048 unsigned int wcap = get_wcaps(codec, nid);
11049 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011050 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020011051 if (wcap != AC_WID_AUD_IN)
11052 continue;
11053 spec->private_adc_nids[spec->num_adc_nids] = nid;
11054 err = snd_hda_get_connections(codec, nid, &cap, 1);
11055 if (err < 0)
11056 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011057 err = snd_hda_get_connections(codec, cap, items,
11058 ARRAY_SIZE(items));
11059 if (err < 0)
11060 continue;
11061 for (j = 0; j < imux->num_items; j++)
11062 if (imux->items[j].index >= err)
11063 break;
11064 if (j < imux->num_items)
11065 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011066 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
11067 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011068 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011069 spec->adc_nids = spec->private_adc_nids;
11070 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020011071 }
11072
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011073 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010011074
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011075 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010011076 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011077
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011078 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020011079
Takashi Iwai2134ea42008-01-10 16:53:55 +010011080 spec->vmaster_nid = 0x0c;
11081
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011082 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011083 if (board_config == ALC882_AUTO)
11084 spec->init_hook = alc882_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020011085
11086 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020011087#ifdef CONFIG_SND_HDA_POWER_SAVE
11088 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020011089 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011090#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011091
11092 return 0;
11093}
11094
Takashi Iwai4953550a2009-06-30 15:28:30 +020011095
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011096/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011097 * ALC262 support
11098 */
11099
11100#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
11101#define ALC262_DIGIN_NID ALC880_DIGIN_NID
11102
11103#define alc262_dac_nids alc260_dac_nids
11104#define alc262_adc_nids alc882_adc_nids
11105#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010011106#define alc262_capsrc_nids alc882_capsrc_nids
11107#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010011108
11109#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010011110#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010011111
Kailang Yang4e555fe2008-08-26 13:05:55 +020011112static hda_nid_t alc262_dmic_adc_nids[1] = {
11113 /* ADC0 */
11114 0x09
11115};
11116
11117static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
11118
Kailang Yangdf694da2005-12-05 19:42:22 +010011119static struct snd_kcontrol_new alc262_base_mixer[] = {
11120 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11121 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11122 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11123 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11124 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11125 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11126 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11127 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011128 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011129 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11130 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011131 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011132 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
11133 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11134 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
11135 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011136 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010011137};
11138
Takashi Iwaice875f02008-01-28 18:17:43 +010011139/* update HP, line and mono-out pins according to the master switch */
11140static void alc262_hp_master_update(struct hda_codec *codec)
11141{
11142 struct alc_spec *spec = codec->spec;
11143 int val = spec->master_sw;
11144
11145 /* HP & line-out */
11146 snd_hda_codec_write_cache(codec, 0x1b, 0,
11147 AC_VERB_SET_PIN_WIDGET_CONTROL,
11148 val ? PIN_HP : 0);
11149 snd_hda_codec_write_cache(codec, 0x15, 0,
11150 AC_VERB_SET_PIN_WIDGET_CONTROL,
11151 val ? PIN_HP : 0);
11152 /* mono (speaker) depending on the HP jack sense */
11153 val = val && !spec->jack_present;
11154 snd_hda_codec_write_cache(codec, 0x16, 0,
11155 AC_VERB_SET_PIN_WIDGET_CONTROL,
11156 val ? PIN_OUT : 0);
11157}
11158
11159static void alc262_hp_bpc_automute(struct hda_codec *codec)
11160{
11161 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011162
11163 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010011164 alc262_hp_master_update(codec);
11165}
11166
11167static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
11168{
11169 if ((res >> 26) != ALC880_HP_EVENT)
11170 return;
11171 alc262_hp_bpc_automute(codec);
11172}
11173
11174static void alc262_hp_wildwest_automute(struct hda_codec *codec)
11175{
11176 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011177
11178 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010011179 alc262_hp_master_update(codec);
11180}
11181
11182static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
11183 unsigned int res)
11184{
11185 if ((res >> 26) != ALC880_HP_EVENT)
11186 return;
11187 alc262_hp_wildwest_automute(codec);
11188}
11189
Takashi Iwaib72519b2009-05-08 14:31:55 +020011190#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010011191
11192static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
11193 struct snd_ctl_elem_value *ucontrol)
11194{
11195 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11196 struct alc_spec *spec = codec->spec;
11197 int val = !!*ucontrol->value.integer.value;
11198
11199 if (val == spec->master_sw)
11200 return 0;
11201 spec->master_sw = val;
11202 alc262_hp_master_update(codec);
11203 return 1;
11204}
11205
Takashi Iwaib72519b2009-05-08 14:31:55 +020011206#define ALC262_HP_MASTER_SWITCH \
11207 { \
11208 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11209 .name = "Master Playback Switch", \
11210 .info = snd_ctl_boolean_mono_info, \
11211 .get = alc262_hp_master_sw_get, \
11212 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011213 }, \
11214 { \
11215 .iface = NID_MAPPING, \
11216 .name = "Master Playback Switch", \
11217 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020011218 }
11219
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011220
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011221static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011222 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011223 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11224 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11225 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011226 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11227 HDA_OUTPUT),
11228 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11229 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011230 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11231 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011232 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011233 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11234 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011235 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011236 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11237 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11238 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11239 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011240 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
11241 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
11242 { } /* end */
11243};
11244
Kailang Yangcd7509a2007-01-26 18:33:17 +010011245static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011246 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010011247 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11248 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11249 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11250 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011251 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11252 HDA_OUTPUT),
11253 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11254 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011255 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11256 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011257 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011258 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11259 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11260 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11261 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011262 { } /* end */
11263};
11264
11265static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11266 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11267 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011268 HDA_CODEC_VOLUME("Rear Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011269 { } /* end */
11270};
11271
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011272/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011273static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011274{
11275 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011276
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011277 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011278 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011279}
11280
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011281static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011282 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11283 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011284 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11285 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11286 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11287 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011288 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011289 { } /* end */
11290};
11291
11292static struct hda_verb alc262_hp_t5735_verbs[] = {
11293 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11294 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11295
11296 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11297 { }
11298};
11299
Kailang Yang8c427222008-01-10 13:03:59 +010011300static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011301 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11302 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011303 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11304 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011305 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11306 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11307 { } /* end */
11308};
11309
11310static struct hda_verb alc262_hp_rp5700_verbs[] = {
11311 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11312 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11313 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11314 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11315 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11316 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11317 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11318 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11319 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11320 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11321 {}
11322};
11323
11324static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11325 .num_items = 1,
11326 .items = {
11327 { "Line", 0x1 },
11328 },
11329};
11330
Takashi Iwai42171c12009-05-08 14:11:43 +020011331/* bind hp and internal speaker mute (with plug check) as master switch */
11332static void alc262_hippo_master_update(struct hda_codec *codec)
11333{
11334 struct alc_spec *spec = codec->spec;
11335 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11336 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11337 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11338 unsigned int mute;
11339
11340 /* HP */
11341 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11342 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11343 HDA_AMP_MUTE, mute);
11344 /* mute internal speaker per jack sense */
11345 if (spec->jack_present)
11346 mute = HDA_AMP_MUTE;
11347 if (line_nid)
11348 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11349 HDA_AMP_MUTE, mute);
11350 if (speaker_nid && speaker_nid != line_nid)
11351 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11352 HDA_AMP_MUTE, mute);
11353}
11354
11355#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
11356
11357static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11358 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020011359{
11360 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020011361 struct alc_spec *spec = codec->spec;
11362 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011363
Takashi Iwai42171c12009-05-08 14:11:43 +020011364 if (val == spec->master_sw)
11365 return 0;
11366 spec->master_sw = val;
11367 alc262_hippo_master_update(codec);
11368 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011369}
Takashi Iwai5b319542007-07-26 11:49:22 +020011370
Takashi Iwai42171c12009-05-08 14:11:43 +020011371#define ALC262_HIPPO_MASTER_SWITCH \
11372 { \
11373 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11374 .name = "Master Playback Switch", \
11375 .info = snd_ctl_boolean_mono_info, \
11376 .get = alc262_hippo_master_sw_get, \
11377 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011378 }, \
11379 { \
11380 .iface = NID_MAPPING, \
11381 .name = "Master Playback Switch", \
11382 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11383 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011384 }
11385
11386static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11387 ALC262_HIPPO_MASTER_SWITCH,
11388 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11389 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11390 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11391 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11392 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11393 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11394 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011395 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011396 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11397 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011398 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011399 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11400 { } /* end */
11401};
11402
11403static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11404 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11405 ALC262_HIPPO_MASTER_SWITCH,
11406 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11407 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11408 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11409 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11410 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11411 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011412 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011413 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11414 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011415 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011416 { } /* end */
11417};
11418
11419/* mute/unmute internal speaker according to the hp jack and mute state */
11420static void alc262_hippo_automute(struct hda_codec *codec)
11421{
11422 struct alc_spec *spec = codec->spec;
11423 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020011424
Wu Fengguang864f92b2009-11-18 12:38:02 +080011425 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020011426 alc262_hippo_master_update(codec);
11427}
11428
11429static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11430{
11431 if ((res >> 26) != ALC880_HP_EVENT)
11432 return;
11433 alc262_hippo_automute(codec);
11434}
11435
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011436static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011437{
11438 struct alc_spec *spec = codec->spec;
11439
11440 spec->autocfg.hp_pins[0] = 0x15;
11441 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011442}
11443
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011444static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011445{
11446 struct alc_spec *spec = codec->spec;
11447
11448 spec->autocfg.hp_pins[0] = 0x1b;
11449 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011450}
11451
11452
Kailang Yang272a5272007-05-14 11:00:38 +020011453static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011454 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011455 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011456 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11457 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11458 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11459 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11460 { } /* end */
11461};
11462
Kailang Yang83c34212007-07-05 11:43:05 +020011463static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011464 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11465 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011466 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11467 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11468 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11469 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11470 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11471 { } /* end */
11472};
Kailang Yang272a5272007-05-14 11:00:38 +020011473
Tony Vroonba340e82009-02-02 19:01:30 +000011474static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11475 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11476 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11477 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11478 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11479 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11480 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11481 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11482 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011483 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011484 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11485 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011486 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011487 { } /* end */
11488};
11489
11490static struct hda_verb alc262_tyan_verbs[] = {
11491 /* Headphone automute */
11492 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11493 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11494 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11495
11496 /* P11 AUX_IN, white 4-pin connector */
11497 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11498 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11499 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11500 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11501
11502 {}
11503};
11504
11505/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011506static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011507{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011508 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011509
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011510 spec->autocfg.hp_pins[0] = 0x1b;
11511 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011512}
11513
Tony Vroonba340e82009-02-02 19:01:30 +000011514
Kailang Yangdf694da2005-12-05 19:42:22 +010011515#define alc262_capture_mixer alc882_capture_mixer
11516#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11517
11518/*
11519 * generic initialization of ADC, input mixers and output mixers
11520 */
11521static struct hda_verb alc262_init_verbs[] = {
11522 /*
11523 * Unmute ADC0-2 and set the default input to mic-in
11524 */
11525 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11526 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11527 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11528 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11529 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11530 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11531
Takashi Iwaicb53c622007-08-10 17:21:45 +020011532 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011533 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011534 * Note: PASD motherboards uses the Line In 2 as the input for
11535 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011536 */
11537 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011538 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11539 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11540 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11541 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11542 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011543
11544 /*
11545 * Set up output mixers (0x0c - 0x0e)
11546 */
11547 /* set vol=0 to output mixers */
11548 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11549 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11550 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11551 /* set up input amps for analog loopback */
11552 /* Amp Indices: DAC = 0, mixer = 1 */
11553 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11554 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11555 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11556 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11557 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11558 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11559
11560 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11561 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11562 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11563 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11564 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11565 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11566
11567 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11568 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11569 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11570 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11571 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011572
Kailang Yangdf694da2005-12-05 19:42:22 +010011573 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11574 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011575
Kailang Yangdf694da2005-12-05 19:42:22 +010011576 /* FIXME: use matrix-type input source selection */
11577 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11578 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11579 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11580 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11581 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11582 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11583 /* Input mixer2 */
11584 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11585 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11586 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11587 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11588 /* Input mixer3 */
11589 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11590 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11591 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011592 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011593
11594 { }
11595};
11596
Kailang Yang4e555fe2008-08-26 13:05:55 +020011597static struct hda_verb alc262_eapd_verbs[] = {
11598 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11599 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11600 { }
11601};
11602
Kailang Yangccc656c2006-10-17 12:32:26 +020011603static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11604 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11605 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11606 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11607
11608 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11609 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11610 {}
11611};
11612
Kailang Yang272a5272007-05-14 11:00:38 +020011613static struct hda_verb alc262_sony_unsol_verbs[] = {
11614 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11615 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11616 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11617
11618 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11619 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011620 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011621};
11622
Kailang Yang4e555fe2008-08-26 13:05:55 +020011623static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11624 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11625 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11626 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11627 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11628 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011629 { } /* end */
11630};
11631
11632static struct hda_verb alc262_toshiba_s06_verbs[] = {
11633 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11634 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11635 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11636 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11637 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11638 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11639 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11640 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11641 {}
11642};
11643
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011644static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011645{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011646 struct alc_spec *spec = codec->spec;
11647
11648 spec->autocfg.hp_pins[0] = 0x15;
11649 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011650 spec->ext_mic.pin = 0x18;
11651 spec->ext_mic.mux_idx = 0;
11652 spec->int_mic.pin = 0x12;
11653 spec->int_mic.mux_idx = 9;
11654 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011655}
11656
Takashi Iwai834be882006-03-01 14:16:17 +010011657/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011658 * nec model
11659 * 0x15 = headphone
11660 * 0x16 = internal speaker
11661 * 0x18 = external mic
11662 */
11663
11664static struct snd_kcontrol_new alc262_nec_mixer[] = {
11665 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11666 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11667
11668 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11669 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011670 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011671
11672 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11673 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11674 { } /* end */
11675};
11676
11677static struct hda_verb alc262_nec_verbs[] = {
11678 /* Unmute Speaker */
11679 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11680
11681 /* Headphone */
11682 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11683 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11684
11685 /* External mic to headphone */
11686 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11687 /* External mic to speaker */
11688 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11689 {}
11690};
11691
11692/*
Takashi Iwai834be882006-03-01 14:16:17 +010011693 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011694 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11695 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011696 */
11697
11698#define ALC_HP_EVENT 0x37
11699
11700static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11701 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11702 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011703 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11704 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011705 {}
11706};
11707
Jiang zhe0e31daf2008-03-20 12:12:39 +010011708static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11709 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11710 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11711 {}
11712};
11713
Daniel T Chene2595322009-12-19 18:19:02 -050011714static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11715 /* Front Mic pin: input vref at 50% */
11716 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11717 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11718 {}
11719};
11720
Takashi Iwai834be882006-03-01 14:16:17 +010011721static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011722 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011723 .items = {
11724 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010011725 { "Internal Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011726 { "CD", 0x4 },
11727 },
11728};
11729
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011730static struct hda_input_mux alc262_HP_capture_source = {
11731 .num_items = 5,
11732 .items = {
11733 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011734 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011735 { "Line", 0x2 },
11736 { "CD", 0x4 },
11737 { "AUX IN", 0x6 },
11738 },
11739};
11740
zhejiangaccbe492007-08-31 12:36:05 +020011741static struct hda_input_mux alc262_HP_D7000_capture_source = {
11742 .num_items = 4,
11743 .items = {
11744 { "Mic", 0x0 },
11745 { "Front Mic", 0x2 },
11746 { "Line", 0x1 },
11747 { "CD", 0x4 },
11748 },
11749};
11750
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011751/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011752static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11753{
11754 struct alc_spec *spec = codec->spec;
11755 unsigned int mute;
11756
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011757 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011758 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11759 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011760 spec->sense_updated = 1;
11761 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011762 /* unmute internal speaker only if both HPs are unplugged and
11763 * master switch is on
11764 */
11765 if (spec->jack_present)
11766 mute = HDA_AMP_MUTE;
11767 else
Takashi Iwai834be882006-03-01 14:16:17 +010011768 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011769 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11770 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011771}
11772
11773/* unsolicited event for HP jack sensing */
11774static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11775 unsigned int res)
11776{
11777 if ((res >> 26) != ALC_HP_EVENT)
11778 return;
11779 alc262_fujitsu_automute(codec, 1);
11780}
11781
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011782static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11783{
11784 alc262_fujitsu_automute(codec, 1);
11785}
11786
Takashi Iwai834be882006-03-01 14:16:17 +010011787/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011788static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11789 .ops = &snd_hda_bind_vol,
11790 .values = {
11791 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11792 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11793 0
11794 },
11795};
Takashi Iwai834be882006-03-01 14:16:17 +010011796
Jiang zhe0e31daf2008-03-20 12:12:39 +010011797/* mute/unmute internal speaker according to the hp jack and mute state */
11798static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11799{
11800 struct alc_spec *spec = codec->spec;
11801 unsigned int mute;
11802
11803 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011804 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011805 spec->sense_updated = 1;
11806 }
11807 if (spec->jack_present) {
11808 /* mute internal speaker */
11809 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11810 HDA_AMP_MUTE, HDA_AMP_MUTE);
11811 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11812 HDA_AMP_MUTE, HDA_AMP_MUTE);
11813 } else {
11814 /* unmute internal speaker if necessary */
11815 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11816 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11817 HDA_AMP_MUTE, mute);
11818 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11819 HDA_AMP_MUTE, mute);
11820 }
11821}
11822
11823/* unsolicited event for HP jack sensing */
11824static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11825 unsigned int res)
11826{
11827 if ((res >> 26) != ALC_HP_EVENT)
11828 return;
11829 alc262_lenovo_3000_automute(codec, 1);
11830}
11831
Takashi Iwai8de56b72009-07-24 16:51:47 +020011832static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11833 int dir, int idx, long *valp)
11834{
11835 int i, change = 0;
11836
11837 for (i = 0; i < 2; i++, valp++)
11838 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11839 HDA_AMP_MUTE,
11840 *valp ? 0 : HDA_AMP_MUTE);
11841 return change;
11842}
11843
Takashi Iwai834be882006-03-01 14:16:17 +010011844/* bind hp and internal speaker mute (with plug check) */
11845static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11846 struct snd_ctl_elem_value *ucontrol)
11847{
11848 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11849 long *valp = ucontrol->value.integer.value;
11850 int change;
11851
Takashi Iwai8de56b72009-07-24 16:51:47 +020011852 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11853 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011854 if (change)
11855 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011856 return change;
11857}
11858
11859static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011860 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011861 {
11862 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11863 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011864 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011865 .info = snd_hda_mixer_amp_switch_info,
11866 .get = snd_hda_mixer_amp_switch_get,
11867 .put = alc262_fujitsu_master_sw_put,
11868 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11869 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011870 {
11871 .iface = NID_MAPPING,
11872 .name = "Master Playback Switch",
11873 .private_value = 0x1b,
11874 },
Takashi Iwai834be882006-03-01 14:16:17 +010011875 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11876 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011877 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011878 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11879 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011880 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010011881 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11882 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011883 { } /* end */
11884};
11885
Jiang zhe0e31daf2008-03-20 12:12:39 +010011886/* bind hp and internal speaker mute (with plug check) */
11887static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11888 struct snd_ctl_elem_value *ucontrol)
11889{
11890 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11891 long *valp = ucontrol->value.integer.value;
11892 int change;
11893
Takashi Iwai8de56b72009-07-24 16:51:47 +020011894 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011895 if (change)
11896 alc262_lenovo_3000_automute(codec, 0);
11897 return change;
11898}
11899
11900static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11901 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11902 {
11903 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11904 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011905 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011906 .info = snd_hda_mixer_amp_switch_info,
11907 .get = snd_hda_mixer_amp_switch_get,
11908 .put = alc262_lenovo_3000_master_sw_put,
11909 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11910 },
11911 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11912 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011913 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011914 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11915 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011916 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010011917 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11918 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011919 { } /* end */
11920};
11921
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011922static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11923 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011924 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011925 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11926 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011927 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011928 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11929 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011930 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011931 { } /* end */
11932};
11933
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011934/* additional init verbs for Benq laptops */
11935static struct hda_verb alc262_EAPD_verbs[] = {
11936 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11937 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11938 {}
11939};
11940
Kailang Yang83c34212007-07-05 11:43:05 +020011941static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11942 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11943 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11944
11945 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11946 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11947 {}
11948};
11949
Tobin Davisf651b502007-10-26 12:40:47 +020011950/* Samsung Q1 Ultra Vista model setup */
11951static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011952 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11953 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011954 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11955 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011956 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
11957 HDA_CODEC_VOLUME("Headphone Mic Boost Volume", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011958 { } /* end */
11959};
11960
11961static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011962 /* output mixer */
11963 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11964 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11965 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11966 /* speaker */
11967 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11968 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11969 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11970 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11971 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011972 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011973 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11974 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11975 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11976 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11977 /* internal mic */
11978 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11979 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11980 /* ADC, choose mic */
11981 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11982 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11983 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11984 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11985 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11986 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11987 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11988 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11989 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11990 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011991 {}
11992};
11993
Tobin Davisf651b502007-10-26 12:40:47 +020011994/* mute/unmute internal speaker according to the hp jack and mute state */
11995static void alc262_ultra_automute(struct hda_codec *codec)
11996{
11997 struct alc_spec *spec = codec->spec;
11998 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011999
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012000 mute = 0;
12001 /* auto-mute only when HP is used as HP */
12002 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012003 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012004 if (spec->jack_present)
12005 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020012006 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012007 /* mute/unmute internal speaker */
12008 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12009 HDA_AMP_MUTE, mute);
12010 /* mute/unmute HP */
12011 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12012 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020012013}
12014
12015/* unsolicited event for HP jack sensing */
12016static void alc262_ultra_unsol_event(struct hda_codec *codec,
12017 unsigned int res)
12018{
12019 if ((res >> 26) != ALC880_HP_EVENT)
12020 return;
12021 alc262_ultra_automute(codec);
12022}
12023
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012024static struct hda_input_mux alc262_ultra_capture_source = {
12025 .num_items = 2,
12026 .items = {
12027 { "Mic", 0x1 },
12028 { "Headphone", 0x7 },
12029 },
12030};
12031
12032static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
12033 struct snd_ctl_elem_value *ucontrol)
12034{
12035 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12036 struct alc_spec *spec = codec->spec;
12037 int ret;
12038
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012039 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012040 if (!ret)
12041 return 0;
12042 /* reprogram the HP pin as mic or HP according to the input source */
12043 snd_hda_codec_write_cache(codec, 0x15, 0,
12044 AC_VERB_SET_PIN_WIDGET_CONTROL,
12045 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
12046 alc262_ultra_automute(codec); /* mute/unmute HP */
12047 return ret;
12048}
12049
12050static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
12051 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
12052 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
12053 {
12054 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12055 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012056 .info = alc_mux_enum_info,
12057 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012058 .put = alc262_ultra_mux_enum_put,
12059 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010012060 {
12061 .iface = NID_MAPPING,
12062 .name = "Capture Source",
12063 .private_value = 0x15,
12064 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012065 { } /* end */
12066};
12067
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012068/* We use two mixers depending on the output pin; 0x16 is a mono output
12069 * and thus it's bound with a different mixer.
12070 * This function returns which mixer amp should be used.
12071 */
12072static int alc262_check_volbit(hda_nid_t nid)
12073{
12074 if (!nid)
12075 return 0;
12076 else if (nid == 0x16)
12077 return 2;
12078 else
12079 return 1;
12080}
12081
12082static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012083 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012084{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012085 unsigned long val;
12086 int vbit;
12087
12088 vbit = alc262_check_volbit(nid);
12089 if (!vbit)
12090 return 0;
12091 if (*vbits & vbit) /* a volume control for this mixer already there */
12092 return 0;
12093 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012094 if (vbit == 2)
12095 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
12096 else
12097 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012098 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012099}
12100
12101static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012102 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012103{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012104 unsigned long val;
12105
12106 if (!nid)
12107 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012108 if (nid == 0x16)
12109 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
12110 else
12111 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012112 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012113}
12114
Kailang Yangdf694da2005-12-05 19:42:22 +010012115/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012116static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
12117 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012118{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012119 const char *pfx;
12120 int vbits;
Takashi Iwai033688a2010-09-08 15:47:09 +020012121 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010012122
12123 spec->multiout.num_dacs = 1; /* only use one dac */
12124 spec->multiout.dac_nids = spec->private_dac_nids;
12125 spec->multiout.dac_nids[0] = 2;
12126
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010012127 pfx = alc_get_line_out_pfx(cfg, true);
12128 if (!pfx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012129 pfx = "Front";
Takashi Iwai033688a2010-09-08 15:47:09 +020012130 for (i = 0; i < 2; i++) {
12131 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
12132 if (err < 0)
12133 return err;
12134 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12135 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
12136 "Speaker", i);
12137 if (err < 0)
12138 return err;
12139 }
12140 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12141 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
12142 "Headphone", i);
12143 if (err < 0)
12144 return err;
12145 }
12146 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012147
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012148 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
12149 alc262_check_volbit(cfg->speaker_pins[0]) |
12150 alc262_check_volbit(cfg->hp_pins[0]);
12151 if (vbits == 1 || vbits == 2)
12152 pfx = "Master"; /* only one mixer is used */
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012153 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020012154 for (i = 0; i < 2; i++) {
12155 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
12156 &vbits, i);
12157 if (err < 0)
12158 return err;
12159 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12160 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
12161 "Speaker", &vbits, i);
12162 if (err < 0)
12163 return err;
12164 }
12165 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12166 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
12167 "Headphone", &vbits, i);
12168 if (err < 0)
12169 return err;
12170 }
12171 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012172 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010012173}
12174
Takashi Iwai05f5f472009-08-25 13:10:18 +020012175#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010012176 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010012177
12178/*
12179 * generic initialization of ADC, input mixers and output mixers
12180 */
12181static struct hda_verb alc262_volume_init_verbs[] = {
12182 /*
12183 * Unmute ADC0-2 and set the default input to mic-in
12184 */
12185 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12186 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12187 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12188 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12189 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12190 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12191
Takashi Iwaicb53c622007-08-10 17:21:45 +020012192 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010012193 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012194 * Note: PASD motherboards uses the Line In 2 as the input for
12195 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010012196 */
12197 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012198 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12199 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12200 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12201 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12202 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012203
12204 /*
12205 * Set up output mixers (0x0c - 0x0f)
12206 */
12207 /* set vol=0 to output mixers */
12208 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12209 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12210 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020012211
Kailang Yangdf694da2005-12-05 19:42:22 +010012212 /* set up input amps for analog loopback */
12213 /* Amp Indices: DAC = 0, mixer = 1 */
12214 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12215 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12216 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12217 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12218 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12219 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12220
12221 /* FIXME: use matrix-type input source selection */
12222 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12223 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12224 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12225 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12226 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12227 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12228 /* Input mixer2 */
12229 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12230 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12231 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12232 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12233 /* Input mixer3 */
12234 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12235 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12236 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12237 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12238
12239 { }
12240};
12241
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012242static struct hda_verb alc262_HP_BPC_init_verbs[] = {
12243 /*
12244 * Unmute ADC0-2 and set the default input to mic-in
12245 */
12246 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12247 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12248 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12249 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12250 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12251 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12252
Takashi Iwaicb53c622007-08-10 17:21:45 +020012253 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012254 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012255 * Note: PASD motherboards uses the Line In 2 as the input for
12256 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012257 */
12258 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012259 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12260 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12261 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12262 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12263 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12264 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12265 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012266
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012267 /*
12268 * Set up output mixers (0x0c - 0x0e)
12269 */
12270 /* set vol=0 to output mixers */
12271 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12272 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12273 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12274
12275 /* set up input amps for analog loopback */
12276 /* Amp Indices: DAC = 0, mixer = 1 */
12277 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12278 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12279 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12280 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12281 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12282 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12283
Takashi Iwaice875f02008-01-28 18:17:43 +010012284 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012285 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12286 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12287
12288 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12289 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12290
12291 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12292 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12293
12294 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12295 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12296 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12297 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12298 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12299
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012300 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012301 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12302 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012303 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012304 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12305 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12306
12307
12308 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012309 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12310 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012311 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012312 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12313 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12314 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12315 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12316 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12317 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12318 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12319 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012320 /* Input mixer2 */
12321 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012322 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12323 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12324 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12325 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12326 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12327 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12328 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12329 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012330 /* Input mixer3 */
12331 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012332 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12333 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12334 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12335 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12336 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12337 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12338 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12339 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012340
Takashi Iwaice875f02008-01-28 18:17:43 +010012341 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12342
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012343 { }
12344};
12345
Kailang Yangcd7509a2007-01-26 18:33:17 +010012346static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12347 /*
12348 * Unmute ADC0-2 and set the default input to mic-in
12349 */
12350 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12351 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12352 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12353 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12354 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12355 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12356
Takashi Iwaicb53c622007-08-10 17:21:45 +020012357 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012358 * mixer widget
12359 * Note: PASD motherboards uses the Line In 2 as the input for front
12360 * panel mic (mic 2)
12361 */
12362 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012363 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12364 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12365 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12366 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12367 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12368 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12369 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12370 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012371 /*
12372 * Set up output mixers (0x0c - 0x0e)
12373 */
12374 /* set vol=0 to output mixers */
12375 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12376 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12377 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12378
12379 /* set up input amps for analog loopback */
12380 /* Amp Indices: DAC = 0, mixer = 1 */
12381 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12382 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12383 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12384 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12385 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12386 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12387
12388
12389 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12390 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12391 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12392 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12393 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12394 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12395 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12396
12397 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12398 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12399
12400 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12401 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12402
12403 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12404 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12405 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12406 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12407 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12408 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12409
12410 /* FIXME: use matrix-type input source selection */
12411 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12412 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12413 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12414 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12415 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12416 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12417 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12418 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12419 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12420 /* Input mixer2 */
12421 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12422 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12423 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12424 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12425 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12426 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12427 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12428 /* Input mixer3 */
12429 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12430 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12431 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12432 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12433 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12434 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12435 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12436
Takashi Iwaice875f02008-01-28 18:17:43 +010012437 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12438
Kailang Yangcd7509a2007-01-26 18:33:17 +010012439 { }
12440};
12441
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012442static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12443
12444 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12445 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12446 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12447
12448 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12449 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12450 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12451 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12452
12453 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12454 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12455 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12456 {}
12457};
12458
Takashi Iwai18675e42010-09-08 15:55:44 +020012459/*
12460 * Pin config fixes
12461 */
12462enum {
12463 PINFIX_FSC_H270,
12464};
12465
12466static const struct alc_fixup alc262_fixups[] = {
12467 [PINFIX_FSC_H270] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012468 .type = ALC_FIXUP_PINS,
12469 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai18675e42010-09-08 15:55:44 +020012470 { 0x14, 0x99130110 }, /* speaker */
12471 { 0x15, 0x0221142f }, /* front HP */
12472 { 0x1b, 0x0121141f }, /* rear HP */
12473 { }
12474 }
12475 },
Takashi Iwai18675e42010-09-08 15:55:44 +020012476};
12477
12478static struct snd_pci_quirk alc262_fixup_tbl[] = {
12479 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12480 {}
12481};
12482
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012483
Takashi Iwaicb53c622007-08-10 17:21:45 +020012484#ifdef CONFIG_SND_HDA_POWER_SAVE
12485#define alc262_loopbacks alc880_loopbacks
12486#endif
12487
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012488/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012489#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12490#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12491#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12492#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12493
12494/*
12495 * BIOS auto configuration
12496 */
12497static int alc262_parse_auto_config(struct hda_codec *codec)
12498{
12499 struct alc_spec *spec = codec->spec;
12500 int err;
12501 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12502
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012503 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12504 alc262_ignore);
12505 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012506 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012507 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012508 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012509 spec->multiout.max_channels = 2;
12510 spec->no_analog = 1;
12511 goto dig_only;
12512 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012513 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012514 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012515 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12516 if (err < 0)
12517 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012518 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012519 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012520 return err;
12521
12522 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12523
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012524 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012525 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012526
Takashi Iwai603c4012008-07-30 15:01:44 +020012527 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012528 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012529
Takashi Iwaid88897e2008-10-31 15:01:37 +010012530 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012531 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012532 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012533
Takashi Iwai776e1842007-08-29 15:07:11 +020012534 err = alc_auto_add_mic_boost(codec);
12535 if (err < 0)
12536 return err;
12537
Kailang Yang6227cdc2010-02-25 08:36:52 +010012538 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012539
Kailang Yangdf694da2005-12-05 19:42:22 +010012540 return 1;
12541}
12542
12543#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12544#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12545#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012546#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012547
12548
12549/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012550static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012551{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012552 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012553 alc262_auto_init_multi_out(codec);
12554 alc262_auto_init_hp_out(codec);
12555 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012556 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012557 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012558 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012559 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012560}
12561
12562/*
12563 * configuration and preset
12564 */
Takashi Iwaiea734962011-01-17 11:29:34 +010012565static const char * const alc262_models[ALC262_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012566 [ALC262_BASIC] = "basic",
12567 [ALC262_HIPPO] = "hippo",
12568 [ALC262_HIPPO_1] = "hippo_1",
12569 [ALC262_FUJITSU] = "fujitsu",
12570 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012571 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012572 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012573 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012574 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012575 [ALC262_BENQ_T31] = "benq-t31",
12576 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012577 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012578 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012579 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012580 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012581 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012582 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012583 [ALC262_AUTO] = "auto",
12584};
12585
12586static struct snd_pci_quirk alc262_cfg_tbl[] = {
12587 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012588 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012589 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12590 ALC262_HP_BPC),
12591 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12592 ALC262_HP_BPC),
Takashi Iwai5734a072011-01-19 17:07:12 +010012593 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1500, "HP z series",
12594 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012595 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12596 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012597 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012598 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012599 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012600 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012601 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012602 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012603 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012604 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012605 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12606 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12607 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012608 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12609 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012610 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012611 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012612 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012613 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012614 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012615 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012616 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012617 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012618#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012619 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12620 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012621#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012622 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012623 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012624 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012625 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012626 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012627 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012628 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12629 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012630 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012631 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012632 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012633 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012634 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012635 {}
12636};
12637
12638static struct alc_config_preset alc262_presets[] = {
12639 [ALC262_BASIC] = {
12640 .mixers = { alc262_base_mixer },
12641 .init_verbs = { alc262_init_verbs },
12642 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12643 .dac_nids = alc262_dac_nids,
12644 .hp_nid = 0x03,
12645 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12646 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012647 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012648 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012649 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012650 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012651 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012652 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12653 .dac_nids = alc262_dac_nids,
12654 .hp_nid = 0x03,
12655 .dig_out_nid = ALC262_DIGOUT_NID,
12656 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12657 .channel_mode = alc262_modes,
12658 .input_mux = &alc262_capture_source,
12659 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012660 .setup = alc262_hippo_setup,
12661 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012662 },
12663 [ALC262_HIPPO_1] = {
12664 .mixers = { alc262_hippo1_mixer },
12665 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12666 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12667 .dac_nids = alc262_dac_nids,
12668 .hp_nid = 0x02,
12669 .dig_out_nid = ALC262_DIGOUT_NID,
12670 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12671 .channel_mode = alc262_modes,
12672 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012673 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012674 .setup = alc262_hippo1_setup,
12675 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012676 },
Takashi Iwai834be882006-03-01 14:16:17 +010012677 [ALC262_FUJITSU] = {
12678 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012679 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12680 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012681 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12682 .dac_nids = alc262_dac_nids,
12683 .hp_nid = 0x03,
12684 .dig_out_nid = ALC262_DIGOUT_NID,
12685 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12686 .channel_mode = alc262_modes,
12687 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012688 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012689 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012690 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012691 [ALC262_HP_BPC] = {
12692 .mixers = { alc262_HP_BPC_mixer },
12693 .init_verbs = { alc262_HP_BPC_init_verbs },
12694 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12695 .dac_nids = alc262_dac_nids,
12696 .hp_nid = 0x03,
12697 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12698 .channel_mode = alc262_modes,
12699 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012700 .unsol_event = alc262_hp_bpc_unsol_event,
12701 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012702 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012703 [ALC262_HP_BPC_D7000_WF] = {
12704 .mixers = { alc262_HP_BPC_WildWest_mixer },
12705 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12706 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12707 .dac_nids = alc262_dac_nids,
12708 .hp_nid = 0x03,
12709 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12710 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012711 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012712 .unsol_event = alc262_hp_wildwest_unsol_event,
12713 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012714 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012715 [ALC262_HP_BPC_D7000_WL] = {
12716 .mixers = { alc262_HP_BPC_WildWest_mixer,
12717 alc262_HP_BPC_WildWest_option_mixer },
12718 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12719 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12720 .dac_nids = alc262_dac_nids,
12721 .hp_nid = 0x03,
12722 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12723 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012724 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012725 .unsol_event = alc262_hp_wildwest_unsol_event,
12726 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012727 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012728 [ALC262_HP_TC_T5735] = {
12729 .mixers = { alc262_hp_t5735_mixer },
12730 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12731 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12732 .dac_nids = alc262_dac_nids,
12733 .hp_nid = 0x03,
12734 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12735 .channel_mode = alc262_modes,
12736 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012737 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012738 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012739 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012740 },
12741 [ALC262_HP_RP5700] = {
12742 .mixers = { alc262_hp_rp5700_mixer },
12743 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12744 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12745 .dac_nids = alc262_dac_nids,
12746 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12747 .channel_mode = alc262_modes,
12748 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012749 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012750 [ALC262_BENQ_ED8] = {
12751 .mixers = { alc262_base_mixer },
12752 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12753 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12754 .dac_nids = alc262_dac_nids,
12755 .hp_nid = 0x03,
12756 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12757 .channel_mode = alc262_modes,
12758 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012759 },
Kailang Yang272a5272007-05-14 11:00:38 +020012760 [ALC262_SONY_ASSAMD] = {
12761 .mixers = { alc262_sony_mixer },
12762 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12763 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12764 .dac_nids = alc262_dac_nids,
12765 .hp_nid = 0x02,
12766 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12767 .channel_mode = alc262_modes,
12768 .input_mux = &alc262_capture_source,
12769 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012770 .setup = alc262_hippo_setup,
12771 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012772 },
12773 [ALC262_BENQ_T31] = {
12774 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012775 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12776 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012777 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12778 .dac_nids = alc262_dac_nids,
12779 .hp_nid = 0x03,
12780 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12781 .channel_mode = alc262_modes,
12782 .input_mux = &alc262_capture_source,
12783 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012784 .setup = alc262_hippo_setup,
12785 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012786 },
Tobin Davisf651b502007-10-26 12:40:47 +020012787 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012788 .mixers = { alc262_ultra_mixer },
12789 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012790 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012791 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12792 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012793 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12794 .channel_mode = alc262_modes,
12795 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012796 .adc_nids = alc262_adc_nids, /* ADC0 */
12797 .capsrc_nids = alc262_capsrc_nids,
12798 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012799 .unsol_event = alc262_ultra_unsol_event,
12800 .init_hook = alc262_ultra_automute,
12801 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012802 [ALC262_LENOVO_3000] = {
12803 .mixers = { alc262_lenovo_3000_mixer },
12804 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012805 alc262_lenovo_3000_unsol_verbs,
12806 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012807 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12808 .dac_nids = alc262_dac_nids,
12809 .hp_nid = 0x03,
12810 .dig_out_nid = ALC262_DIGOUT_NID,
12811 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12812 .channel_mode = alc262_modes,
12813 .input_mux = &alc262_fujitsu_capture_source,
12814 .unsol_event = alc262_lenovo_3000_unsol_event,
12815 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012816 [ALC262_NEC] = {
12817 .mixers = { alc262_nec_mixer },
12818 .init_verbs = { alc262_nec_verbs },
12819 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12820 .dac_nids = alc262_dac_nids,
12821 .hp_nid = 0x03,
12822 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12823 .channel_mode = alc262_modes,
12824 .input_mux = &alc262_capture_source,
12825 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012826 [ALC262_TOSHIBA_S06] = {
12827 .mixers = { alc262_toshiba_s06_mixer },
12828 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12829 alc262_eapd_verbs },
12830 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12831 .capsrc_nids = alc262_dmic_capsrc_nids,
12832 .dac_nids = alc262_dac_nids,
12833 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012834 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012835 .dig_out_nid = ALC262_DIGOUT_NID,
12836 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12837 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012838 .unsol_event = alc_sku_unsol_event,
12839 .setup = alc262_toshiba_s06_setup,
12840 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012841 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012842 [ALC262_TOSHIBA_RX1] = {
12843 .mixers = { alc262_toshiba_rx1_mixer },
12844 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12845 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12846 .dac_nids = alc262_dac_nids,
12847 .hp_nid = 0x03,
12848 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12849 .channel_mode = alc262_modes,
12850 .input_mux = &alc262_capture_source,
12851 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012852 .setup = alc262_hippo_setup,
12853 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012854 },
Tony Vroonba340e82009-02-02 19:01:30 +000012855 [ALC262_TYAN] = {
12856 .mixers = { alc262_tyan_mixer },
12857 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12858 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12859 .dac_nids = alc262_dac_nids,
12860 .hp_nid = 0x02,
12861 .dig_out_nid = ALC262_DIGOUT_NID,
12862 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12863 .channel_mode = alc262_modes,
12864 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012865 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012866 .setup = alc262_tyan_setup,
12867 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012868 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012869};
12870
12871static int patch_alc262(struct hda_codec *codec)
12872{
12873 struct alc_spec *spec;
12874 int board_config;
12875 int err;
12876
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012877 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012878 if (spec == NULL)
12879 return -ENOMEM;
12880
12881 codec->spec = spec;
12882#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012883 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12884 * under-run
12885 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012886 {
12887 int tmp;
12888 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12889 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12890 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12891 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12892 }
12893#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012894 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012895
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012896 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12897
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012898 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12899 alc262_models,
12900 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012901
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012902 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012903 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12904 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012905 board_config = ALC262_AUTO;
12906 }
12907
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012908 if (board_config == ALC262_AUTO) {
12909 alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups);
12910 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
12911 }
Takashi Iwai18675e42010-09-08 15:55:44 +020012912
Kailang Yangdf694da2005-12-05 19:42:22 +010012913 if (board_config == ALC262_AUTO) {
12914 /* automatic parse from the BIOS config */
12915 err = alc262_parse_auto_config(codec);
12916 if (err < 0) {
12917 alc_free(codec);
12918 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012919 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012920 printk(KERN_INFO
12921 "hda_codec: Cannot set up configuration "
12922 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012923 board_config = ALC262_BASIC;
12924 }
12925 }
12926
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012927 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012928 err = snd_hda_attach_beep_device(codec, 0x1);
12929 if (err < 0) {
12930 alc_free(codec);
12931 return err;
12932 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012933 }
12934
Kailang Yangdf694da2005-12-05 19:42:22 +010012935 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012936 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012937
Kailang Yangdf694da2005-12-05 19:42:22 +010012938 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12939 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012940
Kailang Yangdf694da2005-12-05 19:42:22 +010012941 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12942 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12943
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012944 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012945 int i;
12946 /* check whether the digital-mic has to be supported */
12947 for (i = 0; i < spec->input_mux->num_items; i++) {
12948 if (spec->input_mux->items[i].index >= 9)
12949 break;
12950 }
12951 if (i < spec->input_mux->num_items) {
12952 /* use only ADC0 */
12953 spec->adc_nids = alc262_dmic_adc_nids;
12954 spec->num_adc_nids = 1;
12955 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012956 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012957 /* all analog inputs */
12958 /* check whether NID 0x07 is valid */
12959 unsigned int wcap = get_wcaps(codec, 0x07);
12960
12961 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012962 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012963 if (wcap != AC_WID_AUD_IN) {
12964 spec->adc_nids = alc262_adc_nids_alt;
12965 spec->num_adc_nids =
12966 ARRAY_SIZE(alc262_adc_nids_alt);
12967 spec->capsrc_nids = alc262_capsrc_nids_alt;
12968 } else {
12969 spec->adc_nids = alc262_adc_nids;
12970 spec->num_adc_nids =
12971 ARRAY_SIZE(alc262_adc_nids);
12972 spec->capsrc_nids = alc262_capsrc_nids;
12973 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012974 }
12975 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012976 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012977 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012978 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010012979 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012980
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012981 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai18675e42010-09-08 15:55:44 +020012982
Takashi Iwai2134ea42008-01-10 16:53:55 +010012983 spec->vmaster_nid = 0x0c;
12984
Kailang Yangdf694da2005-12-05 19:42:22 +010012985 codec->patch_ops = alc_patch_ops;
12986 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012987 spec->init_hook = alc262_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020012988
12989 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020012990#ifdef CONFIG_SND_HDA_POWER_SAVE
12991 if (!spec->loopback.amplist)
12992 spec->loopback.amplist = alc262_loopbacks;
12993#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012994
Kailang Yangdf694da2005-12-05 19:42:22 +010012995 return 0;
12996}
12997
Kailang Yangdf694da2005-12-05 19:42:22 +010012998/*
Kailang Yanga361d842007-06-05 12:30:55 +020012999 * ALC268 channel source setting (2 channel)
13000 */
13001#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
13002#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020013003
Kailang Yanga361d842007-06-05 12:30:55 +020013004static hda_nid_t alc268_dac_nids[2] = {
13005 /* front, hp */
13006 0x02, 0x03
13007};
13008
13009static hda_nid_t alc268_adc_nids[2] = {
13010 /* ADC0-1 */
13011 0x08, 0x07
13012};
13013
13014static hda_nid_t alc268_adc_nids_alt[1] = {
13015 /* ADC0 */
13016 0x08
13017};
13018
Takashi Iwaie1406342008-02-11 18:32:32 +010013019static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
13020
Kailang Yanga361d842007-06-05 12:30:55 +020013021static struct snd_kcontrol_new alc268_base_mixer[] = {
13022 /* output mixer control */
13023 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13024 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13025 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13026 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013027 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13028 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13029 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020013030 { }
13031};
13032
Takashi Iwai42171c12009-05-08 14:11:43 +020013033static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
13034 /* output mixer control */
13035 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13036 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13037 ALC262_HIPPO_MASTER_SWITCH,
David Henningsson5f99f862011-01-04 15:24:24 +010013038 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13039 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13040 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020013041 { }
13042};
13043
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013044/* bind Beep switches of both NID 0x0f and 0x10 */
13045static struct hda_bind_ctls alc268_bind_beep_sw = {
13046 .ops = &snd_hda_bind_sw,
13047 .values = {
13048 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
13049 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
13050 0
13051 },
13052};
13053
13054static struct snd_kcontrol_new alc268_beep_mixer[] = {
13055 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
13056 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
13057 { }
13058};
13059
Kailang Yangd1a991a2007-08-15 16:21:59 +020013060static struct hda_verb alc268_eapd_verbs[] = {
13061 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13062 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13063 { }
13064};
13065
Takashi Iwaid2738092007-08-16 14:59:45 +020013066/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020013067static struct hda_verb alc268_toshiba_verbs[] = {
13068 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13069 { } /* end */
13070};
13071
13072/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020013073/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020013074static struct hda_bind_ctls alc268_acer_bind_master_vol = {
13075 .ops = &snd_hda_bind_vol,
13076 .values = {
13077 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
13078 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
13079 0
13080 },
13081};
13082
Takashi Iwai889c4392007-08-23 18:56:52 +020013083/* mute/unmute internal speaker according to the hp jack and mute state */
13084static void alc268_acer_automute(struct hda_codec *codec, int force)
13085{
13086 struct alc_spec *spec = codec->spec;
13087 unsigned int mute;
13088
13089 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080013090 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020013091 spec->sense_updated = 1;
13092 }
13093 if (spec->jack_present)
13094 mute = HDA_AMP_MUTE; /* mute internal speaker */
13095 else /* unmute internal speaker if necessary */
13096 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13097 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13098 HDA_AMP_MUTE, mute);
13099}
13100
13101
13102/* bind hp and internal speaker mute (with plug check) */
13103static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
13104 struct snd_ctl_elem_value *ucontrol)
13105{
13106 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
13107 long *valp = ucontrol->value.integer.value;
13108 int change;
13109
Takashi Iwai8de56b72009-07-24 16:51:47 +020013110 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020013111 if (change)
13112 alc268_acer_automute(codec, 0);
13113 return change;
13114}
Takashi Iwaid2738092007-08-16 14:59:45 +020013115
Kailang Yang8ef355d2008-08-26 13:10:22 +020013116static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
13117 /* output mixer control */
13118 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13119 {
13120 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13121 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013122 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013123 .info = snd_hda_mixer_amp_switch_info,
13124 .get = snd_hda_mixer_amp_switch_get,
13125 .put = alc268_acer_master_sw_put,
13126 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13127 },
13128 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
13129 { }
13130};
13131
Takashi Iwaid2738092007-08-16 14:59:45 +020013132static struct snd_kcontrol_new alc268_acer_mixer[] = {
13133 /* output mixer control */
13134 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13135 {
13136 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13137 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013138 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020013139 .info = snd_hda_mixer_amp_switch_info,
13140 .get = snd_hda_mixer_amp_switch_get,
13141 .put = alc268_acer_master_sw_put,
13142 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13143 },
David Henningsson5f99f862011-01-04 15:24:24 +010013144 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13145 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
13146 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020013147 { }
13148};
13149
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013150static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
13151 /* output mixer control */
13152 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13153 {
13154 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13155 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013156 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013157 .info = snd_hda_mixer_amp_switch_info,
13158 .get = snd_hda_mixer_amp_switch_get,
13159 .put = alc268_acer_master_sw_put,
13160 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13161 },
David Henningsson5f99f862011-01-04 15:24:24 +010013162 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13163 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013164 { }
13165};
13166
Kailang Yang8ef355d2008-08-26 13:10:22 +020013167static struct hda_verb alc268_acer_aspire_one_verbs[] = {
13168 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13169 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13170 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13171 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13172 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
13173 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
13174 { }
13175};
13176
Takashi Iwaid2738092007-08-16 14:59:45 +020013177static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013178 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
13179 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020013180 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13181 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013182 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13183 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020013184 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13185 { }
13186};
13187
13188/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020013189#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013190#define alc268_toshiba_setup alc262_hippo_setup
13191#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020013192
13193static void alc268_acer_unsol_event(struct hda_codec *codec,
13194 unsigned int res)
13195{
Takashi Iwai889c4392007-08-23 18:56:52 +020013196 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020013197 return;
13198 alc268_acer_automute(codec, 1);
13199}
13200
Takashi Iwai889c4392007-08-23 18:56:52 +020013201static void alc268_acer_init_hook(struct hda_codec *codec)
13202{
13203 alc268_acer_automute(codec, 1);
13204}
13205
Kailang Yang8ef355d2008-08-26 13:10:22 +020013206/* toggle speaker-output according to the hp-jack state */
13207static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
13208{
13209 unsigned int present;
13210 unsigned char bits;
13211
Wu Fengguang864f92b2009-11-18 12:38:02 +080013212 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013213 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013214 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013215 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013216 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013217 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013218}
13219
Kailang Yang8ef355d2008-08-26 13:10:22 +020013220static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
13221 unsigned int res)
13222{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013223 switch (res >> 26) {
13224 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020013225 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013226 break;
13227 case ALC880_MIC_EVENT:
13228 alc_mic_automute(codec);
13229 break;
13230 }
13231}
13232
13233static void alc268_acer_lc_setup(struct hda_codec *codec)
13234{
13235 struct alc_spec *spec = codec->spec;
13236 spec->ext_mic.pin = 0x18;
13237 spec->ext_mic.mux_idx = 0;
13238 spec->int_mic.pin = 0x12;
13239 spec->int_mic.mux_idx = 6;
13240 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013241}
13242
13243static void alc268_acer_lc_init_hook(struct hda_codec *codec)
13244{
13245 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013246 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013247}
13248
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013249static struct snd_kcontrol_new alc268_dell_mixer[] = {
13250 /* output mixer control */
13251 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13252 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13253 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13254 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013255 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13256 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013257 { }
13258};
13259
13260static struct hda_verb alc268_dell_verbs[] = {
13261 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13262 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13263 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013264 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013265 { }
13266};
13267
13268/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013269static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013270{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013271 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013272
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013273 spec->autocfg.hp_pins[0] = 0x15;
13274 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013275 spec->ext_mic.pin = 0x18;
13276 spec->ext_mic.mux_idx = 0;
13277 spec->int_mic.pin = 0x19;
13278 spec->int_mic.mux_idx = 1;
13279 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013280}
13281
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013282static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
13283 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13284 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13285 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13286 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13287 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13288 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013289 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13290 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013291 { }
13292};
13293
13294static struct hda_verb alc267_quanta_il1_verbs[] = {
13295 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13296 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13297 { }
13298};
13299
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013300static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013301{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013302 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013303 spec->autocfg.hp_pins[0] = 0x15;
13304 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013305 spec->ext_mic.pin = 0x18;
13306 spec->ext_mic.mux_idx = 0;
13307 spec->int_mic.pin = 0x19;
13308 spec->int_mic.mux_idx = 1;
13309 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013310}
13311
Kailang Yanga361d842007-06-05 12:30:55 +020013312/*
13313 * generic initialization of ADC, input mixers and output mixers
13314 */
13315static struct hda_verb alc268_base_init_verbs[] = {
13316 /* Unmute DAC0-1 and set vol = 0 */
13317 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013318 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013319
13320 /*
13321 * Set up output mixers (0x0c - 0x0e)
13322 */
13323 /* set vol=0 to output mixers */
13324 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013325 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13326
13327 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13328 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13329
13330 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13331 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13332 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13333 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13334 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13335 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13336 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13337 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13338
13339 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13340 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13341 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13342 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013343 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013344
13345 /* set PCBEEP vol = 0, mute connections */
13346 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13347 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13348 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013349
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013350 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013351
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013352 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13353 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13354 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13355 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013356
Kailang Yanga361d842007-06-05 12:30:55 +020013357 { }
13358};
13359
13360/*
13361 * generic initialization of ADC, input mixers and output mixers
13362 */
13363static struct hda_verb alc268_volume_init_verbs[] = {
13364 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013365 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13366 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013367
13368 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13369 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13370 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13371 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13372 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13373
Kailang Yanga361d842007-06-05 12:30:55 +020013374 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013375 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13376 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13377
13378 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013379 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013380
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013381 /* set PCBEEP vol = 0, mute connections */
13382 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13383 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13384 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013385
13386 { }
13387};
13388
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013389static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13390 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13391 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13392 { } /* end */
13393};
13394
Kailang Yanga361d842007-06-05 12:30:55 +020013395static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13396 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13397 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013398 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013399 { } /* end */
13400};
13401
13402static struct snd_kcontrol_new alc268_capture_mixer[] = {
13403 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13404 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13405 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13406 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013407 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013408 { } /* end */
13409};
13410
13411static struct hda_input_mux alc268_capture_source = {
13412 .num_items = 4,
13413 .items = {
13414 { "Mic", 0x0 },
13415 { "Front Mic", 0x1 },
13416 { "Line", 0x2 },
13417 { "CD", 0x3 },
13418 },
13419};
13420
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013421static struct hda_input_mux alc268_acer_capture_source = {
13422 .num_items = 3,
13423 .items = {
13424 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013425 { "Internal Mic", 0x1 },
13426 { "Line", 0x2 },
13427 },
13428};
13429
13430static struct hda_input_mux alc268_acer_dmic_capture_source = {
13431 .num_items = 3,
13432 .items = {
13433 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013434 { "Internal Mic", 0x6 },
13435 { "Line", 0x2 },
13436 },
13437};
13438
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013439#ifdef CONFIG_SND_DEBUG
13440static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013441 /* Volume widgets */
13442 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13443 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13444 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13445 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13446 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13447 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13448 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13449 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13450 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13451 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13452 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13453 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13454 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013455 /* The below appears problematic on some hardwares */
13456 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013457 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13458 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13459 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13460 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13461
13462 /* Modes for retasking pin widgets */
13463 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13464 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13465 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13466 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13467
13468 /* Controls for GPIO pins, assuming they are configured as outputs */
13469 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13470 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13471 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13472 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13473
13474 /* Switches to allow the digital SPDIF output pin to be enabled.
13475 * The ALC268 does not have an SPDIF input.
13476 */
13477 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13478
13479 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13480 * this output to turn on an external amplifier.
13481 */
13482 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13483 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13484
13485 { } /* end */
13486};
13487#endif
13488
Kailang Yanga361d842007-06-05 12:30:55 +020013489/* create input playback/capture controls for the given pin */
13490static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13491 const char *ctlname, int idx)
13492{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013493 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013494 int err;
13495
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013496 switch (nid) {
13497 case 0x14:
13498 case 0x16:
13499 dac = 0x02;
13500 break;
13501 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013502 case 0x1a: /* ALC259/269 only */
13503 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013504 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013505 dac = 0x03;
13506 break;
13507 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013508 snd_printd(KERN_WARNING "hda_codec: "
13509 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013510 return 0;
13511 }
13512 if (spec->multiout.dac_nids[0] != dac &&
13513 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013514 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013515 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013516 HDA_OUTPUT));
13517 if (err < 0)
13518 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013519 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13520 }
13521
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013522 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013523 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013524 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013525 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013526 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013527 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013528 if (err < 0)
13529 return err;
13530 return 0;
13531}
13532
13533/* add playback controls from the parsed DAC table */
13534static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13535 const struct auto_pin_cfg *cfg)
13536{
13537 hda_nid_t nid;
13538 int err;
13539
Kailang Yanga361d842007-06-05 12:30:55 +020013540 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013541
13542 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013543 if (nid) {
13544 const char *name;
13545 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13546 name = "Speaker";
13547 else
13548 name = "Front";
13549 err = alc268_new_analog_output(spec, nid, name, 0);
13550 if (err < 0)
13551 return err;
13552 }
Kailang Yanga361d842007-06-05 12:30:55 +020013553
13554 nid = cfg->speaker_pins[0];
13555 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013556 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013557 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13558 if (err < 0)
13559 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013560 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013561 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13562 if (err < 0)
13563 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013564 }
13565 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013566 if (nid) {
13567 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13568 if (err < 0)
13569 return err;
13570 }
Kailang Yanga361d842007-06-05 12:30:55 +020013571
13572 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13573 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013574 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013575 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013576 if (err < 0)
13577 return err;
13578 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013579 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013580}
13581
13582/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013583static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013584 const struct auto_pin_cfg *cfg)
13585{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013586 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013587}
13588
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013589static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13590 hda_nid_t nid, int pin_type)
13591{
13592 int idx;
13593
13594 alc_set_pin_output(codec, nid, pin_type);
13595 if (nid == 0x14 || nid == 0x16)
13596 idx = 0;
13597 else
13598 idx = 1;
13599 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13600}
13601
13602static void alc268_auto_init_multi_out(struct hda_codec *codec)
13603{
13604 struct alc_spec *spec = codec->spec;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013605 int i;
13606
13607 for (i = 0; i < spec->autocfg.line_outs; i++) {
13608 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013609 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13610 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13611 }
13612}
13613
13614static void alc268_auto_init_hp_out(struct hda_codec *codec)
13615{
13616 struct alc_spec *spec = codec->spec;
13617 hda_nid_t pin;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013618 int i;
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013619
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013620 for (i = 0; i < spec->autocfg.hp_outs; i++) {
13621 pin = spec->autocfg.hp_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013622 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013623 }
13624 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
13625 pin = spec->autocfg.speaker_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013626 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013627 }
13628 if (spec->autocfg.mono_out_pin)
13629 snd_hda_codec_write(codec, spec->autocfg.mono_out_pin, 0,
13630 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013631}
13632
Kailang Yanga361d842007-06-05 12:30:55 +020013633static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13634{
13635 struct alc_spec *spec = codec->spec;
13636 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13637 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13638 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13639 unsigned int dac_vol1, dac_vol2;
13640
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013641 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013642 snd_hda_codec_write(codec, speaker_nid, 0,
13643 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013644 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013645 snd_hda_codec_write(codec, 0x0f, 0,
13646 AC_VERB_SET_AMP_GAIN_MUTE,
13647 AMP_IN_UNMUTE(1));
13648 snd_hda_codec_write(codec, 0x10, 0,
13649 AC_VERB_SET_AMP_GAIN_MUTE,
13650 AMP_IN_UNMUTE(1));
13651 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013652 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013653 snd_hda_codec_write(codec, 0x0f, 0,
13654 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13655 snd_hda_codec_write(codec, 0x10, 0,
13656 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13657 }
13658
13659 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013660 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013661 dac_vol2 = AMP_OUT_ZERO;
13662 else if (line_nid == 0x15)
13663 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013664 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013665 dac_vol2 = AMP_OUT_ZERO;
13666 else if (hp_nid == 0x15)
13667 dac_vol1 = AMP_OUT_ZERO;
13668 if (line_nid != 0x16 || hp_nid != 0x16 ||
13669 spec->autocfg.line_out_pins[1] != 0x16 ||
13670 spec->autocfg.line_out_pins[2] != 0x16)
13671 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13672
13673 snd_hda_codec_write(codec, 0x02, 0,
13674 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13675 snd_hda_codec_write(codec, 0x03, 0,
13676 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13677}
13678
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013679/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013680#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13681#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013682#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013683#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13684
13685/*
13686 * BIOS auto configuration
13687 */
13688static int alc268_parse_auto_config(struct hda_codec *codec)
13689{
13690 struct alc_spec *spec = codec->spec;
13691 int err;
13692 static hda_nid_t alc268_ignore[] = { 0 };
13693
13694 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13695 alc268_ignore);
13696 if (err < 0)
13697 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013698 if (!spec->autocfg.line_outs) {
13699 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13700 spec->multiout.max_channels = 2;
13701 spec->no_analog = 1;
13702 goto dig_only;
13703 }
Kailang Yanga361d842007-06-05 12:30:55 +020013704 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013705 }
Kailang Yanga361d842007-06-05 12:30:55 +020013706 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13707 if (err < 0)
13708 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013709 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013710 if (err < 0)
13711 return err;
13712
13713 spec->multiout.max_channels = 2;
13714
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013715 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013716 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013717 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013718 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013719 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013720
Takashi Iwai892981f2009-03-02 08:04:35 +010013721 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013722 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013723
Takashi Iwaid88897e2008-10-31 15:01:37 +010013724 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013725 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013726 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013727
Takashi Iwai776e1842007-08-29 15:07:11 +020013728 err = alc_auto_add_mic_boost(codec);
13729 if (err < 0)
13730 return err;
13731
Kailang Yang6227cdc2010-02-25 08:36:52 +010013732 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013733
Kailang Yanga361d842007-06-05 12:30:55 +020013734 return 1;
13735}
13736
Kailang Yanga361d842007-06-05 12:30:55 +020013737#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13738
13739/* init callback for auto-configuration model -- overriding the default init */
13740static void alc268_auto_init(struct hda_codec *codec)
13741{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013742 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013743 alc268_auto_init_multi_out(codec);
13744 alc268_auto_init_hp_out(codec);
13745 alc268_auto_init_mono_speaker_out(codec);
13746 alc268_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013747 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013748 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013749 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013750}
13751
13752/*
13753 * configuration and preset
13754 */
Takashi Iwaiea734962011-01-17 11:29:34 +010013755static const char * const alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013756 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013757 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013758 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013759 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013760 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013761 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013762 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013763 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013764#ifdef CONFIG_SND_DEBUG
13765 [ALC268_TEST] = "test",
13766#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013767 [ALC268_AUTO] = "auto",
13768};
13769
13770static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013771 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013772 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013773 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013774 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013775 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013776 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13777 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013778 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013779 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13780 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013781 /* almost compatible with toshiba but with optional digital outs;
13782 * auto-probing seems working fine
13783 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013784 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013785 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013786 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013787 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013788 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013789 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013790 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013791 {}
13792};
13793
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013794/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13795static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13796 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13797 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13798 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13799 ALC268_TOSHIBA),
13800 {}
13801};
13802
Kailang Yanga361d842007-06-05 12:30:55 +020013803static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013804 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013805 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13806 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013807 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13808 alc267_quanta_il1_verbs },
13809 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13810 .dac_nids = alc268_dac_nids,
13811 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13812 .adc_nids = alc268_adc_nids_alt,
13813 .hp_nid = 0x03,
13814 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13815 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013816 .unsol_event = alc_sku_unsol_event,
13817 .setup = alc267_quanta_il1_setup,
13818 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013819 },
Kailang Yanga361d842007-06-05 12:30:55 +020013820 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013821 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13822 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013823 .init_verbs = { alc268_base_init_verbs },
13824 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13825 .dac_nids = alc268_dac_nids,
13826 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13827 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013828 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013829 .hp_nid = 0x03,
13830 .dig_out_nid = ALC268_DIGOUT_NID,
13831 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13832 .channel_mode = alc268_modes,
13833 .input_mux = &alc268_capture_source,
13834 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013835 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013836 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013837 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013838 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13839 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013840 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13841 .dac_nids = alc268_dac_nids,
13842 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13843 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013844 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013845 .hp_nid = 0x03,
13846 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13847 .channel_mode = alc268_modes,
13848 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013849 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013850 .setup = alc268_toshiba_setup,
13851 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013852 },
13853 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013854 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013855 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013856 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13857 alc268_acer_verbs },
13858 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13859 .dac_nids = alc268_dac_nids,
13860 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13861 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013862 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013863 .hp_nid = 0x02,
13864 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13865 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013866 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013867 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013868 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013869 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013870 [ALC268_ACER_DMIC] = {
13871 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13872 alc268_beep_mixer },
13873 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13874 alc268_acer_verbs },
13875 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13876 .dac_nids = alc268_dac_nids,
13877 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13878 .adc_nids = alc268_adc_nids_alt,
13879 .capsrc_nids = alc268_capsrc_nids,
13880 .hp_nid = 0x02,
13881 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13882 .channel_mode = alc268_modes,
13883 .input_mux = &alc268_acer_dmic_capture_source,
13884 .unsol_event = alc268_acer_unsol_event,
13885 .init_hook = alc268_acer_init_hook,
13886 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013887 [ALC268_ACER_ASPIRE_ONE] = {
13888 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013889 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013890 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013891 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13892 alc268_acer_aspire_one_verbs },
13893 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13894 .dac_nids = alc268_dac_nids,
13895 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13896 .adc_nids = alc268_adc_nids_alt,
13897 .capsrc_nids = alc268_capsrc_nids,
13898 .hp_nid = 0x03,
13899 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13900 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013901 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013902 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013903 .init_hook = alc268_acer_lc_init_hook,
13904 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013905 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013906 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13907 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013908 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13909 alc268_dell_verbs },
13910 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13911 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013912 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13913 .adc_nids = alc268_adc_nids_alt,
13914 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013915 .hp_nid = 0x02,
13916 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13917 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013918 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013919 .setup = alc268_dell_setup,
13920 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013921 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013922 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013923 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13924 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013925 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13926 alc268_toshiba_verbs },
13927 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13928 .dac_nids = alc268_dac_nids,
13929 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13930 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013931 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013932 .hp_nid = 0x03,
13933 .dig_out_nid = ALC268_DIGOUT_NID,
13934 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13935 .channel_mode = alc268_modes,
13936 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013937 .setup = alc268_toshiba_setup,
13938 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013939 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013940#ifdef CONFIG_SND_DEBUG
13941 [ALC268_TEST] = {
13942 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13943 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13944 alc268_volume_init_verbs },
13945 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13946 .dac_nids = alc268_dac_nids,
13947 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13948 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013949 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013950 .hp_nid = 0x03,
13951 .dig_out_nid = ALC268_DIGOUT_NID,
13952 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13953 .channel_mode = alc268_modes,
13954 .input_mux = &alc268_capture_source,
13955 },
13956#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013957};
13958
13959static int patch_alc268(struct hda_codec *codec)
13960{
13961 struct alc_spec *spec;
13962 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013963 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013964
Julia Lawallef86f582009-12-19 08:18:03 +010013965 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013966 if (spec == NULL)
13967 return -ENOMEM;
13968
13969 codec->spec = spec;
13970
13971 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13972 alc268_models,
13973 alc268_cfg_tbl);
13974
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013975 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13976 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013977 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013978
Kailang Yanga361d842007-06-05 12:30:55 +020013979 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013980 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13981 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013982 board_config = ALC268_AUTO;
13983 }
13984
13985 if (board_config == ALC268_AUTO) {
13986 /* automatic parse from the BIOS config */
13987 err = alc268_parse_auto_config(codec);
13988 if (err < 0) {
13989 alc_free(codec);
13990 return err;
13991 } else if (!err) {
13992 printk(KERN_INFO
13993 "hda_codec: Cannot set up configuration "
13994 "from BIOS. Using base mode...\n");
13995 board_config = ALC268_3ST;
13996 }
13997 }
13998
13999 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014000 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020014001
Kailang Yanga361d842007-06-05 12:30:55 +020014002 spec->stream_analog_playback = &alc268_pcm_analog_playback;
14003 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010014004 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020014005
Kailang Yanga361d842007-06-05 12:30:55 +020014006 spec->stream_digital_playback = &alc268_pcm_digital_playback;
14007
Takashi Iwai22971e32009-02-10 11:56:44 +010014008 has_beep = 0;
14009 for (i = 0; i < spec->num_mixers; i++) {
14010 if (spec->mixers[i] == alc268_beep_mixer) {
14011 has_beep = 1;
14012 break;
14013 }
14014 }
14015
14016 if (has_beep) {
14017 err = snd_hda_attach_beep_device(codec, 0x1);
14018 if (err < 0) {
14019 alc_free(codec);
14020 return err;
14021 }
14022 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
14023 /* override the amp caps for beep generator */
14024 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014025 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
14026 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
14027 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
14028 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010014029 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014030
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014031 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014032 /* check whether NID 0x07 is valid */
14033 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010014034 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020014035
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014036 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014037 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020014038 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014039 if (spec->auto_mic ||
14040 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014041 spec->adc_nids = alc268_adc_nids_alt;
14042 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014043 if (spec->auto_mic)
14044 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014045 if (spec->auto_mic || spec->input_mux->num_items == 1)
14046 add_mixer(spec, alc268_capture_nosrc_mixer);
14047 else
14048 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014049 } else {
14050 spec->adc_nids = alc268_adc_nids;
14051 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010014052 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020014053 }
Takashi Iwai85860c02008-02-19 15:00:15 +010014054 /* set default input source */
14055 for (i = 0; i < spec->num_adc_nids; i++)
14056 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
14057 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030014058 i < spec->num_mux_defs ?
14059 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010014060 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020014061 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010014062
14063 spec->vmaster_nid = 0x02;
14064
Kailang Yanga361d842007-06-05 12:30:55 +020014065 codec->patch_ops = alc_patch_ops;
14066 if (board_config == ALC268_AUTO)
14067 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020014068
Kailang Yangbf1b0222010-10-21 08:49:56 +020014069 alc_init_jacks(codec);
14070
Kailang Yanga361d842007-06-05 12:30:55 +020014071 return 0;
14072}
14073
14074/*
Kailang Yangf6a92242007-12-13 16:52:54 +010014075 * ALC269 channel source setting (2 channel)
14076 */
14077#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
14078
14079#define alc269_dac_nids alc260_dac_nids
14080
14081static hda_nid_t alc269_adc_nids[1] = {
14082 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020014083 0x08,
14084};
14085
Takashi Iwaie01bf502008-08-21 16:25:07 +020014086static hda_nid_t alc269_capsrc_nids[1] = {
14087 0x23,
14088};
14089
Kailang Yang84898e82010-02-04 14:16:14 +010014090static hda_nid_t alc269vb_adc_nids[1] = {
14091 /* ADC1 */
14092 0x09,
14093};
14094
14095static hda_nid_t alc269vb_capsrc_nids[1] = {
14096 0x22,
14097};
14098
Takashi Iwai66946352010-03-29 17:21:45 +020014099static hda_nid_t alc269_adc_candidates[] = {
14100 0x08, 0x09, 0x07,
14101};
Takashi Iwaie01bf502008-08-21 16:25:07 +020014102
Kailang Yangf6a92242007-12-13 16:52:54 +010014103#define alc269_modes alc260_modes
14104#define alc269_capture_source alc880_lg_lw_capture_source
14105
14106static struct snd_kcontrol_new alc269_base_mixer[] = {
14107 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14108 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14109 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14110 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14111 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14112 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014113 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014114 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14115 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014116 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014117 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14118 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
14119 { } /* end */
14120};
14121
Kailang Yang60db6b52008-08-26 13:13:00 +020014122static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
14123 /* output mixer control */
14124 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14125 {
14126 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14127 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014128 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020014129 .info = snd_hda_mixer_amp_switch_info,
14130 .get = snd_hda_mixer_amp_switch_get,
14131 .put = alc268_acer_master_sw_put,
14132 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14133 },
14134 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14135 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014136 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014137 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14138 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014139 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014140 { }
14141};
14142
Tony Vroon64154832008-11-06 15:08:49 +000014143static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
14144 /* output mixer control */
14145 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14146 {
14147 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14148 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014149 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000014150 .info = snd_hda_mixer_amp_switch_info,
14151 .get = snd_hda_mixer_amp_switch_get,
14152 .put = alc268_acer_master_sw_put,
14153 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14154 },
14155 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14156 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014157 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014158 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14159 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014160 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014161 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
14162 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014163 HDA_CODEC_VOLUME("Dock Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014164 { }
14165};
14166
Kailang Yang84898e82010-02-04 14:16:14 +010014167static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020014168 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014169 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020014170 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014171 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020014172 { } /* end */
14173};
14174
Kailang Yang84898e82010-02-04 14:16:14 +010014175static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
14176 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14177 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14178 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14179 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14180 { } /* end */
14181};
14182
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014183static struct snd_kcontrol_new alc269_asus_mixer[] = {
14184 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14185 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
14186 { } /* end */
14187};
14188
Kailang Yangf6a92242007-12-13 16:52:54 +010014189/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010014190static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
14191 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14192 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014193 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14194 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014195 { } /* end */
14196};
14197
14198static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020014199 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14200 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014201 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010014202 { } /* end */
14203};
14204
Kailang Yang84898e82010-02-04 14:16:14 +010014205static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
14206 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14207 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014208 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14209 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014210 { } /* end */
14211};
14212
14213static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
14214 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14215 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014216 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014217 { } /* end */
14218};
14219
Takashi Iwai26f5df22008-11-03 17:39:46 +010014220/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010014221#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020014222
Kailang Yang60db6b52008-08-26 13:13:00 +020014223static struct hda_verb alc269_quanta_fl1_verbs[] = {
14224 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14225 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14226 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14227 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14228 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14229 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14230 { }
14231};
14232
Tony Vroon64154832008-11-06 15:08:49 +000014233static struct hda_verb alc269_lifebook_verbs[] = {
14234 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14235 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
14236 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14237 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14238 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14239 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14240 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14241 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14242 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14243 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14244 { }
14245};
14246
Kailang Yang60db6b52008-08-26 13:13:00 +020014247/* toggle speaker-output according to the hp-jack state */
14248static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
14249{
14250 unsigned int present;
14251 unsigned char bits;
14252
Wu Fengguang864f92b2009-11-18 12:38:02 +080014253 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014254 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014255 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014256 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014257 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014258 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014259
14260 snd_hda_codec_write(codec, 0x20, 0,
14261 AC_VERB_SET_COEF_INDEX, 0x0c);
14262 snd_hda_codec_write(codec, 0x20, 0,
14263 AC_VERB_SET_PROC_COEF, 0x680);
14264
14265 snd_hda_codec_write(codec, 0x20, 0,
14266 AC_VERB_SET_COEF_INDEX, 0x0c);
14267 snd_hda_codec_write(codec, 0x20, 0,
14268 AC_VERB_SET_PROC_COEF, 0x480);
14269}
14270
Tony Vroon64154832008-11-06 15:08:49 +000014271/* toggle speaker-output according to the hp-jacks state */
14272static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
14273{
14274 unsigned int present;
14275 unsigned char bits;
14276
14277 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014278 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000014279
14280 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014281 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000014282
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014283 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000014284 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014285 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014286 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014287 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014288
14289 snd_hda_codec_write(codec, 0x20, 0,
14290 AC_VERB_SET_COEF_INDEX, 0x0c);
14291 snd_hda_codec_write(codec, 0x20, 0,
14292 AC_VERB_SET_PROC_COEF, 0x680);
14293
14294 snd_hda_codec_write(codec, 0x20, 0,
14295 AC_VERB_SET_COEF_INDEX, 0x0c);
14296 snd_hda_codec_write(codec, 0x20, 0,
14297 AC_VERB_SET_PROC_COEF, 0x480);
14298}
14299
Tony Vroon64154832008-11-06 15:08:49 +000014300static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14301{
14302 unsigned int present_laptop;
14303 unsigned int present_dock;
14304
Wu Fengguang864f92b2009-11-18 12:38:02 +080014305 present_laptop = snd_hda_jack_detect(codec, 0x18);
14306 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014307
14308 /* Laptop mic port overrides dock mic port, design decision */
14309 if (present_dock)
14310 snd_hda_codec_write(codec, 0x23, 0,
14311 AC_VERB_SET_CONNECT_SEL, 0x3);
14312 if (present_laptop)
14313 snd_hda_codec_write(codec, 0x23, 0,
14314 AC_VERB_SET_CONNECT_SEL, 0x0);
14315 if (!present_dock && !present_laptop)
14316 snd_hda_codec_write(codec, 0x23, 0,
14317 AC_VERB_SET_CONNECT_SEL, 0x1);
14318}
14319
Kailang Yang60db6b52008-08-26 13:13:00 +020014320static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14321 unsigned int res)
14322{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014323 switch (res >> 26) {
14324 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014325 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014326 break;
14327 case ALC880_MIC_EVENT:
14328 alc_mic_automute(codec);
14329 break;
14330 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014331}
14332
Tony Vroon64154832008-11-06 15:08:49 +000014333static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14334 unsigned int res)
14335{
14336 if ((res >> 26) == ALC880_HP_EVENT)
14337 alc269_lifebook_speaker_automute(codec);
14338 if ((res >> 26) == ALC880_MIC_EVENT)
14339 alc269_lifebook_mic_autoswitch(codec);
14340}
14341
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014342static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14343{
14344 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014345 spec->autocfg.hp_pins[0] = 0x15;
14346 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014347 spec->ext_mic.pin = 0x18;
14348 spec->ext_mic.mux_idx = 0;
14349 spec->int_mic.pin = 0x19;
14350 spec->int_mic.mux_idx = 1;
14351 spec->auto_mic = 1;
14352}
14353
Kailang Yang60db6b52008-08-26 13:13:00 +020014354static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14355{
14356 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014357 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014358}
14359
Tony Vroon64154832008-11-06 15:08:49 +000014360static void alc269_lifebook_init_hook(struct hda_codec *codec)
14361{
14362 alc269_lifebook_speaker_automute(codec);
14363 alc269_lifebook_mic_autoswitch(codec);
14364}
14365
Kailang Yang84898e82010-02-04 14:16:14 +010014366static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014367 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14368 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14369 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14370 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14371 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14372 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14373 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14374 {}
14375};
14376
Kailang Yang84898e82010-02-04 14:16:14 +010014377static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014378 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14379 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14380 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14381 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
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 alc269vb_laptop_dmic_init_verbs[] = {
14388 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14389 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14390 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14391 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14392 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14393 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14394 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14395 {}
14396};
14397
14398static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14399 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14400 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14401 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14402 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14403 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14404 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14405 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14406 {}
14407};
14408
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014409static struct hda_verb alc271_acer_dmic_verbs[] = {
14410 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14411 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14412 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14413 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14414 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14415 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14416 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14417 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14418 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14419 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14420 { }
14421};
14422
Kailang Yang60db6b52008-08-26 13:13:00 +020014423/* toggle speaker-output according to the hp-jack state */
14424static void alc269_speaker_automute(struct hda_codec *codec)
14425{
Kailang Yangebb83ee2009-12-17 12:23:00 +010014426 struct alc_spec *spec = codec->spec;
14427 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020014428 unsigned int present;
14429 unsigned char bits;
14430
Kailang Yangebb83ee2009-12-17 12:23:00 +010014431 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014432 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014433 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014434 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014435 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014436 HDA_AMP_MUTE, bits);
Takashi Iwaicd372fb2011-03-03 14:40:14 +010014437 snd_hda_input_jack_report(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020014438}
14439
Kailang Yang60db6b52008-08-26 13:13:00 +020014440/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010014441static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020014442 unsigned int res)
14443{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014444 switch (res >> 26) {
14445 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014446 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014447 break;
14448 case ALC880_MIC_EVENT:
14449 alc_mic_automute(codec);
14450 break;
14451 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014452}
14453
Kailang Yang226b1ec2010-04-09 11:01:20 +020014454static void alc269_laptop_amic_setup(struct hda_codec *codec)
14455{
14456 struct alc_spec *spec = codec->spec;
14457 spec->autocfg.hp_pins[0] = 0x15;
14458 spec->autocfg.speaker_pins[0] = 0x14;
14459 spec->ext_mic.pin = 0x18;
14460 spec->ext_mic.mux_idx = 0;
14461 spec->int_mic.pin = 0x19;
14462 spec->int_mic.mux_idx = 1;
14463 spec->auto_mic = 1;
14464}
14465
Kailang Yang84898e82010-02-04 14:16:14 +010014466static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014467{
14468 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014469 spec->autocfg.hp_pins[0] = 0x15;
14470 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014471 spec->ext_mic.pin = 0x18;
14472 spec->ext_mic.mux_idx = 0;
14473 spec->int_mic.pin = 0x12;
14474 spec->int_mic.mux_idx = 5;
14475 spec->auto_mic = 1;
14476}
14477
Kailang Yang226b1ec2010-04-09 11:01:20 +020014478static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014479{
14480 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014481 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014482 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014483 spec->ext_mic.pin = 0x18;
14484 spec->ext_mic.mux_idx = 0;
14485 spec->int_mic.pin = 0x19;
14486 spec->int_mic.mux_idx = 1;
14487 spec->auto_mic = 1;
14488}
14489
Kailang Yang226b1ec2010-04-09 11:01:20 +020014490static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14491{
14492 struct alc_spec *spec = codec->spec;
14493 spec->autocfg.hp_pins[0] = 0x21;
14494 spec->autocfg.speaker_pins[0] = 0x14;
14495 spec->ext_mic.pin = 0x18;
14496 spec->ext_mic.mux_idx = 0;
14497 spec->int_mic.pin = 0x12;
14498 spec->int_mic.mux_idx = 6;
14499 spec->auto_mic = 1;
14500}
14501
Kailang Yang84898e82010-02-04 14:16:14 +010014502static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020014503{
14504 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014505 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014506}
14507
Kailang Yangf6a92242007-12-13 16:52:54 +010014508/*
14509 * generic initialization of ADC, input mixers and output mixers
14510 */
14511static struct hda_verb alc269_init_verbs[] = {
14512 /*
14513 * Unmute ADC0 and set the default input to mic-in
14514 */
Kailang Yang84898e82010-02-04 14:16:14 +010014515 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014516
14517 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014518 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014519 */
14520 /* set vol=0 to output mixers */
14521 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14522 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14523
14524 /* set up input amps for analog loopback */
14525 /* Amp Indices: DAC = 0, mixer = 1 */
14526 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14527 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14528 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14529 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14530 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14531 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14532
14533 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14534 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14535 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14536 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14537 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14538 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14539 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14540
14541 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14542 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014543
Kailang Yang84898e82010-02-04 14:16:14 +010014544 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014545 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14546 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014547 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014548
14549 /* set EAPD */
14550 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014551 { }
14552};
14553
14554static struct hda_verb alc269vb_init_verbs[] = {
14555 /*
14556 * Unmute ADC0 and set the default input to mic-in
14557 */
14558 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14559
14560 /*
14561 * Set up output mixers (0x02 - 0x03)
14562 */
14563 /* set vol=0 to output mixers */
14564 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14565 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14566
14567 /* set up input amps for analog loopback */
14568 /* Amp Indices: DAC = 0, mixer = 1 */
14569 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14570 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14571 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14572 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14573 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14574 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14575
14576 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14577 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14578 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14579 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14580 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14581 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14582 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14583
14584 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14585 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14586
14587 /* FIXME: use Mux-type input source selection */
14588 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14589 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14590 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14591
14592 /* set EAPD */
14593 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014594 { }
14595};
14596
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014597#define alc269_auto_create_multi_out_ctls \
14598 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014599#define alc269_auto_create_input_ctls \
14600 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014601
14602#ifdef CONFIG_SND_HDA_POWER_SAVE
14603#define alc269_loopbacks alc880_loopbacks
14604#endif
14605
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014606/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014607#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14608#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14609#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14610#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14611
Takashi Iwaif03d3112009-03-05 14:18:16 +010014612static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14613 .substreams = 1,
14614 .channels_min = 2,
14615 .channels_max = 8,
14616 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14617 /* NID is set in alc_build_pcms */
14618 .ops = {
14619 .open = alc880_playback_pcm_open,
14620 .prepare = alc880_playback_pcm_prepare,
14621 .cleanup = alc880_playback_pcm_cleanup
14622 },
14623};
14624
14625static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14626 .substreams = 1,
14627 .channels_min = 2,
14628 .channels_max = 2,
14629 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14630 /* NID is set in alc_build_pcms */
14631};
14632
Takashi Iwaiad358792010-03-30 18:00:59 +020014633#ifdef CONFIG_SND_HDA_POWER_SAVE
14634static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14635{
14636 switch (codec->subsystem_id) {
14637 case 0x103c1586:
14638 return 1;
14639 }
14640 return 0;
14641}
14642
14643static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14644{
14645 /* update mute-LED according to the speaker mute state */
14646 if (nid == 0x01 || nid == 0x14) {
14647 int pinval;
14648 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14649 HDA_AMP_MUTE)
14650 pinval = 0x24;
14651 else
14652 pinval = 0x20;
14653 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a542010-03-30 18:03:44 +020014654 snd_hda_codec_update_cache(codec, 0x19, 0,
14655 AC_VERB_SET_PIN_WIDGET_CONTROL,
14656 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014657 }
14658 return alc_check_power_status(codec, nid);
14659}
14660#endif /* CONFIG_SND_HDA_POWER_SAVE */
14661
Takashi Iwai840b64c2010-07-13 22:49:01 +020014662static int alc275_setup_dual_adc(struct hda_codec *codec)
14663{
14664 struct alc_spec *spec = codec->spec;
14665
14666 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14667 return 0;
14668 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14669 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14670 if (spec->ext_mic.pin <= 0x12) {
14671 spec->private_adc_nids[0] = 0x08;
14672 spec->private_adc_nids[1] = 0x11;
14673 spec->private_capsrc_nids[0] = 0x23;
14674 spec->private_capsrc_nids[1] = 0x22;
14675 } else {
14676 spec->private_adc_nids[0] = 0x11;
14677 spec->private_adc_nids[1] = 0x08;
14678 spec->private_capsrc_nids[0] = 0x22;
14679 spec->private_capsrc_nids[1] = 0x23;
14680 }
14681 spec->adc_nids = spec->private_adc_nids;
14682 spec->capsrc_nids = spec->private_capsrc_nids;
14683 spec->num_adc_nids = 2;
14684 spec->dual_adc_switch = 1;
14685 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14686 spec->adc_nids[0], spec->adc_nids[1]);
14687 return 1;
14688 }
14689 return 0;
14690}
14691
Takashi Iwaid433a672010-09-20 15:11:54 +020014692/* different alc269-variants */
14693enum {
14694 ALC269_TYPE_NORMAL,
Kailang Yang48c88e82010-11-23 08:56:16 +010014695 ALC269_TYPE_ALC258,
Takashi Iwaid433a672010-09-20 15:11:54 +020014696 ALC269_TYPE_ALC259,
Kailang Yang48c88e82010-11-23 08:56:16 +010014697 ALC269_TYPE_ALC269VB,
14698 ALC269_TYPE_ALC270,
Takashi Iwaid433a672010-09-20 15:11:54 +020014699 ALC269_TYPE_ALC271X,
14700};
14701
Kailang Yangf6a92242007-12-13 16:52:54 +010014702/*
14703 * BIOS auto configuration
14704 */
14705static int alc269_parse_auto_config(struct hda_codec *codec)
14706{
14707 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014708 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014709 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14710
14711 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14712 alc269_ignore);
14713 if (err < 0)
14714 return err;
14715
14716 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14717 if (err < 0)
14718 return err;
Takashi Iwaif3550d12010-09-20 15:09:03 +020014719 if (spec->codec_variant == ALC269_TYPE_NORMAL)
14720 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
14721 else
14722 err = alc_auto_create_input_ctls(codec, &spec->autocfg, 0,
14723 0x22, 0);
Kailang Yangf6a92242007-12-13 16:52:54 +010014724 if (err < 0)
14725 return err;
14726
14727 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14728
Takashi Iwai757899a2010-07-30 10:48:14 +020014729 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014730
Takashi Iwai603c4012008-07-30 15:01:44 +020014731 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014732 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014733
Takashi Iwaid433a672010-09-20 15:11:54 +020014734 if (spec->codec_variant != ALC269_TYPE_NORMAL) {
Kailang Yang84898e82010-02-04 14:16:14 +010014735 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014736 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014737 } else {
14738 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014739 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014740 }
14741
Kailang Yangf6a92242007-12-13 16:52:54 +010014742 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014743 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014744
14745 if (!alc275_setup_dual_adc(codec))
14746 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14747 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014748
Takashi Iwaie01bf502008-08-21 16:25:07 +020014749 /* set default input source */
Takashi Iwai840b64c2010-07-13 22:49:01 +020014750 if (!spec->dual_adc_switch)
Takashi Iwai748cce42010-08-04 07:37:39 +020014751 select_or_unmute_capsrc(codec, spec->capsrc_nids[0],
14752 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014753
14754 err = alc_auto_add_mic_boost(codec);
14755 if (err < 0)
14756 return err;
14757
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014758 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014759 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014760
Kailang Yangf6a92242007-12-13 16:52:54 +010014761 return 1;
14762}
14763
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014764#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14765#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014766#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14767
14768
14769/* init callback for auto-configuration model -- overriding the default init */
14770static void alc269_auto_init(struct hda_codec *codec)
14771{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014772 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014773 alc269_auto_init_multi_out(codec);
14774 alc269_auto_init_hp_out(codec);
14775 alc269_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014776 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014777 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014778 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014779}
14780
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014781#ifdef SND_HDA_NEEDS_RESUME
14782static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
14783{
14784 int val = alc_read_coef_idx(codec, 0x04);
14785 if (power_up)
14786 val |= 1 << 11;
14787 else
14788 val &= ~(1 << 11);
14789 alc_write_coef_idx(codec, 0x04, val);
14790}
14791
Kailang Yang977ddd62010-09-15 10:02:29 +020014792#ifdef CONFIG_SND_HDA_POWER_SAVE
14793static int alc269_suspend(struct hda_codec *codec, pm_message_t state)
14794{
14795 struct alc_spec *spec = codec->spec;
Kailang Yang977ddd62010-09-15 10:02:29 +020014796
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014797 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017)
14798 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014799 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014800 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014801 msleep(150);
14802 }
14803
14804 alc_shutup(codec);
14805 if (spec && spec->power_hook)
14806 spec->power_hook(codec);
14807 return 0;
14808}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014809#endif /* CONFIG_SND_HDA_POWER_SAVE */
14810
Kailang Yang977ddd62010-09-15 10:02:29 +020014811static int alc269_resume(struct hda_codec *codec)
14812{
Kailang Yang977ddd62010-09-15 10:02:29 +020014813 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014814 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014815 msleep(150);
14816 }
14817
14818 codec->patch_ops.init(codec);
14819
14820 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014821 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014822 msleep(200);
14823 }
14824
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014825 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018)
14826 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014827
14828 snd_hda_codec_resume_amp(codec);
14829 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +020014830 hda_call_check_power_status(codec, 0x01);
Kailang Yang977ddd62010-09-15 10:02:29 +020014831 return 0;
14832}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014833#endif /* SND_HDA_NEEDS_RESUME */
Kailang Yang977ddd62010-09-15 10:02:29 +020014834
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014835static void alc269_fixup_hweq(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014836 const struct alc_fixup *fix, int action)
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014837{
14838 int coef;
14839
Takashi Iwai58701122011-01-13 15:41:45 +010014840 if (action != ALC_FIXUP_ACT_INIT)
Takashi Iwai9fb1ef22011-01-13 14:40:43 +010014841 return;
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014842 coef = alc_read_coef_idx(codec, 0x1e);
14843 alc_write_coef_idx(codec, 0x1e, coef | 0x80);
14844}
14845
Takashi Iwaiff818c22010-04-12 08:59:25 +020014846enum {
14847 ALC269_FIXUP_SONY_VAIO,
Takashi Iwai74dc8902011-01-13 14:14:41 +010014848 ALC275_FIXUP_SONY_VAIO_GPIO2,
David Henningsson145a9022010-09-16 10:07:53 +020014849 ALC269_FIXUP_DELL_M101Z,
David Henningsson022c92b2010-12-17 20:43:04 +010014850 ALC269_FIXUP_SKU_IGNORE,
David Henningssonac612402010-12-15 09:18:18 +010014851 ALC269_FIXUP_ASUS_G73JW,
Kailang Yang357f9152011-01-12 08:12:52 +010014852 ALC269_FIXUP_LENOVO_EAPD,
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014853 ALC275_FIXUP_SONY_HWEQ,
Takashi Iwaiff818c22010-04-12 08:59:25 +020014854};
14855
Takashi Iwaiff818c22010-04-12 08:59:25 +020014856static const struct alc_fixup alc269_fixups[] = {
14857 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014858 .type = ALC_FIXUP_VERBS,
14859 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020014860 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14861 {}
14862 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014863 },
Takashi Iwai74dc8902011-01-13 14:14:41 +010014864 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014865 .type = ALC_FIXUP_VERBS,
14866 .v.verbs = (const struct hda_verb[]) {
Kailang Yang27855912010-12-21 09:09:53 +010014867 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
14868 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
14869 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
14870 { }
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014871 },
14872 .chained = true,
14873 .chain_id = ALC269_FIXUP_SONY_VAIO
Kailang Yang27855912010-12-21 09:09:53 +010014874 },
David Henningsson145a9022010-09-16 10:07:53 +020014875 [ALC269_FIXUP_DELL_M101Z] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014876 .type = ALC_FIXUP_VERBS,
14877 .v.verbs = (const struct hda_verb[]) {
David Henningsson145a9022010-09-16 10:07:53 +020014878 /* Enables internal speaker */
14879 {0x20, AC_VERB_SET_COEF_INDEX, 13},
14880 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
14881 {}
14882 }
14883 },
David Henningsson022c92b2010-12-17 20:43:04 +010014884 [ALC269_FIXUP_SKU_IGNORE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014885 .type = ALC_FIXUP_SKU,
14886 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonfe67b242010-12-15 08:01:46 +010014887 },
David Henningssonac612402010-12-15 09:18:18 +010014888 [ALC269_FIXUP_ASUS_G73JW] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014889 .type = ALC_FIXUP_PINS,
14890 .v.pins = (const struct alc_pincfg[]) {
David Henningssonac612402010-12-15 09:18:18 +010014891 { 0x17, 0x99130111 }, /* subwoofer */
14892 { }
14893 }
14894 },
Kailang Yang357f9152011-01-12 08:12:52 +010014895 [ALC269_FIXUP_LENOVO_EAPD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014896 .type = ALC_FIXUP_VERBS,
14897 .v.verbs = (const struct hda_verb[]) {
Kailang Yang357f9152011-01-12 08:12:52 +010014898 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
14899 {}
14900 }
14901 },
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014902 [ALC275_FIXUP_SONY_HWEQ] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014903 .type = ALC_FIXUP_FUNC,
14904 .v.func = alc269_fixup_hweq,
14905 .chained = true,
14906 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014907 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014908};
14909
14910static struct snd_pci_quirk alc269_fixup_tbl[] = {
Takashi Iwai74dc8902011-01-13 14:14:41 +010014911 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014912 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
14913 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
Takashi Iwai7039c742010-12-23 16:35:34 +010014914 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningsson145a9022010-09-16 10:07:53 +020014915 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
David Henningsson022c92b2010-12-17 20:43:04 +010014916 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
David Henningssonded9f522011-01-26 11:46:12 +010014917 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
14918 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
14919 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
14920 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
David Henningssonac612402010-12-15 09:18:18 +010014921 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
Kailang Yang357f9152011-01-12 08:12:52 +010014922 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014923 {}
14924};
14925
14926
Kailang Yangf6a92242007-12-13 16:52:54 +010014927/*
14928 * configuration and preset
14929 */
Takashi Iwaiea734962011-01-17 11:29:34 +010014930static const char * const alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014931 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014932 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014933 [ALC269_AMIC] = "laptop-amic",
14934 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014935 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014936 [ALC269_LIFEBOOK] = "lifebook",
14937 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014938};
14939
14940static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014941 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014942 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014943 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014944 ALC269_AMIC),
14945 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14946 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14947 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14948 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14949 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14950 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14951 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14952 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14953 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
Chih-Wei Huangc790ad32011-02-25 11:14:31 +080014954 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269VB_AMIC),
Kailang Yang84898e82010-02-04 14:16:14 +010014955 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14956 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14957 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14958 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14959 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14960 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14961 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14962 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14963 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14964 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14965 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14966 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14967 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14968 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14969 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14970 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14971 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14972 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14973 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14974 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14975 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14976 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14977 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14978 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14979 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14980 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014981 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014982 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014983 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014984 ALC269_DMIC),
14985 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14986 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014987 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014988 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014989 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14990 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14991 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14992 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14993 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14994 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014995 {}
14996};
14997
14998static struct alc_config_preset alc269_presets[] = {
14999 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015000 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010015001 .init_verbs = { alc269_init_verbs },
15002 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15003 .dac_nids = alc269_dac_nids,
15004 .hp_nid = 0x03,
15005 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15006 .channel_mode = alc269_modes,
15007 .input_mux = &alc269_capture_source,
15008 },
Kailang Yang60db6b52008-08-26 13:13:00 +020015009 [ALC269_QUANTA_FL1] = {
15010 .mixers = { alc269_quanta_fl1_mixer },
15011 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_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 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015019 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020015020 .init_hook = alc269_quanta_fl1_init_hook,
15021 },
Kailang Yang84898e82010-02-04 14:16:14 +010015022 [ALC269_AMIC] = {
15023 .mixers = { alc269_laptop_mixer },
15024 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020015025 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015026 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015027 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15028 .dac_nids = alc269_dac_nids,
15029 .hp_nid = 0x03,
15030 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15031 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015032 .unsol_event = alc269_laptop_unsol_event,
15033 .setup = alc269_laptop_amic_setup,
15034 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015035 },
Kailang Yang84898e82010-02-04 14:16:14 +010015036 [ALC269_DMIC] = {
15037 .mixers = { alc269_laptop_mixer },
15038 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020015039 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015040 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015041 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15042 .dac_nids = alc269_dac_nids,
15043 .hp_nid = 0x03,
15044 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15045 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015046 .unsol_event = alc269_laptop_unsol_event,
15047 .setup = alc269_laptop_dmic_setup,
15048 .init_hook = alc269_laptop_inithook,
15049 },
15050 [ALC269VB_AMIC] = {
15051 .mixers = { alc269vb_laptop_mixer },
15052 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
15053 .init_verbs = { alc269vb_init_verbs,
15054 alc269vb_laptop_amic_init_verbs },
15055 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15056 .dac_nids = alc269_dac_nids,
15057 .hp_nid = 0x03,
15058 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15059 .channel_mode = alc269_modes,
15060 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020015061 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010015062 .init_hook = alc269_laptop_inithook,
15063 },
15064 [ALC269VB_DMIC] = {
15065 .mixers = { alc269vb_laptop_mixer },
15066 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15067 .init_verbs = { alc269vb_init_verbs,
15068 alc269vb_laptop_dmic_init_verbs },
15069 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15070 .dac_nids = alc269_dac_nids,
15071 .hp_nid = 0x03,
15072 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15073 .channel_mode = alc269_modes,
15074 .unsol_event = alc269_laptop_unsol_event,
15075 .setup = alc269vb_laptop_dmic_setup,
15076 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015077 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015078 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015079 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010015080 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015081 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015082 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015083 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15084 .dac_nids = alc269_dac_nids,
15085 .hp_nid = 0x03,
15086 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15087 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015088 .unsol_event = alc269_laptop_unsol_event,
15089 .setup = alc269_laptop_dmic_setup,
15090 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015091 },
Tony Vroon64154832008-11-06 15:08:49 +000015092 [ALC269_LIFEBOOK] = {
15093 .mixers = { alc269_lifebook_mixer },
15094 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
15095 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15096 .dac_nids = alc269_dac_nids,
15097 .hp_nid = 0x03,
15098 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15099 .channel_mode = alc269_modes,
15100 .input_mux = &alc269_capture_source,
15101 .unsol_event = alc269_lifebook_unsol_event,
15102 .init_hook = alc269_lifebook_init_hook,
15103 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020015104 [ALC271_ACER] = {
15105 .mixers = { alc269_asus_mixer },
15106 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15107 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
15108 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15109 .dac_nids = alc269_dac_nids,
15110 .adc_nids = alc262_dmic_adc_nids,
15111 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
15112 .capsrc_nids = alc262_dmic_capsrc_nids,
15113 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15114 .channel_mode = alc269_modes,
15115 .input_mux = &alc269_capture_source,
15116 .dig_out_nid = ALC880_DIGOUT_NID,
15117 .unsol_event = alc_sku_unsol_event,
15118 .setup = alc269vb_laptop_dmic_setup,
15119 .init_hook = alc_inithook,
15120 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015121};
15122
Kailang Yang977ddd62010-09-15 10:02:29 +020015123static int alc269_fill_coef(struct hda_codec *codec)
15124{
15125 int val;
15126
15127 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
15128 alc_write_coef_idx(codec, 0xf, 0x960b);
15129 alc_write_coef_idx(codec, 0xe, 0x8817);
15130 }
15131
15132 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
15133 alc_write_coef_idx(codec, 0xf, 0x960b);
15134 alc_write_coef_idx(codec, 0xe, 0x8814);
15135 }
15136
15137 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
15138 val = alc_read_coef_idx(codec, 0x04);
15139 /* Power up output pin */
15140 alc_write_coef_idx(codec, 0x04, val | (1<<11));
15141 }
15142
15143 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
15144 val = alc_read_coef_idx(codec, 0xd);
15145 if ((val & 0x0c00) >> 10 != 0x1) {
15146 /* Capless ramp up clock control */
15147 alc_write_coef_idx(codec, 0xd, val | 1<<10);
15148 }
15149 val = alc_read_coef_idx(codec, 0x17);
15150 if ((val & 0x01c0) >> 6 != 0x4) {
15151 /* Class D power on reset */
15152 alc_write_coef_idx(codec, 0x17, val | 1<<7);
15153 }
15154 }
15155 return 0;
15156}
15157
Kailang Yangf6a92242007-12-13 16:52:54 +010015158static int patch_alc269(struct hda_codec *codec)
15159{
15160 struct alc_spec *spec;
Kailang Yang48c88e82010-11-23 08:56:16 +010015161 int board_config, coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010015162 int err;
15163
15164 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15165 if (spec == NULL)
15166 return -ENOMEM;
15167
15168 codec->spec = spec;
15169
Kailang Yangda00c242010-03-19 11:23:45 +010015170 alc_auto_parse_customize_define(codec);
15171
Kailang Yangc793bec2010-12-21 09:14:13 +010015172 if (codec->vendor_id == 0x10ec0269) {
15173 coef = alc_read_coef_idx(codec, 0);
15174 if ((coef & 0x00f0) == 0x0010) {
15175 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
15176 spec->cdefine.platform_type == 1) {
15177 alc_codec_rename(codec, "ALC271X");
15178 spec->codec_variant = ALC269_TYPE_ALC271X;
15179 } else if ((coef & 0xf000) == 0x1000) {
15180 spec->codec_variant = ALC269_TYPE_ALC270;
15181 } else if ((coef & 0xf000) == 0x2000) {
15182 alc_codec_rename(codec, "ALC259");
15183 spec->codec_variant = ALC269_TYPE_ALC259;
15184 } else if ((coef & 0xf000) == 0x3000) {
15185 alc_codec_rename(codec, "ALC258");
15186 spec->codec_variant = ALC269_TYPE_ALC258;
15187 } else {
15188 alc_codec_rename(codec, "ALC269VB");
15189 spec->codec_variant = ALC269_TYPE_ALC269VB;
15190 }
15191 } else
15192 alc_fix_pll_init(codec, 0x20, 0x04, 15);
15193 alc269_fill_coef(codec);
15194 }
Kailang Yang977ddd62010-09-15 10:02:29 +020015195
Kailang Yangf6a92242007-12-13 16:52:54 +010015196 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
15197 alc269_models,
15198 alc269_cfg_tbl);
15199
15200 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015201 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15202 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010015203 board_config = ALC269_AUTO;
15204 }
15205
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015206 if (board_config == ALC269_AUTO) {
15207 alc_pick_fixup(codec, NULL, alc269_fixup_tbl, alc269_fixups);
15208 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
15209 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020015210
Kailang Yangf6a92242007-12-13 16:52:54 +010015211 if (board_config == ALC269_AUTO) {
15212 /* automatic parse from the BIOS config */
15213 err = alc269_parse_auto_config(codec);
15214 if (err < 0) {
15215 alc_free(codec);
15216 return err;
15217 } else if (!err) {
15218 printk(KERN_INFO
15219 "hda_codec: Cannot set up configuration "
15220 "from BIOS. Using base mode...\n");
15221 board_config = ALC269_BASIC;
15222 }
15223 }
15224
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015225 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020015226 err = snd_hda_attach_beep_device(codec, 0x1);
15227 if (err < 0) {
15228 alc_free(codec);
15229 return err;
15230 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015231 }
15232
Kailang Yangf6a92242007-12-13 16:52:54 +010015233 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015234 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010015235
Kailang Yang84898e82010-02-04 14:16:14 +010015236 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010015237 /* Due to a hardware problem on Lenovo Ideadpad, we need to
15238 * fix the sample rate of analog I/O to 44.1kHz
15239 */
15240 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
15241 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020015242 } else if (spec->dual_adc_switch) {
15243 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15244 /* switch ADC dynamically */
15245 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010015246 } else {
15247 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15248 spec->stream_analog_capture = &alc269_pcm_analog_capture;
15249 }
Kailang Yangf6a92242007-12-13 16:52:54 +010015250 spec->stream_digital_playback = &alc269_pcm_digital_playback;
15251 spec->stream_digital_capture = &alc269_pcm_digital_capture;
15252
Takashi Iwai66946352010-03-29 17:21:45 +020015253 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
Kailang Yang1657cbd2010-11-23 08:53:32 +010015254 if (spec->codec_variant == ALC269_TYPE_NORMAL) {
Takashi Iwai66946352010-03-29 17:21:45 +020015255 spec->adc_nids = alc269_adc_nids;
15256 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
15257 spec->capsrc_nids = alc269_capsrc_nids;
15258 } else {
15259 spec->adc_nids = alc269vb_adc_nids;
15260 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
15261 spec->capsrc_nids = alc269vb_capsrc_nids;
15262 }
Kailang Yang84898e82010-02-04 14:16:14 +010015263 }
15264
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015265 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015266 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015267 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010015268 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010015269
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015270 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaiff818c22010-04-12 08:59:25 +020015271
Takashi Iwai100d5eb2009-08-10 11:55:51 +020015272 spec->vmaster_nid = 0x02;
15273
Kailang Yangf6a92242007-12-13 16:52:54 +010015274 codec->patch_ops = alc_patch_ops;
Kailang Yang977ddd62010-09-15 10:02:29 +020015275#ifdef CONFIG_SND_HDA_POWER_SAVE
15276 codec->patch_ops.suspend = alc269_suspend;
15277#endif
15278#ifdef SND_HDA_NEEDS_RESUME
15279 codec->patch_ops.resume = alc269_resume;
15280#endif
Kailang Yangf6a92242007-12-13 16:52:54 +010015281 if (board_config == ALC269_AUTO)
15282 spec->init_hook = alc269_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020015283
15284 alc_init_jacks(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010015285#ifdef CONFIG_SND_HDA_POWER_SAVE
15286 if (!spec->loopback.amplist)
15287 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020015288 if (alc269_mic2_for_mute_led(codec))
15289 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010015290#endif
15291
15292 return 0;
15293}
15294
15295/*
Kailang Yangdf694da2005-12-05 19:42:22 +010015296 * ALC861 channel source setting (2/6 channel selection for 3-stack)
15297 */
15298
15299/*
15300 * set the path ways for 2 channel output
15301 * need to set the codec line out and mic 1 pin widgets to inputs
15302 */
15303static struct hda_verb alc861_threestack_ch2_init[] = {
15304 /* set pin widget 1Ah (line in) for input */
15305 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015306 /* set pin widget 18h (mic1/2) for input, for mic also enable
15307 * the vref
15308 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015309 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15310
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015311 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15312#if 0
15313 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15314 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15315#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015316 { } /* end */
15317};
15318/*
15319 * 6ch mode
15320 * need to set the codec line out and mic 1 pin widgets to outputs
15321 */
15322static struct hda_verb alc861_threestack_ch6_init[] = {
15323 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15324 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15325 /* set pin widget 18h (mic1) for output (CLFE)*/
15326 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15327
15328 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015329 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015330
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015331 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15332#if 0
15333 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15334 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15335#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015336 { } /* end */
15337};
15338
15339static struct hda_channel_mode alc861_threestack_modes[2] = {
15340 { 2, alc861_threestack_ch2_init },
15341 { 6, alc861_threestack_ch6_init },
15342};
Takashi Iwai22309c32006-08-09 16:57:28 +020015343/* Set mic1 as input and unmute the mixer */
15344static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
15345 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15346 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15347 { } /* end */
15348};
15349/* Set mic1 as output and mute mixer */
15350static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
15351 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15352 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15353 { } /* end */
15354};
15355
15356static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
15357 { 2, alc861_uniwill_m31_ch2_init },
15358 { 4, alc861_uniwill_m31_ch4_init },
15359};
Kailang Yangdf694da2005-12-05 19:42:22 +010015360
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015361/* Set mic1 and line-in as input and unmute the mixer */
15362static struct hda_verb alc861_asus_ch2_init[] = {
15363 /* set pin widget 1Ah (line in) for input */
15364 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015365 /* set pin widget 18h (mic1/2) for input, for mic also enable
15366 * the vref
15367 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015368 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15369
15370 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15371#if 0
15372 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15373 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15374#endif
15375 { } /* end */
15376};
15377/* Set mic1 nad line-in as output and mute mixer */
15378static struct hda_verb alc861_asus_ch6_init[] = {
15379 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15380 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15381 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15382 /* set pin widget 18h (mic1) for output (CLFE)*/
15383 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15384 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15385 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
15386 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
15387
15388 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15389#if 0
15390 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15391 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15392#endif
15393 { } /* end */
15394};
15395
15396static struct hda_channel_mode alc861_asus_modes[2] = {
15397 { 2, alc861_asus_ch2_init },
15398 { 6, alc861_asus_ch6_init },
15399};
15400
Kailang Yangdf694da2005-12-05 19:42:22 +010015401/* patch-ALC861 */
15402
15403static struct snd_kcontrol_new alc861_base_mixer[] = {
15404 /* output mixer control */
15405 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15406 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15407 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15408 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15409 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15410
15411 /*Input mixer control */
15412 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15413 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15414 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15415 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15416 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15417 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15418 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15419 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15420 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15421 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015422
Kailang Yangdf694da2005-12-05 19:42:22 +010015423 { } /* end */
15424};
15425
15426static struct snd_kcontrol_new alc861_3ST_mixer[] = {
15427 /* output mixer control */
15428 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15429 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15430 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15431 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15432 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15433
15434 /* Input mixer control */
15435 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15436 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15437 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15438 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15439 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15440 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15441 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15442 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15443 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15444 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015445
Kailang Yangdf694da2005-12-05 19:42:22 +010015446 {
15447 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15448 .name = "Channel Mode",
15449 .info = alc_ch_mode_info,
15450 .get = alc_ch_mode_get,
15451 .put = alc_ch_mode_put,
15452 .private_value = ARRAY_SIZE(alc861_threestack_modes),
15453 },
15454 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015455};
15456
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015457static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015458 /* output mixer control */
15459 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15460 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15461 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015462
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015463 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015464};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015465
Takashi Iwai22309c32006-08-09 16:57:28 +020015466static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
15467 /* output mixer control */
15468 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15469 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15470 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15471 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15472 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15473
15474 /* Input mixer control */
15475 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15476 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15477 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15478 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15479 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15480 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15481 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15482 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15483 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15484 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015485
Takashi Iwai22309c32006-08-09 16:57:28 +020015486 {
15487 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15488 .name = "Channel Mode",
15489 .info = alc_ch_mode_info,
15490 .get = alc_ch_mode_get,
15491 .put = alc_ch_mode_put,
15492 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15493 },
15494 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015495};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015496
15497static struct snd_kcontrol_new alc861_asus_mixer[] = {
15498 /* output mixer control */
15499 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15500 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15501 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15502 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15503 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15504
15505 /* Input mixer control */
15506 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15507 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15508 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15509 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15510 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15511 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15512 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15513 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15514 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015515 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15516
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015517 {
15518 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15519 .name = "Channel Mode",
15520 .info = alc_ch_mode_info,
15521 .get = alc_ch_mode_get,
15522 .put = alc_ch_mode_put,
15523 .private_value = ARRAY_SIZE(alc861_asus_modes),
15524 },
15525 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015526};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015527
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015528/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015529static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015530 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15531 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015532 { }
15533};
15534
Kailang Yangdf694da2005-12-05 19:42:22 +010015535/*
15536 * generic initialization of ADC, input mixers and output mixers
15537 */
15538static struct hda_verb alc861_base_init_verbs[] = {
15539 /*
15540 * Unmute ADC0 and set the default input to mic-in
15541 */
15542 /* port-A for surround (rear panel) */
15543 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15544 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15545 /* port-B for mic-in (rear panel) with vref */
15546 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15547 /* port-C for line-in (rear panel) */
15548 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15549 /* port-D for Front */
15550 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15551 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15552 /* port-E for HP out (front panel) */
15553 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15554 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015555 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015556 /* port-F for mic-in (front panel) with vref */
15557 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15558 /* port-G for CLFE (rear panel) */
15559 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15560 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15561 /* port-H for side (rear panel) */
15562 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15563 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15564 /* CD-in */
15565 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15566 /* route front mic to ADC1*/
15567 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15568 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015569
Kailang Yangdf694da2005-12-05 19:42:22 +010015570 /* Unmute DAC0~3 & spdif out*/
15571 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15572 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15573 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15574 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15575 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015576
Kailang Yangdf694da2005-12-05 19:42:22 +010015577 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15578 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15579 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15580 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15581 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015582
Kailang Yangdf694da2005-12-05 19:42:22 +010015583 /* Unmute Stereo Mixer 15 */
15584 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15585 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15586 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015587 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015588
15589 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15590 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15591 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15592 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15593 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15594 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15595 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15596 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015597 /* hp used DAC 3 (Front) */
15598 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015599 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15600
15601 { }
15602};
15603
15604static struct hda_verb alc861_threestack_init_verbs[] = {
15605 /*
15606 * Unmute ADC0 and set the default input to mic-in
15607 */
15608 /* port-A for surround (rear panel) */
15609 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15610 /* port-B for mic-in (rear panel) with vref */
15611 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15612 /* port-C for line-in (rear panel) */
15613 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15614 /* port-D for Front */
15615 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15616 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15617 /* port-E for HP out (front panel) */
15618 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15619 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015620 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015621 /* port-F for mic-in (front panel) with vref */
15622 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15623 /* port-G for CLFE (rear panel) */
15624 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15625 /* port-H for side (rear panel) */
15626 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15627 /* CD-in */
15628 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15629 /* route front mic to ADC1*/
15630 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15631 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15632 /* Unmute DAC0~3 & spdif out*/
15633 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15634 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15635 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15636 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15637 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015638
Kailang Yangdf694da2005-12-05 19:42:22 +010015639 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15640 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15641 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15642 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15643 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015644
Kailang Yangdf694da2005-12-05 19:42:22 +010015645 /* Unmute Stereo Mixer 15 */
15646 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15647 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15648 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015649 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015650
15651 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15652 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15653 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15654 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15655 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15656 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15657 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15658 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015659 /* hp used DAC 3 (Front) */
15660 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015661 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15662 { }
15663};
Takashi Iwai22309c32006-08-09 16:57:28 +020015664
15665static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15666 /*
15667 * Unmute ADC0 and set the default input to mic-in
15668 */
15669 /* port-A for surround (rear panel) */
15670 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15671 /* port-B for mic-in (rear panel) with vref */
15672 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15673 /* port-C for line-in (rear panel) */
15674 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15675 /* port-D for Front */
15676 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15677 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15678 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015679 /* this has to be set to VREF80 */
15680 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015681 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015682 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015683 /* port-F for mic-in (front panel) with vref */
15684 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15685 /* port-G for CLFE (rear panel) */
15686 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15687 /* port-H for side (rear panel) */
15688 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15689 /* CD-in */
15690 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15691 /* route front mic to ADC1*/
15692 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15693 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15694 /* Unmute DAC0~3 & spdif out*/
15695 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15696 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15697 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15698 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15699 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015700
Takashi Iwai22309c32006-08-09 16:57:28 +020015701 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15702 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15703 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15704 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15705 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015706
Takashi Iwai22309c32006-08-09 16:57:28 +020015707 /* Unmute Stereo Mixer 15 */
15708 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15709 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15710 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015711 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015712
15713 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15714 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15715 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15716 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15717 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15718 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15719 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15720 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015721 /* hp used DAC 3 (Front) */
15722 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015723 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15724 { }
15725};
15726
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015727static struct hda_verb alc861_asus_init_verbs[] = {
15728 /*
15729 * Unmute ADC0 and set the default input to mic-in
15730 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015731 /* port-A for surround (rear panel)
15732 * according to codec#0 this is the HP jack
15733 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015734 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15735 /* route front PCM to HP */
15736 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15737 /* port-B for mic-in (rear panel) with vref */
15738 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15739 /* port-C for line-in (rear panel) */
15740 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15741 /* port-D for Front */
15742 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15743 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15744 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015745 /* this has to be set to VREF80 */
15746 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015747 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015748 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015749 /* port-F for mic-in (front panel) with vref */
15750 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15751 /* port-G for CLFE (rear panel) */
15752 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15753 /* port-H for side (rear panel) */
15754 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15755 /* CD-in */
15756 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15757 /* route front mic to ADC1*/
15758 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15759 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15760 /* Unmute DAC0~3 & spdif out*/
15761 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15762 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15763 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15764 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15765 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15766 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15767 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15768 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15769 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15770 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015771
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015772 /* Unmute Stereo Mixer 15 */
15773 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15774 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15775 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015776 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015777
15778 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15779 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15780 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15781 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15782 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15783 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15784 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15785 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015786 /* hp used DAC 3 (Front) */
15787 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015788 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15789 { }
15790};
15791
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015792/* additional init verbs for ASUS laptops */
15793static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15794 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15795 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15796 { }
15797};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015798
Kailang Yangdf694da2005-12-05 19:42:22 +010015799/*
15800 * generic initialization of ADC, input mixers and output mixers
15801 */
15802static struct hda_verb alc861_auto_init_verbs[] = {
15803 /*
15804 * Unmute ADC0 and set the default input to mic-in
15805 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015806 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015807 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015808
Kailang Yangdf694da2005-12-05 19:42:22 +010015809 /* Unmute DAC0~3 & spdif out*/
15810 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15811 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15812 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15813 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15814 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015815
Kailang Yangdf694da2005-12-05 19:42:22 +010015816 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15817 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15818 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15819 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15820 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015821
Kailang Yangdf694da2005-12-05 19:42:22 +010015822 /* Unmute Stereo Mixer 15 */
15823 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15824 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15825 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15826 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15827
Takashi Iwai1c209302009-07-22 15:17:45 +020015828 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15829 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15830 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15831 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15832 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15833 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15834 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15835 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015836
15837 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15838 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015839 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15840 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015841 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15842 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015843 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15844 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015845
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015846 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015847
15848 { }
15849};
15850
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015851static struct hda_verb alc861_toshiba_init_verbs[] = {
15852 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015853
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015854 { }
15855};
15856
15857/* toggle speaker-output according to the hp-jack state */
15858static void alc861_toshiba_automute(struct hda_codec *codec)
15859{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015860 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015861
Takashi Iwai47fd8302007-08-10 17:11:07 +020015862 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15863 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15864 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15865 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015866}
15867
15868static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15869 unsigned int res)
15870{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015871 if ((res >> 26) == ALC880_HP_EVENT)
15872 alc861_toshiba_automute(codec);
15873}
15874
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015875/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015876#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15877#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15878#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15879#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15880
15881
15882#define ALC861_DIGOUT_NID 0x07
15883
15884static struct hda_channel_mode alc861_8ch_modes[1] = {
15885 { 8, NULL }
15886};
15887
15888static hda_nid_t alc861_dac_nids[4] = {
15889 /* front, surround, clfe, side */
15890 0x03, 0x06, 0x05, 0x04
15891};
15892
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015893static hda_nid_t alc660_dac_nids[3] = {
15894 /* front, clfe, surround */
15895 0x03, 0x05, 0x06
15896};
15897
Kailang Yangdf694da2005-12-05 19:42:22 +010015898static hda_nid_t alc861_adc_nids[1] = {
15899 /* ADC0-2 */
15900 0x08,
15901};
15902
15903static struct hda_input_mux alc861_capture_source = {
15904 .num_items = 5,
15905 .items = {
15906 { "Mic", 0x0 },
15907 { "Front Mic", 0x3 },
15908 { "Line", 0x1 },
15909 { "CD", 0x4 },
15910 { "Mixer", 0x5 },
15911 },
15912};
15913
Takashi Iwai1c209302009-07-22 15:17:45 +020015914static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15915{
15916 struct alc_spec *spec = codec->spec;
15917 hda_nid_t mix, srcs[5];
15918 int i, j, num;
15919
15920 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15921 return 0;
15922 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15923 if (num < 0)
15924 return 0;
15925 for (i = 0; i < num; i++) {
15926 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015927 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015928 if (type != AC_WID_AUD_OUT)
15929 continue;
15930 for (j = 0; j < spec->multiout.num_dacs; j++)
15931 if (spec->multiout.dac_nids[j] == srcs[i])
15932 break;
15933 if (j >= spec->multiout.num_dacs)
15934 return srcs[i];
15935 }
15936 return 0;
15937}
15938
Kailang Yangdf694da2005-12-05 19:42:22 +010015939/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015940static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015941 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015942{
Takashi Iwai1c209302009-07-22 15:17:45 +020015943 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015944 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015945 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015946
15947 spec->multiout.dac_nids = spec->private_dac_nids;
15948 for (i = 0; i < cfg->line_outs; i++) {
15949 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015950 dac = alc861_look_for_dac(codec, nid);
15951 if (!dac)
15952 continue;
15953 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015954 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015955 return 0;
15956}
15957
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015958static int __alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15959 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015960{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015961 return __add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015962 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15963}
15964
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015965#define alc861_create_out_sw(codec, pfx, nid, chs) \
15966 __alc861_create_out_sw(codec, pfx, nid, 0, chs)
15967
Takashi Iwai1c209302009-07-22 15:17:45 +020015968/* add playback controls from the parsed DAC table */
15969static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15970 const struct auto_pin_cfg *cfg)
15971{
15972 struct alc_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +010015973 static const char * const chname[4] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015974 "Front", "Surround", NULL /*CLFE*/, "Side"
15975 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015976 const char *pfx = alc_get_line_out_pfx(cfg, true);
Kailang Yangdf694da2005-12-05 19:42:22 +010015977 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015978 int i, err;
15979
Kailang Yangdf694da2005-12-05 19:42:22 +010015980 for (i = 0; i < cfg->line_outs; i++) {
15981 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015982 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015983 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015984 if (!pfx && i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015985 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015986 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015987 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015988 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015989 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015990 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015991 return err;
15992 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015993 const char *name = pfx;
15994 if (!name)
15995 name = chname[i];
15996 err = __alc861_create_out_sw(codec, name, nid, i, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015997 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015998 return err;
15999 }
16000 }
16001 return 0;
16002}
16003
Takashi Iwai1c209302009-07-22 15:17:45 +020016004static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010016005{
Takashi Iwai1c209302009-07-22 15:17:45 +020016006 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016007 int err;
16008 hda_nid_t nid;
16009
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016010 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010016011 return 0;
16012
16013 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020016014 nid = alc861_look_for_dac(codec, pin);
16015 if (nid) {
16016 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
16017 if (err < 0)
16018 return err;
16019 spec->multiout.hp_nid = nid;
16020 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016021 }
16022 return 0;
16023}
16024
16025/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016026static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016027 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010016028{
Takashi Iwai05f5f472009-08-25 13:10:18 +020016029 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010016030}
16031
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016032static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
16033 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020016034 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010016035{
Takashi Iwai1c209302009-07-22 15:17:45 +020016036 hda_nid_t mix, srcs[5];
16037 int i, num;
16038
Jacek Luczak564c5be2008-05-03 18:41:23 +020016039 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
16040 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020016041 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020016042 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020016043 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
16044 return;
16045 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
16046 if (num < 0)
16047 return;
16048 for (i = 0; i < num; i++) {
16049 unsigned int mute;
16050 if (srcs[i] == dac || srcs[i] == 0x15)
16051 mute = AMP_IN_UNMUTE(i);
16052 else
16053 mute = AMP_IN_MUTE(i);
16054 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16055 mute);
16056 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016057}
16058
16059static void alc861_auto_init_multi_out(struct hda_codec *codec)
16060{
16061 struct alc_spec *spec = codec->spec;
16062 int i;
16063
16064 for (i = 0; i < spec->autocfg.line_outs; i++) {
16065 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016066 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016067 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016068 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016069 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016070 }
16071}
16072
16073static void alc861_auto_init_hp_out(struct hda_codec *codec)
16074{
16075 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016076
Takashi Iwai15870f02009-10-05 08:25:13 +020016077 if (spec->autocfg.hp_outs)
16078 alc861_auto_set_output_and_unmute(codec,
16079 spec->autocfg.hp_pins[0],
16080 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020016081 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020016082 if (spec->autocfg.speaker_outs)
16083 alc861_auto_set_output_and_unmute(codec,
16084 spec->autocfg.speaker_pins[0],
16085 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020016086 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016087}
16088
16089static void alc861_auto_init_analog_input(struct hda_codec *codec)
16090{
16091 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016092 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010016093 int i;
16094
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016095 for (i = 0; i < cfg->num_inputs; i++) {
16096 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010016097 if (nid >= 0x0c && nid <= 0x11)
Takashi Iwai30ea0982010-09-16 18:47:56 +020016098 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016099 }
16100}
16101
16102/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016103/* return 1 if successful, 0 if the proper config is not found,
16104 * or a negative error code
16105 */
Kailang Yangdf694da2005-12-05 19:42:22 +010016106static int alc861_parse_auto_config(struct hda_codec *codec)
16107{
16108 struct alc_spec *spec = codec->spec;
16109 int err;
16110 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
16111
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016112 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16113 alc861_ignore);
16114 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016115 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016116 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010016117 return 0; /* can't find valid BIOS pin config */
16118
Takashi Iwai1c209302009-07-22 15:17:45 +020016119 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016120 if (err < 0)
16121 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016122 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016123 if (err < 0)
16124 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016125 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016126 if (err < 0)
16127 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016128 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016129 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016130 return err;
16131
16132 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16133
Takashi Iwai757899a2010-07-30 10:48:14 +020016134 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016135
Takashi Iwai603c4012008-07-30 15:01:44 +020016136 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016137 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010016138
Takashi Iwaid88897e2008-10-31 15:01:37 +010016139 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010016140
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020016141 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016142 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010016143
16144 spec->adc_nids = alc861_adc_nids;
16145 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016146 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016147
Kailang Yang6227cdc2010-02-25 08:36:52 +010016148 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016149
Kailang Yangdf694da2005-12-05 19:42:22 +010016150 return 1;
16151}
16152
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016153/* additional initialization for auto-configuration model */
16154static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010016155{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016156 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016157 alc861_auto_init_multi_out(codec);
16158 alc861_auto_init_hp_out(codec);
16159 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020016160 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016161 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016162 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016163}
16164
Takashi Iwaicb53c622007-08-10 17:21:45 +020016165#ifdef CONFIG_SND_HDA_POWER_SAVE
16166static struct hda_amp_list alc861_loopbacks[] = {
16167 { 0x15, HDA_INPUT, 0 },
16168 { 0x15, HDA_INPUT, 1 },
16169 { 0x15, HDA_INPUT, 2 },
16170 { 0x15, HDA_INPUT, 3 },
16171 { } /* end */
16172};
16173#endif
16174
Kailang Yangdf694da2005-12-05 19:42:22 +010016175
16176/*
16177 * configuration and preset
16178 */
Takashi Iwaiea734962011-01-17 11:29:34 +010016179static const char * const alc861_models[ALC861_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016180 [ALC861_3ST] = "3stack",
16181 [ALC660_3ST] = "3stack-660",
16182 [ALC861_3ST_DIG] = "3stack-dig",
16183 [ALC861_6ST_DIG] = "6stack-dig",
16184 [ALC861_UNIWILL_M31] = "uniwill-m31",
16185 [ALC861_TOSHIBA] = "toshiba",
16186 [ALC861_ASUS] = "asus",
16187 [ALC861_ASUS_LAPTOP] = "asus-laptop",
16188 [ALC861_AUTO] = "auto",
16189};
16190
16191static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010016192 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016193 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16194 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16195 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016196 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020016197 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010016198 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020016199 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
16200 * Any other models that need this preset?
16201 */
16202 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020016203 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
16204 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016205 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
16206 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
16207 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
16208 /* FIXME: the below seems conflict */
16209 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
16210 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
16211 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010016212 {}
16213};
16214
16215static struct alc_config_preset alc861_presets[] = {
16216 [ALC861_3ST] = {
16217 .mixers = { alc861_3ST_mixer },
16218 .init_verbs = { alc861_threestack_init_verbs },
16219 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16220 .dac_nids = alc861_dac_nids,
16221 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16222 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016223 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016224 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16225 .adc_nids = alc861_adc_nids,
16226 .input_mux = &alc861_capture_source,
16227 },
16228 [ALC861_3ST_DIG] = {
16229 .mixers = { alc861_base_mixer },
16230 .init_verbs = { alc861_threestack_init_verbs },
16231 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16232 .dac_nids = alc861_dac_nids,
16233 .dig_out_nid = ALC861_DIGOUT_NID,
16234 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16235 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016236 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016237 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16238 .adc_nids = alc861_adc_nids,
16239 .input_mux = &alc861_capture_source,
16240 },
16241 [ALC861_6ST_DIG] = {
16242 .mixers = { alc861_base_mixer },
16243 .init_verbs = { alc861_base_init_verbs },
16244 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16245 .dac_nids = alc861_dac_nids,
16246 .dig_out_nid = ALC861_DIGOUT_NID,
16247 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
16248 .channel_mode = alc861_8ch_modes,
16249 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16250 .adc_nids = alc861_adc_nids,
16251 .input_mux = &alc861_capture_source,
16252 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016253 [ALC660_3ST] = {
16254 .mixers = { alc861_3ST_mixer },
16255 .init_verbs = { alc861_threestack_init_verbs },
16256 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
16257 .dac_nids = alc660_dac_nids,
16258 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16259 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016260 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016261 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16262 .adc_nids = alc861_adc_nids,
16263 .input_mux = &alc861_capture_source,
16264 },
Takashi Iwai22309c32006-08-09 16:57:28 +020016265 [ALC861_UNIWILL_M31] = {
16266 .mixers = { alc861_uniwill_m31_mixer },
16267 .init_verbs = { alc861_uniwill_m31_init_verbs },
16268 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16269 .dac_nids = alc861_dac_nids,
16270 .dig_out_nid = ALC861_DIGOUT_NID,
16271 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
16272 .channel_mode = alc861_uniwill_m31_modes,
16273 .need_dac_fix = 1,
16274 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16275 .adc_nids = alc861_adc_nids,
16276 .input_mux = &alc861_capture_source,
16277 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016278 [ALC861_TOSHIBA] = {
16279 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016280 .init_verbs = { alc861_base_init_verbs,
16281 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016282 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16283 .dac_nids = alc861_dac_nids,
16284 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16285 .channel_mode = alc883_3ST_2ch_modes,
16286 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16287 .adc_nids = alc861_adc_nids,
16288 .input_mux = &alc861_capture_source,
16289 .unsol_event = alc861_toshiba_unsol_event,
16290 .init_hook = alc861_toshiba_automute,
16291 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020016292 [ALC861_ASUS] = {
16293 .mixers = { alc861_asus_mixer },
16294 .init_verbs = { alc861_asus_init_verbs },
16295 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16296 .dac_nids = alc861_dac_nids,
16297 .dig_out_nid = ALC861_DIGOUT_NID,
16298 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
16299 .channel_mode = alc861_asus_modes,
16300 .need_dac_fix = 1,
16301 .hp_nid = 0x06,
16302 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16303 .adc_nids = alc861_adc_nids,
16304 .input_mux = &alc861_capture_source,
16305 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010016306 [ALC861_ASUS_LAPTOP] = {
16307 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
16308 .init_verbs = { alc861_asus_init_verbs,
16309 alc861_asus_laptop_init_verbs },
16310 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16311 .dac_nids = alc861_dac_nids,
16312 .dig_out_nid = ALC861_DIGOUT_NID,
16313 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16314 .channel_mode = alc883_3ST_2ch_modes,
16315 .need_dac_fix = 1,
16316 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16317 .adc_nids = alc861_adc_nids,
16318 .input_mux = &alc861_capture_source,
16319 },
16320};
Kailang Yangdf694da2005-12-05 19:42:22 +010016321
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016322/* Pin config fixes */
16323enum {
16324 PINFIX_FSC_AMILO_PI1505,
16325};
16326
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016327static const struct alc_fixup alc861_fixups[] = {
16328 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016329 .type = ALC_FIXUP_PINS,
16330 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020016331 { 0x0b, 0x0221101f }, /* HP */
16332 { 0x0f, 0x90170310 }, /* speaker */
16333 { }
16334 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016335 },
16336};
16337
16338static struct snd_pci_quirk alc861_fixup_tbl[] = {
16339 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
16340 {}
16341};
Kailang Yangdf694da2005-12-05 19:42:22 +010016342
16343static int patch_alc861(struct hda_codec *codec)
16344{
16345 struct alc_spec *spec;
16346 int board_config;
16347 int err;
16348
Robert P. J. Daydc041e02006-12-19 14:44:15 +010016349 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010016350 if (spec == NULL)
16351 return -ENOMEM;
16352
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016353 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016354
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016355 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
16356 alc861_models,
16357 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016358
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016359 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016360 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16361 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010016362 board_config = ALC861_AUTO;
16363 }
16364
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016365 if (board_config == ALC861_AUTO) {
16366 alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
16367 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
16368 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016369
Kailang Yangdf694da2005-12-05 19:42:22 +010016370 if (board_config == ALC861_AUTO) {
16371 /* automatic parse from the BIOS config */
16372 err = alc861_parse_auto_config(codec);
16373 if (err < 0) {
16374 alc_free(codec);
16375 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016376 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016377 printk(KERN_INFO
16378 "hda_codec: Cannot set up configuration "
16379 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010016380 board_config = ALC861_3ST_DIG;
16381 }
16382 }
16383
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016384 err = snd_hda_attach_beep_device(codec, 0x23);
16385 if (err < 0) {
16386 alc_free(codec);
16387 return err;
16388 }
16389
Kailang Yangdf694da2005-12-05 19:42:22 +010016390 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016391 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016392
Kailang Yangdf694da2005-12-05 19:42:22 +010016393 spec->stream_analog_playback = &alc861_pcm_analog_playback;
16394 spec->stream_analog_capture = &alc861_pcm_analog_capture;
16395
Kailang Yangdf694da2005-12-05 19:42:22 +010016396 spec->stream_digital_playback = &alc861_pcm_digital_playback;
16397 spec->stream_digital_capture = &alc861_pcm_digital_capture;
16398
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010016399 if (!spec->cap_mixer)
16400 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016401 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
16402
Takashi Iwai2134ea42008-01-10 16:53:55 +010016403 spec->vmaster_nid = 0x03;
16404
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016405 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016406
Kailang Yangdf694da2005-12-05 19:42:22 +010016407 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050016408 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016409 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016410#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050016411 spec->power_hook = alc_power_eapd;
16412#endif
16413 }
16414#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020016415 if (!spec->loopback.amplist)
16416 spec->loopback.amplist = alc861_loopbacks;
16417#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020016418
Kailang Yangdf694da2005-12-05 19:42:22 +010016419 return 0;
16420}
16421
16422/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016423 * ALC861-VD support
16424 *
16425 * Based on ALC882
16426 *
16427 * In addition, an independent DAC
16428 */
16429#define ALC861VD_DIGOUT_NID 0x06
16430
16431static hda_nid_t alc861vd_dac_nids[4] = {
16432 /* front, surr, clfe, side surr */
16433 0x02, 0x03, 0x04, 0x05
16434};
16435
16436/* dac_nids for ALC660vd are in a different order - according to
16437 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016438 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016439 * of ALC660vd codecs, but for now there is only 3stack mixer
16440 * - and it is the same as in 861vd.
16441 * adc_nids in ALC660vd are (is) the same as in 861vd
16442 */
16443static hda_nid_t alc660vd_dac_nids[3] = {
16444 /* front, rear, clfe, rear_surr */
16445 0x02, 0x04, 0x03
16446};
16447
16448static hda_nid_t alc861vd_adc_nids[1] = {
16449 /* ADC0 */
16450 0x09,
16451};
16452
Takashi Iwaie1406342008-02-11 18:32:32 +010016453static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
16454
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016455/* input MUX */
16456/* FIXME: should be a matrix-type input source selection */
16457static struct hda_input_mux alc861vd_capture_source = {
16458 .num_items = 4,
16459 .items = {
16460 { "Mic", 0x0 },
16461 { "Front Mic", 0x1 },
16462 { "Line", 0x2 },
16463 { "CD", 0x4 },
16464 },
16465};
16466
Kailang Yang272a5272007-05-14 11:00:38 +020016467static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016468 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016469 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +010016470 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010016471 { "Internal Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016472 },
16473};
16474
Kailang Yangd1a991a2007-08-15 16:21:59 +020016475static struct hda_input_mux alc861vd_hp_capture_source = {
16476 .num_items = 2,
16477 .items = {
16478 { "Front Mic", 0x0 },
16479 { "ATAPI Mic", 0x1 },
16480 },
16481};
16482
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016483/*
16484 * 2ch mode
16485 */
16486static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16487 { 2, NULL }
16488};
16489
16490/*
16491 * 6ch mode
16492 */
16493static struct hda_verb alc861vd_6stack_ch6_init[] = {
16494 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16495 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16496 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16497 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16498 { } /* end */
16499};
16500
16501/*
16502 * 8ch mode
16503 */
16504static struct hda_verb alc861vd_6stack_ch8_init[] = {
16505 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16506 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16507 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16508 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16509 { } /* end */
16510};
16511
16512static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16513 { 6, alc861vd_6stack_ch6_init },
16514 { 8, alc861vd_6stack_ch8_init },
16515};
16516
16517static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16518 {
16519 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16520 .name = "Channel Mode",
16521 .info = alc_ch_mode_info,
16522 .get = alc_ch_mode_get,
16523 .put = alc_ch_mode_put,
16524 },
16525 { } /* end */
16526};
16527
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016528/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16529 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16530 */
16531static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16532 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16533 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16534
16535 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16536 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16537
16538 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16539 HDA_OUTPUT),
16540 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16541 HDA_OUTPUT),
16542 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16543 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16544
16545 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16546 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16547
16548 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16549
David Henningsson5f99f862011-01-04 15:24:24 +010016550 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016551 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16552 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16553
David Henningsson5f99f862011-01-04 15:24:24 +010016554 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016555 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16556 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16557
16558 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16559 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16560
16561 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16562 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16563
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016564 { } /* end */
16565};
16566
16567static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16568 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16569 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16570
16571 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16572
David Henningsson5f99f862011-01-04 15:24:24 +010016573 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016574 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16575 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16576
David Henningsson5f99f862011-01-04 15:24:24 +010016577 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016578 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16579 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16580
16581 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16582 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16583
16584 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16585 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16586
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016587 { } /* end */
16588};
16589
Kailang Yangbdd148a2007-05-08 15:19:08 +020016590static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16591 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16592 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16593 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16594
16595 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16596
David Henningsson5f99f862011-01-04 15:24:24 +010016597 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016598 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16599 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16600
David Henningsson5f99f862011-01-04 15:24:24 +010016601 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016602 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16603 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16604
16605 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16606 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16607
16608 { } /* end */
16609};
16610
Tobin Davisb419f342008-03-07 11:57:51 +010016611/* Pin assignment: Speaker=0x14, HP = 0x15,
David Henningsson8607f7c2010-12-20 14:43:54 +010016612 * Mic=0x18, Internal Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016613 */
16614static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016615 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16616 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016617 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16618 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016619 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +010016620 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16621 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016622 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010016623 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16624 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016625 { } /* end */
16626};
16627
Kailang Yangd1a991a2007-08-15 16:21:59 +020016628/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16629 * Front Mic=0x18, ATAPI Mic = 0x19,
16630 */
16631static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16632 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16633 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16634 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16635 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16636 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16637 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16638 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16639 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016640
Kailang Yangd1a991a2007-08-15 16:21:59 +020016641 { } /* end */
16642};
16643
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016644/*
16645 * generic initialization of ADC, input mixers and output mixers
16646 */
16647static struct hda_verb alc861vd_volume_init_verbs[] = {
16648 /*
16649 * Unmute ADC0 and set the default input to mic-in
16650 */
16651 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16652 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16653
16654 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16655 * the analog-loopback mixer widget
16656 */
16657 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016658 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16659 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16660 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16661 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16662 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016663
16664 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016665 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16666 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16667 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016668 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016669
16670 /*
16671 * Set up output mixers (0x02 - 0x05)
16672 */
16673 /* set vol=0 to output mixers */
16674 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16675 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16676 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16677 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16678
16679 /* set up input amps for analog loopback */
16680 /* Amp Indices: DAC = 0, mixer = 1 */
16681 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16682 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16683 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16684 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16685 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16686 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16687 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16688 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16689
16690 { }
16691};
16692
16693/*
16694 * 3-stack pin configuration:
16695 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16696 */
16697static struct hda_verb alc861vd_3stack_init_verbs[] = {
16698 /*
16699 * Set pin mode and muting
16700 */
16701 /* set front pin widgets 0x14 for output */
16702 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16703 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16704 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16705
16706 /* Mic (rear) pin: input vref at 80% */
16707 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16708 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16709 /* Front Mic pin: input vref at 80% */
16710 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16711 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16712 /* Line In pin: input */
16713 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16714 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16715 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16716 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16717 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16718 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16719 /* CD pin widget for input */
16720 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16721
16722 { }
16723};
16724
16725/*
16726 * 6-stack pin configuration:
16727 */
16728static struct hda_verb alc861vd_6stack_init_verbs[] = {
16729 /*
16730 * Set pin mode and muting
16731 */
16732 /* set front pin widgets 0x14 for output */
16733 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16734 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16735 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16736
16737 /* Rear Pin: output 1 (0x0d) */
16738 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16739 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16740 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16741 /* CLFE Pin: output 2 (0x0e) */
16742 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16743 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16744 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16745 /* Side Pin: output 3 (0x0f) */
16746 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16747 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16748 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16749
16750 /* Mic (rear) pin: input vref at 80% */
16751 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16752 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16753 /* Front Mic pin: input vref at 80% */
16754 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16755 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16756 /* Line In pin: input */
16757 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16758 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16759 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16760 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16761 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16762 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16763 /* CD pin widget for input */
16764 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16765
16766 { }
16767};
16768
Kailang Yangbdd148a2007-05-08 15:19:08 +020016769static struct hda_verb alc861vd_eapd_verbs[] = {
16770 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16771 { }
16772};
16773
Kailang Yangf9423e72008-05-27 12:32:25 +020016774static struct hda_verb alc660vd_eapd_verbs[] = {
16775 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16776 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16777 { }
16778};
16779
Kailang Yangbdd148a2007-05-08 15:19:08 +020016780static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16781 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16782 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16783 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16784 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016785 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016786 {}
16787};
16788
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016789static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016790{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016791 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016792 spec->autocfg.hp_pins[0] = 0x1b;
16793 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016794}
16795
16796static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16797{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016798 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +010016799 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016800}
16801
16802static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16803 unsigned int res)
16804{
16805 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016806 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +010016807 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016808 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016809 default:
16810 alc_automute_amp_unsol_event(codec, res);
16811 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016812 }
16813}
16814
Kailang Yang272a5272007-05-14 11:00:38 +020016815static struct hda_verb alc861vd_dallas_verbs[] = {
16816 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16817 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16818 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16819 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16820
16821 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16822 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16823 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16824 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16825 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16826 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16827 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16828 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016829
Kailang Yang272a5272007-05-14 11:00:38 +020016830 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16831 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16832 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16833 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16834 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16835 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16836 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16837 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16838
16839 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16840 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16841 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16842 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16843 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16844 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16845 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16846 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16847
16848 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16849 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16850 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16851 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16852
16853 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016854 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016855 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16856
16857 { } /* end */
16858};
16859
16860/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016861static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016862{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016863 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016864
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016865 spec->autocfg.hp_pins[0] = 0x15;
16866 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016867}
16868
Takashi Iwaicb53c622007-08-10 17:21:45 +020016869#ifdef CONFIG_SND_HDA_POWER_SAVE
16870#define alc861vd_loopbacks alc880_loopbacks
16871#endif
16872
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016873/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016874#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16875#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16876#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16877#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16878
16879/*
16880 * configuration and preset
16881 */
Takashi Iwaiea734962011-01-17 11:29:34 +010016882static const char * const alc861vd_models[ALC861VD_MODEL_LAST] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016883 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016884 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016885 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016886 [ALC861VD_3ST] = "3stack",
16887 [ALC861VD_3ST_DIG] = "3stack-digout",
16888 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016889 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016890 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016891 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016892 [ALC861VD_AUTO] = "auto",
16893};
16894
16895static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016896 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16897 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016898 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016899 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016900 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016901 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016902 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016903 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016904 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016905 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016906 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016907 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016908 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016909 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016910 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016911 {}
16912};
16913
16914static struct alc_config_preset alc861vd_presets[] = {
16915 [ALC660VD_3ST] = {
16916 .mixers = { alc861vd_3st_mixer },
16917 .init_verbs = { alc861vd_volume_init_verbs,
16918 alc861vd_3stack_init_verbs },
16919 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16920 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016921 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16922 .channel_mode = alc861vd_3stack_2ch_modes,
16923 .input_mux = &alc861vd_capture_source,
16924 },
Mike Crash6963f842007-06-25 12:12:51 +020016925 [ALC660VD_3ST_DIG] = {
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,
16931 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016932 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16933 .channel_mode = alc861vd_3stack_2ch_modes,
16934 .input_mux = &alc861vd_capture_source,
16935 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016936 [ALC861VD_3ST] = {
16937 .mixers = { alc861vd_3st_mixer },
16938 .init_verbs = { alc861vd_volume_init_verbs,
16939 alc861vd_3stack_init_verbs },
16940 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16941 .dac_nids = alc861vd_dac_nids,
16942 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16943 .channel_mode = alc861vd_3stack_2ch_modes,
16944 .input_mux = &alc861vd_capture_source,
16945 },
16946 [ALC861VD_3ST_DIG] = {
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 .dig_out_nid = ALC861VD_DIGOUT_NID,
16953 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16954 .channel_mode = alc861vd_3stack_2ch_modes,
16955 .input_mux = &alc861vd_capture_source,
16956 },
16957 [ALC861VD_6ST_DIG] = {
16958 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16959 .init_verbs = { alc861vd_volume_init_verbs,
16960 alc861vd_6stack_init_verbs },
16961 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16962 .dac_nids = alc861vd_dac_nids,
16963 .dig_out_nid = ALC861VD_DIGOUT_NID,
16964 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16965 .channel_mode = alc861vd_6stack_modes,
16966 .input_mux = &alc861vd_capture_source,
16967 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016968 [ALC861VD_LENOVO] = {
16969 .mixers = { alc861vd_lenovo_mixer },
16970 .init_verbs = { alc861vd_volume_init_verbs,
16971 alc861vd_3stack_init_verbs,
16972 alc861vd_eapd_verbs,
16973 alc861vd_lenovo_unsol_verbs },
16974 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16975 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016976 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16977 .channel_mode = alc861vd_3stack_2ch_modes,
16978 .input_mux = &alc861vd_capture_source,
16979 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016980 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016981 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016982 },
Kailang Yang272a5272007-05-14 11:00:38 +020016983 [ALC861VD_DALLAS] = {
16984 .mixers = { alc861vd_dallas_mixer },
16985 .init_verbs = { alc861vd_dallas_verbs },
16986 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16987 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016988 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16989 .channel_mode = alc861vd_3stack_2ch_modes,
16990 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016991 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016992 .setup = alc861vd_dallas_setup,
16993 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016994 },
16995 [ALC861VD_HP] = {
16996 .mixers = { alc861vd_hp_mixer },
16997 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16998 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16999 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017000 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017001 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17002 .channel_mode = alc861vd_3stack_2ch_modes,
17003 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017004 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017005 .setup = alc861vd_dallas_setup,
17006 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020017007 },
Takashi Iwai13c94742008-11-05 08:06:08 +010017008 [ALC660VD_ASUS_V1S] = {
17009 .mixers = { alc861vd_lenovo_mixer },
17010 .init_verbs = { alc861vd_volume_init_verbs,
17011 alc861vd_3stack_init_verbs,
17012 alc861vd_eapd_verbs,
17013 alc861vd_lenovo_unsol_verbs },
17014 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
17015 .dac_nids = alc660vd_dac_nids,
17016 .dig_out_nid = ALC861VD_DIGOUT_NID,
17017 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17018 .channel_mode = alc861vd_3stack_2ch_modes,
17019 .input_mux = &alc861vd_capture_source,
17020 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017021 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017022 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010017023 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017024};
17025
17026/*
17027 * BIOS auto configuration
17028 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017029static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
17030 const struct auto_pin_cfg *cfg)
17031{
Herton Ronaldo Krzesinski71675942010-11-25 00:08:01 -020017032 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x22, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020017033}
17034
17035
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017036static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
17037 hda_nid_t nid, int pin_type, int dac_idx)
17038{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017039 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017040}
17041
17042static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
17043{
17044 struct alc_spec *spec = codec->spec;
17045 int i;
17046
17047 for (i = 0; i <= HDA_SIDE; i++) {
17048 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017049 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017050 if (nid)
17051 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017052 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017053 }
17054}
17055
17056
17057static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
17058{
17059 struct alc_spec *spec = codec->spec;
17060 hda_nid_t pin;
17061
17062 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017063 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017064 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017065 pin = spec->autocfg.speaker_pins[0];
17066 if (pin)
17067 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017068}
17069
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017070#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
17071
17072static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
17073{
17074 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017075 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017076 int i;
17077
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017078 for (i = 0; i < cfg->num_inputs; i++) {
17079 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017080 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020017081 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +010017082 if (nid != ALC861VD_PIN_CD_NID &&
17083 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017084 snd_hda_codec_write(codec, nid, 0,
17085 AC_VERB_SET_AMP_GAIN_MUTE,
17086 AMP_OUT_MUTE);
17087 }
17088 }
17089}
17090
Takashi Iwaif511b012008-08-15 16:46:42 +020017091#define alc861vd_auto_init_input_src alc882_auto_init_input_src
17092
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017093#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
17094#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
17095
17096/* add playback controls from the parsed DAC table */
Takashi Iwai569ed342011-01-19 10:14:46 +010017097/* Based on ALC880 version. But ALC861VD has separate,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017098 * different NIDs for mute/unmute switch and volume control */
17099static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
17100 const struct auto_pin_cfg *cfg)
17101{
Takashi Iwaiea734962011-01-17 11:29:34 +010017102 static const char * const chname[4] = {
17103 "Front", "Surround", "CLFE", "Side"
17104 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017105 const char *pfx = alc_get_line_out_pfx(cfg, true);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017106 hda_nid_t nid_v, nid_s;
17107 int i, err;
17108
17109 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017110 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017111 continue;
17112 nid_v = alc861vd_idx_to_mixer_vol(
17113 alc880_dac_to_idx(
17114 spec->multiout.dac_nids[i]));
17115 nid_s = alc861vd_idx_to_mixer_switch(
17116 alc880_dac_to_idx(
17117 spec->multiout.dac_nids[i]));
17118
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017119 if (!pfx && i == 2) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017120 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017121 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17122 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017123 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
17124 HDA_OUTPUT));
17125 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017126 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017127 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17128 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017129 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
17130 HDA_OUTPUT));
17131 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017132 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017133 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17134 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017135 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
17136 HDA_INPUT));
17137 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017138 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017139 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17140 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017141 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
17142 HDA_INPUT));
17143 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017144 return err;
17145 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017146 const char *name = pfx;
17147 if (!name)
17148 name = chname[i];
17149 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17150 name, i,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017151 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
17152 HDA_OUTPUT));
17153 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017154 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017155 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17156 name, i,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017157 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017158 HDA_INPUT));
17159 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017160 return err;
17161 }
17162 }
17163 return 0;
17164}
17165
17166/* add playback controls for speaker and HP outputs */
17167/* Based on ALC880 version. But ALC861VD has separate,
17168 * different NIDs for mute/unmute switch and volume control */
17169static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
17170 hda_nid_t pin, const char *pfx)
17171{
17172 hda_nid_t nid_v, nid_s;
17173 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017174
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017175 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017176 return 0;
17177
17178 if (alc880_is_fixed_pin(pin)) {
17179 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17180 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017181 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017182 spec->multiout.hp_nid = nid_v;
17183 else
17184 spec->multiout.extra_out_nid[0] = nid_v;
17185 /* control HP volume/switch on the output mixer amp */
17186 nid_v = alc861vd_idx_to_mixer_vol(
17187 alc880_fixed_pin_idx(pin));
17188 nid_s = alc861vd_idx_to_mixer_switch(
17189 alc880_fixed_pin_idx(pin));
17190
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017191 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017192 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
17193 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017194 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017195 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017196 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
17197 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017198 return err;
17199 } else if (alc880_is_multi_pin(pin)) {
17200 /* set manual connection */
17201 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017202 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017203 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17204 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017205 return err;
17206 }
17207 return 0;
17208}
17209
17210/* parse the BIOS configuration and set up the alc_spec
17211 * return 1 if successful, 0 if the proper config is not found,
17212 * or a negative error code
17213 * Based on ALC880 version - had to change it to override
17214 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
17215static int alc861vd_parse_auto_config(struct hda_codec *codec)
17216{
17217 struct alc_spec *spec = codec->spec;
17218 int err;
17219 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
17220
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017221 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17222 alc861vd_ignore);
17223 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017224 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017225 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017226 return 0; /* can't find valid BIOS pin config */
17227
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017228 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17229 if (err < 0)
17230 return err;
17231 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
17232 if (err < 0)
17233 return err;
17234 err = alc861vd_auto_create_extra_out(spec,
17235 spec->autocfg.speaker_pins[0],
17236 "Speaker");
17237 if (err < 0)
17238 return err;
17239 err = alc861vd_auto_create_extra_out(spec,
17240 spec->autocfg.hp_pins[0],
17241 "Headphone");
17242 if (err < 0)
17243 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017244 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017245 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017246 return err;
17247
17248 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17249
Takashi Iwai757899a2010-07-30 10:48:14 +020017250 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017251
Takashi Iwai603c4012008-07-30 15:01:44 +020017252 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017253 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017254
Takashi Iwaid88897e2008-10-31 15:01:37 +010017255 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017256
17257 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017258 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017259
Takashi Iwai776e1842007-08-29 15:07:11 +020017260 err = alc_auto_add_mic_boost(codec);
17261 if (err < 0)
17262 return err;
17263
Kailang Yang6227cdc2010-02-25 08:36:52 +010017264 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017265
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017266 return 1;
17267}
17268
17269/* additional initialization for auto-configuration model */
17270static void alc861vd_auto_init(struct hda_codec *codec)
17271{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017272 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017273 alc861vd_auto_init_multi_out(codec);
17274 alc861vd_auto_init_hp_out(codec);
17275 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017276 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020017277 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017278 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017279 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017280}
17281
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017282enum {
17283 ALC660VD_FIX_ASUS_GPIO1
17284};
17285
17286/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017287static const struct alc_fixup alc861vd_fixups[] = {
17288 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017289 .type = ALC_FIXUP_VERBS,
17290 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020017291 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
17292 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
17293 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
17294 { }
17295 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017296 },
17297};
17298
17299static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
17300 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
17301 {}
17302};
17303
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017304static int patch_alc861vd(struct hda_codec *codec)
17305{
17306 struct alc_spec *spec;
17307 int err, board_config;
17308
17309 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17310 if (spec == NULL)
17311 return -ENOMEM;
17312
17313 codec->spec = spec;
17314
17315 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
17316 alc861vd_models,
17317 alc861vd_cfg_tbl);
17318
17319 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017320 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17321 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017322 board_config = ALC861VD_AUTO;
17323 }
17324
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017325 if (board_config == ALC861VD_AUTO) {
17326 alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
17327 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
17328 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017329
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017330 if (board_config == ALC861VD_AUTO) {
17331 /* automatic parse from the BIOS config */
17332 err = alc861vd_parse_auto_config(codec);
17333 if (err < 0) {
17334 alc_free(codec);
17335 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017336 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017337 printk(KERN_INFO
17338 "hda_codec: Cannot set up configuration "
17339 "from BIOS. Using base mode...\n");
17340 board_config = ALC861VD_3ST;
17341 }
17342 }
17343
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017344 err = snd_hda_attach_beep_device(codec, 0x23);
17345 if (err < 0) {
17346 alc_free(codec);
17347 return err;
17348 }
17349
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017350 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017351 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017352
Kailang Yang2f893282008-05-27 12:14:47 +020017353 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020017354 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010017355 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020017356 }
17357
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017358 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
17359 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
17360
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017361 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
17362 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
17363
Takashi Iwaidd704692009-08-11 08:45:11 +020017364 if (!spec->adc_nids) {
17365 spec->adc_nids = alc861vd_adc_nids;
17366 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
17367 }
17368 if (!spec->capsrc_nids)
17369 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017370
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017371 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010017372 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017373
Takashi Iwai2134ea42008-01-10 16:53:55 +010017374 spec->vmaster_nid = 0x02;
17375
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017376 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017377
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017378 codec->patch_ops = alc_patch_ops;
17379
17380 if (board_config == ALC861VD_AUTO)
17381 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017382#ifdef CONFIG_SND_HDA_POWER_SAVE
17383 if (!spec->loopback.amplist)
17384 spec->loopback.amplist = alc861vd_loopbacks;
17385#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017386
17387 return 0;
17388}
17389
17390/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017391 * ALC662 support
17392 *
17393 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
17394 * configuration. Each pin widget can choose any input DACs and a mixer.
17395 * Each ADC is connected from a mixer of all inputs. This makes possible
17396 * 6-channel independent captures.
17397 *
17398 * In addition, an independent DAC for the multi-playback (not used in this
17399 * driver yet).
17400 */
17401#define ALC662_DIGOUT_NID 0x06
17402#define ALC662_DIGIN_NID 0x0a
17403
17404static hda_nid_t alc662_dac_nids[4] = {
17405 /* front, rear, clfe, rear_surr */
17406 0x02, 0x03, 0x04
17407};
17408
Kailang Yang622e84c2009-04-21 07:39:04 +020017409static hda_nid_t alc272_dac_nids[2] = {
17410 0x02, 0x03
17411};
17412
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017413static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017414 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017415 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017416};
Takashi Iwaie1406342008-02-11 18:32:32 +010017417
Kailang Yang622e84c2009-04-21 07:39:04 +020017418static hda_nid_t alc272_adc_nids[1] = {
17419 /* ADC1-2 */
17420 0x08,
17421};
17422
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017423static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020017424static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
17425
Takashi Iwaie1406342008-02-11 18:32:32 +010017426
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017427/* input MUX */
17428/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017429static struct hda_input_mux alc662_capture_source = {
17430 .num_items = 4,
17431 .items = {
17432 { "Mic", 0x0 },
17433 { "Front Mic", 0x1 },
17434 { "Line", 0x2 },
17435 { "CD", 0x4 },
17436 },
17437};
17438
17439static struct hda_input_mux alc662_lenovo_101e_capture_source = {
17440 .num_items = 2,
17441 .items = {
17442 { "Mic", 0x1 },
17443 { "Line", 0x2 },
17444 },
17445};
Kailang Yang291702f2007-10-16 14:28:03 +020017446
Kailang Yang6dda9f42008-05-27 12:05:31 +020017447static struct hda_input_mux alc663_capture_source = {
17448 .num_items = 3,
17449 .items = {
17450 { "Mic", 0x0 },
17451 { "Front Mic", 0x1 },
17452 { "Line", 0x2 },
17453 },
17454};
17455
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017456#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020017457static struct hda_input_mux alc272_nc10_capture_source = {
17458 .num_items = 16,
17459 .items = {
17460 { "Autoselect Mic", 0x0 },
17461 { "Internal Mic", 0x1 },
17462 { "In-0x02", 0x2 },
17463 { "In-0x03", 0x3 },
17464 { "In-0x04", 0x4 },
17465 { "In-0x05", 0x5 },
17466 { "In-0x06", 0x6 },
17467 { "In-0x07", 0x7 },
17468 { "In-0x08", 0x8 },
17469 { "In-0x09", 0x9 },
17470 { "In-0x0a", 0x0a },
17471 { "In-0x0b", 0x0b },
17472 { "In-0x0c", 0x0c },
17473 { "In-0x0d", 0x0d },
17474 { "In-0x0e", 0x0e },
17475 { "In-0x0f", 0x0f },
17476 },
17477};
17478#endif
17479
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017480/*
17481 * 2ch mode
17482 */
17483static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17484 { 2, NULL }
17485};
17486
17487/*
17488 * 2ch mode
17489 */
17490static struct hda_verb alc662_3ST_ch2_init[] = {
17491 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17492 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17493 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17494 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17495 { } /* end */
17496};
17497
17498/*
17499 * 6ch mode
17500 */
17501static struct hda_verb alc662_3ST_ch6_init[] = {
17502 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17503 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17504 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17505 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17506 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17507 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17508 { } /* end */
17509};
17510
17511static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17512 { 2, alc662_3ST_ch2_init },
17513 { 6, alc662_3ST_ch6_init },
17514};
17515
17516/*
17517 * 2ch mode
17518 */
17519static struct hda_verb alc662_sixstack_ch6_init[] = {
17520 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17521 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17522 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17523 { } /* end */
17524};
17525
17526/*
17527 * 6ch mode
17528 */
17529static struct hda_verb alc662_sixstack_ch8_init[] = {
17530 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17531 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17532 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17533 { } /* end */
17534};
17535
17536static struct hda_channel_mode alc662_5stack_modes[2] = {
17537 { 2, alc662_sixstack_ch6_init },
17538 { 6, alc662_sixstack_ch8_init },
17539};
17540
17541/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17542 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17543 */
17544
17545static struct snd_kcontrol_new alc662_base_mixer[] = {
17546 /* output mixer control */
17547 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017548 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017549 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017550 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017551 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17552 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017553 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17554 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017555 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17556
17557 /*Input mixer control */
17558 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17559 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17560 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17561 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17562 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17563 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17564 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17565 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017566 { } /* end */
17567};
17568
17569static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17570 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017571 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017572 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17573 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17574 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17575 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17576 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17577 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17578 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17579 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17580 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017581 { } /* end */
17582};
17583
17584static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17585 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017586 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017587 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017588 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017589 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17590 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017591 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17592 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017593 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17594 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17595 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17596 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17597 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17598 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17599 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17600 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17601 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017602 { } /* end */
17603};
17604
17605static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17606 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17607 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017608 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17609 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017610 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17611 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17612 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17613 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17614 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017615 { } /* end */
17616};
17617
Kailang Yang291702f2007-10-16 14:28:03 +020017618static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017619 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17620 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017621
David Henningsson5f99f862011-01-04 15:24:24 +010017622 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017623 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17624 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017625
David Henningsson5f99f862011-01-04 15:24:24 +010017626 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017627 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17628 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017629 { } /* end */
17630};
17631
Kailang Yang8c427222008-01-10 13:03:59 +010017632static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017633 ALC262_HIPPO_MASTER_SWITCH,
17634 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017635 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017636 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17637 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017638 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17639 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17640 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17641 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17642 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17643 { } /* end */
17644};
17645
Kailang Yangf1d4e282008-08-26 14:03:29 +020017646static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17647 .ops = &snd_hda_bind_vol,
17648 .values = {
17649 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17650 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17651 0
17652 },
17653};
17654
17655static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17656 .ops = &snd_hda_bind_sw,
17657 .values = {
17658 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17659 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17660 0
17661 },
17662};
17663
Kailang Yang6dda9f42008-05-27 12:05:31 +020017664static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017665 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17666 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17667 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17668 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17669 { } /* end */
17670};
17671
17672static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17673 .ops = &snd_hda_bind_sw,
17674 .values = {
17675 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17676 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17677 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17678 0
17679 },
17680};
17681
17682static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17683 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17684 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17685 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17686 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17687 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17688 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17689
17690 { } /* end */
17691};
17692
17693static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17694 .ops = &snd_hda_bind_sw,
17695 .values = {
17696 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17697 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17698 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17699 0
17700 },
17701};
17702
17703static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17704 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17705 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17706 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17707 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17708 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17709 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17710 { } /* end */
17711};
17712
17713static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017714 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17715 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017716 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17717 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17718 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17719 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17720 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17721 { } /* end */
17722};
17723
17724static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17725 .ops = &snd_hda_bind_vol,
17726 .values = {
17727 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17728 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17729 0
17730 },
17731};
17732
17733static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17734 .ops = &snd_hda_bind_sw,
17735 .values = {
17736 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17737 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17738 0
17739 },
17740};
17741
17742static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17743 HDA_BIND_VOL("Master Playback Volume",
17744 &alc663_asus_two_bind_master_vol),
17745 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17746 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017747 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17748 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17749 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017750 { } /* end */
17751};
17752
17753static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17754 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_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),
17757 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 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 Yang6dda9f42008-05-27 12:05:31 +020017760 { } /* end */
17761};
17762
17763static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17764 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17765 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17766 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17767 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17768 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17769
17770 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17771 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017772 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17773 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017774 { } /* end */
17775};
17776
17777static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17778 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17779 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17780 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17781
17782 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17783 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017784 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17785 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017786 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17787 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17788 { } /* end */
17789};
17790
Kailang Yangebb83ee2009-12-17 12:23:00 +010017791static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17792 .ops = &snd_hda_bind_sw,
17793 .values = {
17794 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17795 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17796 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17797 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17798 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17799 0
17800 },
17801};
17802
17803static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17804 .ops = &snd_hda_bind_sw,
17805 .values = {
17806 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17807 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17808 0
17809 },
17810};
17811
17812static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17813 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17814 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17815 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17816 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17817 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17818 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17819 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17820 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17821 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17822 { } /* end */
17823};
17824
17825static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17826 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17827 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17828 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17829 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17830 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17831 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17832 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17833 { } /* end */
17834};
17835
17836
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017837static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17838 {
17839 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17840 .name = "Channel Mode",
17841 .info = alc_ch_mode_info,
17842 .get = alc_ch_mode_get,
17843 .put = alc_ch_mode_put,
17844 },
17845 { } /* end */
17846};
17847
17848static struct hda_verb alc662_init_verbs[] = {
17849 /* ADC: mute amp left and right */
17850 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17851 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017852
Kailang Yangb60dd392007-09-20 12:50:29 +020017853 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17854 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17855 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17856 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17857 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17858 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017859
17860 /* Front Pin: output 0 (0x0c) */
17861 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17862 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17863
17864 /* Rear Pin: output 1 (0x0d) */
17865 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17866 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17867
17868 /* CLFE Pin: output 2 (0x0e) */
17869 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17870 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17871
17872 /* Mic (rear) pin: input vref at 80% */
17873 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17874 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17875 /* Front Mic pin: input vref at 80% */
17876 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17877 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17878 /* Line In pin: input */
17879 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17880 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17881 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17882 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17883 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17884 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17885 /* CD pin widget for input */
17886 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17887
17888 /* FIXME: use matrix-type input source selection */
17889 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17890 /* Input mixer */
17891 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017892 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017893
17894 /* always trun on EAPD */
17895 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17896 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17897
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017898 { }
17899};
17900
Kailang Yangcec27c82010-02-04 14:18:18 +010017901static struct hda_verb alc663_init_verbs[] = {
17902 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17903 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17904 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17905 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17906 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17907 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17908 { }
17909};
17910
17911static struct hda_verb alc272_init_verbs[] = {
17912 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17913 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17914 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17915 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17916 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17917 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17918 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17919 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17920 { }
17921};
17922
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017923static struct hda_verb alc662_sue_init_verbs[] = {
17924 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17925 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017926 {}
17927};
17928
17929static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17930 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17931 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17932 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017933};
17934
Kailang Yang8c427222008-01-10 13:03:59 +010017935/* Set Unsolicited Event*/
17936static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17937 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17938 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17939 {}
17940};
17941
Kailang Yang6dda9f42008-05-27 12:05:31 +020017942static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017943 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17944 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017945 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17946 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017947 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17948 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17949 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017950 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17951 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17952 {}
17953};
17954
Kailang Yangf1d4e282008-08-26 14:03:29 +020017955static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17956 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17957 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17958 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17959 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17960 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17961 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17962 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17963 {}
17964};
17965
17966static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17967 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17968 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17969 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17970 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17971 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17972 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17973 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17974 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17975 {}
17976};
17977
17978static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17979 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17980 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17981 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17982 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17983 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17984 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17985 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17986 {}
17987};
17988
17989static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17990 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17991 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17992 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17993 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17994 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17995 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17996 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17997 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17998 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17999 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18000 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18001 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18002 {}
18003};
18004
18005static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
18006 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18007 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18008 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18009 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18010 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18011 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18012 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18013 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18014 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18015 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18016 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18017 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18018 {}
18019};
18020
Kailang Yang6dda9f42008-05-27 12:05:31 +020018021static struct hda_verb alc663_g71v_init_verbs[] = {
18022 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18023 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
18024 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
18025
18026 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18027 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18028 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18029
18030 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
18031 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
18032 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
18033 {}
18034};
18035
18036static struct hda_verb alc663_g50v_init_verbs[] = {
18037 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18038 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18039 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18040
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
Kailang Yangf1d4e282008-08-26 14:03:29 +020018046static struct hda_verb alc662_ecs_init_verbs[] = {
18047 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
18048 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18049 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18050 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18051 {}
18052};
18053
Kailang Yang622e84c2009-04-21 07:39:04 +020018054static struct hda_verb alc272_dell_zm1_init_verbs[] = {
18055 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18056 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18057 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18058 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18059 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18060 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18061 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18062 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18063 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18064 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18065 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18066 {}
18067};
18068
18069static struct hda_verb alc272_dell_init_verbs[] = {
18070 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18071 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18072 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18073 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18074 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18075 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18076 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18077 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18078 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18079 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18080 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18081 {}
18082};
18083
Kailang Yangebb83ee2009-12-17 12:23:00 +010018084static struct hda_verb alc663_mode7_init_verbs[] = {
18085 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18086 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18087 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18088 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18089 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18090 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18091 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
18092 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18093 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18094 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18095 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18096 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18097 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18098 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18099 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18100 {}
18101};
18102
18103static struct hda_verb alc663_mode8_init_verbs[] = {
18104 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18105 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18106 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18107 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
18108 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18109 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18110 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18111 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18112 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18113 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18114 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18115 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18116 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18117 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18118 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18119 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18120 {}
18121};
18122
Kailang Yangf1d4e282008-08-26 14:03:29 +020018123static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
18124 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
18125 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
18126 { } /* end */
18127};
18128
Kailang Yang622e84c2009-04-21 07:39:04 +020018129static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
18130 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
18131 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
18132 { } /* end */
18133};
18134
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018135static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
18136{
18137 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018138 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018139
Wu Fengguang864f92b2009-11-18 12:38:02 +080018140 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018141 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018142
Takashi Iwai47fd8302007-08-10 17:11:07 +020018143 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18144 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018145}
18146
18147static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
18148{
18149 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018150 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018151
Wu Fengguang864f92b2009-11-18 12:38:02 +080018152 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018153 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018154
Takashi Iwai47fd8302007-08-10 17:11:07 +020018155 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18156 HDA_AMP_MUTE, bits);
18157 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18158 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018159}
18160
18161static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
18162 unsigned int res)
18163{
18164 if ((res >> 26) == ALC880_HP_EVENT)
18165 alc662_lenovo_101e_all_automute(codec);
18166 if ((res >> 26) == ALC880_FRONT_EVENT)
18167 alc662_lenovo_101e_ispeaker_automute(codec);
18168}
18169
Kailang Yang291702f2007-10-16 14:28:03 +020018170/* unsolicited event for HP jack sensing */
18171static void alc662_eeepc_unsol_event(struct hda_codec *codec,
18172 unsigned int res)
18173{
Kailang Yang291702f2007-10-16 14:28:03 +020018174 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018175 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020018176 else
18177 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020018178}
18179
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018180static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020018181{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018182 struct alc_spec *spec = codec->spec;
18183
18184 alc262_hippo1_setup(codec);
18185 spec->ext_mic.pin = 0x18;
18186 spec->ext_mic.mux_idx = 0;
18187 spec->int_mic.pin = 0x19;
18188 spec->int_mic.mux_idx = 1;
18189 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020018190}
18191
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018192static void alc662_eeepc_inithook(struct hda_codec *codec)
18193{
18194 alc262_hippo_automute(codec);
18195 alc_mic_automute(codec);
18196}
18197
18198static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010018199{
Takashi Iwai42171c12009-05-08 14:11:43 +020018200 struct alc_spec *spec = codec->spec;
18201
18202 spec->autocfg.hp_pins[0] = 0x14;
18203 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010018204}
18205
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018206#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
18207
Kailang Yang6dda9f42008-05-27 12:05:31 +020018208static void alc663_m51va_speaker_automute(struct hda_codec *codec)
18209{
18210 unsigned int present;
18211 unsigned char bits;
18212
Wu Fengguang864f92b2009-11-18 12:38:02 +080018213 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018214 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018215 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018216 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018217 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018218 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018219}
18220
18221static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
18222{
18223 unsigned int present;
18224 unsigned char bits;
18225
Wu Fengguang864f92b2009-11-18 12:38:02 +080018226 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018227 bits = present ? HDA_AMP_MUTE : 0;
18228 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018229 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018230 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018231 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018232 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018233 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018234 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018235 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018236}
18237
18238static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
18239{
18240 unsigned int present;
18241 unsigned char bits;
18242
Wu Fengguang864f92b2009-11-18 12:38:02 +080018243 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018244 bits = present ? HDA_AMP_MUTE : 0;
18245 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018246 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018247 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018248 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018249 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018250 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018251 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018252 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018253}
18254
18255static void alc662_f5z_speaker_automute(struct hda_codec *codec)
18256{
18257 unsigned int present;
18258 unsigned char bits;
18259
Wu Fengguang864f92b2009-11-18 12:38:02 +080018260 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018261 bits = present ? 0 : PIN_OUT;
18262 snd_hda_codec_write(codec, 0x14, 0,
18263 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
18264}
18265
18266static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
18267{
18268 unsigned int present1, present2;
18269
Wu Fengguang864f92b2009-11-18 12:38:02 +080018270 present1 = snd_hda_jack_detect(codec, 0x21);
18271 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018272
18273 if (present1 || present2) {
18274 snd_hda_codec_write_cache(codec, 0x14, 0,
18275 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18276 } else {
18277 snd_hda_codec_write_cache(codec, 0x14, 0,
18278 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18279 }
18280}
18281
18282static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
18283{
18284 unsigned int present1, present2;
18285
Wu Fengguang864f92b2009-11-18 12:38:02 +080018286 present1 = snd_hda_jack_detect(codec, 0x1b);
18287 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018288
18289 if (present1 || present2) {
18290 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018291 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018292 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018293 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018294 } else {
18295 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018296 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018297 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018298 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018299 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020018300}
18301
Kailang Yangebb83ee2009-12-17 12:23:00 +010018302static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
18303{
18304 unsigned int present1, present2;
18305
18306 present1 = snd_hda_codec_read(codec, 0x1b, 0,
18307 AC_VERB_GET_PIN_SENSE, 0)
18308 & AC_PINSENSE_PRESENCE;
18309 present2 = snd_hda_codec_read(codec, 0x21, 0,
18310 AC_VERB_GET_PIN_SENSE, 0)
18311 & AC_PINSENSE_PRESENCE;
18312
18313 if (present1 || present2) {
18314 snd_hda_codec_write_cache(codec, 0x14, 0,
18315 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18316 snd_hda_codec_write_cache(codec, 0x17, 0,
18317 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18318 } else {
18319 snd_hda_codec_write_cache(codec, 0x14, 0,
18320 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18321 snd_hda_codec_write_cache(codec, 0x17, 0,
18322 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18323 }
18324}
18325
18326static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
18327{
18328 unsigned int present1, present2;
18329
18330 present1 = snd_hda_codec_read(codec, 0x21, 0,
18331 AC_VERB_GET_PIN_SENSE, 0)
18332 & AC_PINSENSE_PRESENCE;
18333 present2 = snd_hda_codec_read(codec, 0x15, 0,
18334 AC_VERB_GET_PIN_SENSE, 0)
18335 & AC_PINSENSE_PRESENCE;
18336
18337 if (present1 || present2) {
18338 snd_hda_codec_write_cache(codec, 0x14, 0,
18339 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18340 snd_hda_codec_write_cache(codec, 0x17, 0,
18341 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18342 } else {
18343 snd_hda_codec_write_cache(codec, 0x14, 0,
18344 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18345 snd_hda_codec_write_cache(codec, 0x17, 0,
18346 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18347 }
18348}
18349
Kailang Yang6dda9f42008-05-27 12:05:31 +020018350static void alc663_m51va_unsol_event(struct hda_codec *codec,
18351 unsigned int res)
18352{
18353 switch (res >> 26) {
18354 case ALC880_HP_EVENT:
18355 alc663_m51va_speaker_automute(codec);
18356 break;
18357 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018358 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018359 break;
18360 }
18361}
18362
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018363static void alc663_m51va_setup(struct hda_codec *codec)
18364{
18365 struct alc_spec *spec = codec->spec;
18366 spec->ext_mic.pin = 0x18;
18367 spec->ext_mic.mux_idx = 0;
18368 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018369 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018370 spec->auto_mic = 1;
18371}
18372
Kailang Yang6dda9f42008-05-27 12:05:31 +020018373static void alc663_m51va_inithook(struct hda_codec *codec)
18374{
18375 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018376 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018377}
18378
Kailang Yangf1d4e282008-08-26 14:03:29 +020018379/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018380#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010018381
18382static void alc663_mode1_setup(struct hda_codec *codec)
18383{
18384 struct alc_spec *spec = codec->spec;
18385 spec->ext_mic.pin = 0x18;
18386 spec->ext_mic.mux_idx = 0;
18387 spec->int_mic.pin = 0x19;
18388 spec->int_mic.mux_idx = 1;
18389 spec->auto_mic = 1;
18390}
18391
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018392#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020018393
Kailang Yangf1d4e282008-08-26 14:03:29 +020018394/* ***************** Mode2 ******************************/
18395static void alc662_mode2_unsol_event(struct hda_codec *codec,
18396 unsigned int res)
18397{
18398 switch (res >> 26) {
18399 case ALC880_HP_EVENT:
18400 alc662_f5z_speaker_automute(codec);
18401 break;
18402 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018403 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018404 break;
18405 }
18406}
18407
Kailang Yangebb83ee2009-12-17 12:23:00 +010018408#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018409
Kailang Yangf1d4e282008-08-26 14:03:29 +020018410static void alc662_mode2_inithook(struct hda_codec *codec)
18411{
18412 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018413 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018414}
18415/* ***************** Mode3 ******************************/
18416static void alc663_mode3_unsol_event(struct hda_codec *codec,
18417 unsigned int res)
18418{
18419 switch (res >> 26) {
18420 case ALC880_HP_EVENT:
18421 alc663_two_hp_m1_speaker_automute(codec);
18422 break;
18423 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018424 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018425 break;
18426 }
18427}
18428
Kailang Yangebb83ee2009-12-17 12:23:00 +010018429#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018430
Kailang Yangf1d4e282008-08-26 14:03:29 +020018431static void alc663_mode3_inithook(struct hda_codec *codec)
18432{
18433 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018434 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018435}
18436/* ***************** Mode4 ******************************/
18437static void alc663_mode4_unsol_event(struct hda_codec *codec,
18438 unsigned int res)
18439{
18440 switch (res >> 26) {
18441 case ALC880_HP_EVENT:
18442 alc663_21jd_two_speaker_automute(codec);
18443 break;
18444 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018445 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018446 break;
18447 }
18448}
18449
Kailang Yangebb83ee2009-12-17 12:23:00 +010018450#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018451
Kailang Yangf1d4e282008-08-26 14:03:29 +020018452static void alc663_mode4_inithook(struct hda_codec *codec)
18453{
18454 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018455 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018456}
18457/* ***************** Mode5 ******************************/
18458static void alc663_mode5_unsol_event(struct hda_codec *codec,
18459 unsigned int res)
18460{
18461 switch (res >> 26) {
18462 case ALC880_HP_EVENT:
18463 alc663_15jd_two_speaker_automute(codec);
18464 break;
18465 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018466 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018467 break;
18468 }
18469}
18470
Kailang Yangebb83ee2009-12-17 12:23:00 +010018471#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018472
Kailang Yangf1d4e282008-08-26 14:03:29 +020018473static void alc663_mode5_inithook(struct hda_codec *codec)
18474{
18475 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018476 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018477}
18478/* ***************** Mode6 ******************************/
18479static void alc663_mode6_unsol_event(struct hda_codec *codec,
18480 unsigned int res)
18481{
18482 switch (res >> 26) {
18483 case ALC880_HP_EVENT:
18484 alc663_two_hp_m2_speaker_automute(codec);
18485 break;
18486 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018487 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018488 break;
18489 }
18490}
18491
Kailang Yangebb83ee2009-12-17 12:23:00 +010018492#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018493
Kailang Yangf1d4e282008-08-26 14:03:29 +020018494static void alc663_mode6_inithook(struct hda_codec *codec)
18495{
18496 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018497 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018498}
18499
Kailang Yangebb83ee2009-12-17 12:23:00 +010018500/* ***************** Mode7 ******************************/
18501static void alc663_mode7_unsol_event(struct hda_codec *codec,
18502 unsigned int res)
18503{
18504 switch (res >> 26) {
18505 case ALC880_HP_EVENT:
18506 alc663_two_hp_m7_speaker_automute(codec);
18507 break;
18508 case ALC880_MIC_EVENT:
18509 alc_mic_automute(codec);
18510 break;
18511 }
18512}
18513
18514#define alc663_mode7_setup alc663_mode1_setup
18515
18516static void alc663_mode7_inithook(struct hda_codec *codec)
18517{
18518 alc663_two_hp_m7_speaker_automute(codec);
18519 alc_mic_automute(codec);
18520}
18521
18522/* ***************** Mode8 ******************************/
18523static void alc663_mode8_unsol_event(struct hda_codec *codec,
18524 unsigned int res)
18525{
18526 switch (res >> 26) {
18527 case ALC880_HP_EVENT:
18528 alc663_two_hp_m8_speaker_automute(codec);
18529 break;
18530 case ALC880_MIC_EVENT:
18531 alc_mic_automute(codec);
18532 break;
18533 }
18534}
18535
18536#define alc663_mode8_setup alc663_m51va_setup
18537
18538static void alc663_mode8_inithook(struct hda_codec *codec)
18539{
18540 alc663_two_hp_m8_speaker_automute(codec);
18541 alc_mic_automute(codec);
18542}
18543
Kailang Yang6dda9f42008-05-27 12:05:31 +020018544static void alc663_g71v_hp_automute(struct hda_codec *codec)
18545{
18546 unsigned int present;
18547 unsigned char bits;
18548
Wu Fengguang864f92b2009-11-18 12:38:02 +080018549 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018550 bits = present ? HDA_AMP_MUTE : 0;
18551 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18552 HDA_AMP_MUTE, bits);
18553 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18554 HDA_AMP_MUTE, bits);
18555}
18556
18557static void alc663_g71v_front_automute(struct hda_codec *codec)
18558{
18559 unsigned int present;
18560 unsigned char bits;
18561
Wu Fengguang864f92b2009-11-18 12:38:02 +080018562 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018563 bits = present ? HDA_AMP_MUTE : 0;
18564 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18565 HDA_AMP_MUTE, bits);
18566}
18567
18568static void alc663_g71v_unsol_event(struct hda_codec *codec,
18569 unsigned int res)
18570{
18571 switch (res >> 26) {
18572 case ALC880_HP_EVENT:
18573 alc663_g71v_hp_automute(codec);
18574 break;
18575 case ALC880_FRONT_EVENT:
18576 alc663_g71v_front_automute(codec);
18577 break;
18578 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018579 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018580 break;
18581 }
18582}
18583
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018584#define alc663_g71v_setup alc663_m51va_setup
18585
Kailang Yang6dda9f42008-05-27 12:05:31 +020018586static void alc663_g71v_inithook(struct hda_codec *codec)
18587{
18588 alc663_g71v_front_automute(codec);
18589 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018590 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018591}
18592
18593static void alc663_g50v_unsol_event(struct hda_codec *codec,
18594 unsigned int res)
18595{
18596 switch (res >> 26) {
18597 case ALC880_HP_EVENT:
18598 alc663_m51va_speaker_automute(codec);
18599 break;
18600 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018601 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018602 break;
18603 }
18604}
18605
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018606#define alc663_g50v_setup alc663_m51va_setup
18607
Kailang Yang6dda9f42008-05-27 12:05:31 +020018608static void alc663_g50v_inithook(struct hda_codec *codec)
18609{
18610 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018611 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018612}
18613
Kailang Yangf1d4e282008-08-26 14:03:29 +020018614static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18615 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018616 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018617
David Henningsson5f99f862011-01-04 15:24:24 +010018618 HDA_CODEC_VOLUME("Mic/LineIn Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018619 HDA_CODEC_VOLUME("Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18620 HDA_CODEC_MUTE("Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018621
David Henningsson5f99f862011-01-04 15:24:24 +010018622 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018623 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18624 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018625 { } /* end */
18626};
18627
Chris Pockelé9541ba12009-05-12 08:08:53 +020018628static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18629 /* Master Playback automatically created from Speaker and Headphone */
18630 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18631 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18632 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18633 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18634
David Henningsson8607f7c2010-12-20 14:43:54 +010018635 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18636 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018637 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018638
David Henningsson28c4edb2010-12-20 14:24:29 +010018639 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18640 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018641 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018642 { } /* end */
18643};
18644
Takashi Iwaicb53c622007-08-10 17:21:45 +020018645#ifdef CONFIG_SND_HDA_POWER_SAVE
18646#define alc662_loopbacks alc880_loopbacks
18647#endif
18648
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018649
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018650/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018651#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18652#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18653#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18654#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18655
18656/*
18657 * configuration and preset
18658 */
Takashi Iwaiea734962011-01-17 11:29:34 +010018659static const char * const alc662_models[ALC662_MODEL_LAST] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018660 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18661 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18662 [ALC662_3ST_6ch] = "3stack-6ch",
18663 [ALC662_5ST_DIG] = "6stack-dig",
18664 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018665 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018666 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018667 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018668 [ALC663_ASUS_M51VA] = "m51va",
18669 [ALC663_ASUS_G71V] = "g71v",
18670 [ALC663_ASUS_H13] = "h13",
18671 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018672 [ALC663_ASUS_MODE1] = "asus-mode1",
18673 [ALC662_ASUS_MODE2] = "asus-mode2",
18674 [ALC663_ASUS_MODE3] = "asus-mode3",
18675 [ALC663_ASUS_MODE4] = "asus-mode4",
18676 [ALC663_ASUS_MODE5] = "asus-mode5",
18677 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018678 [ALC663_ASUS_MODE7] = "asus-mode7",
18679 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018680 [ALC272_DELL] = "dell",
18681 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018682 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018683 [ALC662_AUTO] = "auto",
18684};
18685
18686static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018687 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018688 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18689 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018690 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18691 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018692 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018693 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18694 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18695 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18696 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018697 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18698 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018699 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018700 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18701 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18702 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18703 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18704 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018705 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018706 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18707 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018708 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18709 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18710 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18711 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018712 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018713 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18714 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18715 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018716 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18717 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18718 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18719 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018720 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018721 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18722 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018723 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018724 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18725 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18726 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018727 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018728 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018729 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18730 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018731 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18732 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18733 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018734 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018735 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18736 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018737 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018738 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018739 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018740 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18741 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18742 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018743 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018744 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18745 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018746 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018747 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018748 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018749 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018750 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18751 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018752 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018753 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018754 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18755 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018756 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018757 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018758 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018759 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018760 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018761 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018762 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18763 ALC663_ASUS_H13),
Anisse Astier965b76d2011-02-10 13:14:44 +010018764 SND_PCI_QUIRK(0x1991, 0x5628, "Ordissimo EVE", ALC662_LENOVO_101E),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018765 {}
18766};
18767
18768static struct alc_config_preset alc662_presets[] = {
18769 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018770 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018771 .init_verbs = { alc662_init_verbs },
18772 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18773 .dac_nids = alc662_dac_nids,
18774 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018775 .dig_in_nid = ALC662_DIGIN_NID,
18776 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18777 .channel_mode = alc662_3ST_2ch_modes,
18778 .input_mux = &alc662_capture_source,
18779 },
18780 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018781 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018782 .init_verbs = { alc662_init_verbs },
18783 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18784 .dac_nids = alc662_dac_nids,
18785 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018786 .dig_in_nid = ALC662_DIGIN_NID,
18787 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18788 .channel_mode = alc662_3ST_6ch_modes,
18789 .need_dac_fix = 1,
18790 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018791 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018792 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018793 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018794 .init_verbs = { alc662_init_verbs },
18795 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18796 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018797 .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_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018803 .mixers = { alc662_base_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,
18807 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018808 .dig_in_nid = ALC662_DIGIN_NID,
18809 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18810 .channel_mode = alc662_5stack_modes,
18811 .input_mux = &alc662_capture_source,
18812 },
18813 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018814 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018815 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18816 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18817 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018818 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18819 .channel_mode = alc662_3ST_2ch_modes,
18820 .input_mux = &alc662_lenovo_101e_capture_source,
18821 .unsol_event = alc662_lenovo_101e_unsol_event,
18822 .init_hook = alc662_lenovo_101e_all_automute,
18823 },
Kailang Yang291702f2007-10-16 14:28:03 +020018824 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018825 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018826 .init_verbs = { alc662_init_verbs,
18827 alc662_eeepc_sue_init_verbs },
18828 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18829 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018830 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18831 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018832 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018833 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018834 .init_hook = alc662_eeepc_inithook,
18835 },
Kailang Yang8c427222008-01-10 13:03:59 +010018836 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018837 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018838 alc662_chmode_mixer },
18839 .init_verbs = { alc662_init_verbs,
18840 alc662_eeepc_ep20_sue_init_verbs },
18841 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18842 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018843 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18844 .channel_mode = alc662_3ST_6ch_modes,
18845 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018846 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018847 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018848 .init_hook = alc662_eeepc_ep20_inithook,
18849 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018850 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018851 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018852 .init_verbs = { alc662_init_verbs,
18853 alc662_ecs_init_verbs },
18854 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18855 .dac_nids = alc662_dac_nids,
18856 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18857 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018858 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018859 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018860 .init_hook = alc662_eeepc_inithook,
18861 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018862 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018863 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018864 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18865 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18866 .dac_nids = alc662_dac_nids,
18867 .dig_out_nid = ALC662_DIGOUT_NID,
18868 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18869 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018870 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018871 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018872 .init_hook = alc663_m51va_inithook,
18873 },
18874 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018875 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018876 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18877 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18878 .dac_nids = alc662_dac_nids,
18879 .dig_out_nid = ALC662_DIGOUT_NID,
18880 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18881 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018882 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018883 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018884 .init_hook = alc663_g71v_inithook,
18885 },
18886 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018887 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018888 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18889 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18890 .dac_nids = alc662_dac_nids,
18891 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18892 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018893 .unsol_event = alc663_m51va_unsol_event,
18894 .init_hook = alc663_m51va_inithook,
18895 },
18896 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018897 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018898 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18899 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18900 .dac_nids = alc662_dac_nids,
18901 .dig_out_nid = ALC662_DIGOUT_NID,
18902 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18903 .channel_mode = alc662_3ST_6ch_modes,
18904 .input_mux = &alc663_capture_source,
18905 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018906 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018907 .init_hook = alc663_g50v_inithook,
18908 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018909 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018910 .mixers = { alc663_m51va_mixer },
18911 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018912 .init_verbs = { alc662_init_verbs,
18913 alc663_21jd_amic_init_verbs },
18914 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18915 .hp_nid = 0x03,
18916 .dac_nids = alc662_dac_nids,
18917 .dig_out_nid = ALC662_DIGOUT_NID,
18918 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18919 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018920 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018921 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018922 .init_hook = alc663_mode1_inithook,
18923 },
18924 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018925 .mixers = { alc662_1bjd_mixer },
18926 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018927 .init_verbs = { alc662_init_verbs,
18928 alc662_1bjd_amic_init_verbs },
18929 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18930 .dac_nids = alc662_dac_nids,
18931 .dig_out_nid = ALC662_DIGOUT_NID,
18932 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18933 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018934 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018935 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018936 .init_hook = alc662_mode2_inithook,
18937 },
18938 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018939 .mixers = { alc663_two_hp_m1_mixer },
18940 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018941 .init_verbs = { alc662_init_verbs,
18942 alc663_two_hp_amic_m1_init_verbs },
18943 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18944 .hp_nid = 0x03,
18945 .dac_nids = alc662_dac_nids,
18946 .dig_out_nid = ALC662_DIGOUT_NID,
18947 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18948 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018949 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018950 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018951 .init_hook = alc663_mode3_inithook,
18952 },
18953 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018954 .mixers = { alc663_asus_21jd_clfe_mixer },
18955 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018956 .init_verbs = { alc662_init_verbs,
18957 alc663_21jd_amic_init_verbs},
18958 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18959 .hp_nid = 0x03,
18960 .dac_nids = alc662_dac_nids,
18961 .dig_out_nid = ALC662_DIGOUT_NID,
18962 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18963 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018964 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018965 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018966 .init_hook = alc663_mode4_inithook,
18967 },
18968 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018969 .mixers = { alc663_asus_15jd_clfe_mixer },
18970 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018971 .init_verbs = { alc662_init_verbs,
18972 alc663_15jd_amic_init_verbs },
18973 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18974 .hp_nid = 0x03,
18975 .dac_nids = alc662_dac_nids,
18976 .dig_out_nid = ALC662_DIGOUT_NID,
18977 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18978 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018979 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018980 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018981 .init_hook = alc663_mode5_inithook,
18982 },
18983 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018984 .mixers = { alc663_two_hp_m2_mixer },
18985 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018986 .init_verbs = { alc662_init_verbs,
18987 alc663_two_hp_amic_m2_init_verbs },
18988 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18989 .hp_nid = 0x03,
18990 .dac_nids = alc662_dac_nids,
18991 .dig_out_nid = ALC662_DIGOUT_NID,
18992 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18993 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018994 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018995 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018996 .init_hook = alc663_mode6_inithook,
18997 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018998 [ALC663_ASUS_MODE7] = {
18999 .mixers = { alc663_mode7_mixer },
19000 .cap_mixer = alc662_auto_capture_mixer,
19001 .init_verbs = { alc662_init_verbs,
19002 alc663_mode7_init_verbs },
19003 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
19004 .hp_nid = 0x03,
19005 .dac_nids = alc662_dac_nids,
19006 .dig_out_nid = ALC662_DIGOUT_NID,
19007 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19008 .channel_mode = alc662_3ST_2ch_modes,
19009 .unsol_event = alc663_mode7_unsol_event,
19010 .setup = alc663_mode7_setup,
19011 .init_hook = alc663_mode7_inithook,
19012 },
19013 [ALC663_ASUS_MODE8] = {
19014 .mixers = { alc663_mode8_mixer },
19015 .cap_mixer = alc662_auto_capture_mixer,
19016 .init_verbs = { alc662_init_verbs,
19017 alc663_mode8_init_verbs },
19018 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
19019 .hp_nid = 0x03,
19020 .dac_nids = alc662_dac_nids,
19021 .dig_out_nid = ALC662_DIGOUT_NID,
19022 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19023 .channel_mode = alc662_3ST_2ch_modes,
19024 .unsol_event = alc663_mode8_unsol_event,
19025 .setup = alc663_mode8_setup,
19026 .init_hook = alc663_mode8_inithook,
19027 },
Kailang Yang622e84c2009-04-21 07:39:04 +020019028 [ALC272_DELL] = {
19029 .mixers = { alc663_m51va_mixer },
19030 .cap_mixer = alc272_auto_capture_mixer,
19031 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
19032 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19033 .dac_nids = alc662_dac_nids,
19034 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19035 .adc_nids = alc272_adc_nids,
19036 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
19037 .capsrc_nids = alc272_capsrc_nids,
19038 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020019039 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019040 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020019041 .init_hook = alc663_m51va_inithook,
19042 },
19043 [ALC272_DELL_ZM1] = {
19044 .mixers = { alc663_m51va_mixer },
19045 .cap_mixer = alc662_auto_capture_mixer,
19046 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
19047 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19048 .dac_nids = alc662_dac_nids,
19049 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19050 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019051 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020019052 .capsrc_nids = alc662_capsrc_nids,
19053 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020019054 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019055 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020019056 .init_hook = alc663_m51va_inithook,
19057 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020019058 [ALC272_SAMSUNG_NC10] = {
19059 .mixers = { alc272_nc10_mixer },
19060 .init_verbs = { alc662_init_verbs,
19061 alc663_21jd_amic_init_verbs },
19062 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19063 .dac_nids = alc272_dac_nids,
19064 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19065 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019066 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020019067 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019068 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020019069 .init_hook = alc663_mode4_inithook,
19070 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019071};
19072
19073
19074/*
19075 * BIOS auto configuration
19076 */
19077
Takashi Iwai7085ec12009-10-02 09:03:58 +020019078/* convert from MIX nid to DAC */
19079static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
19080{
19081 if (nid == 0x0f)
19082 return 0x02;
19083 else if (nid >= 0x0c && nid <= 0x0e)
19084 return nid - 0x0c + 0x02;
David Henningssoncc1c4522010-11-24 14:17:47 +010019085 else if (nid == 0x26) /* ALC887-VD has this DAC too */
19086 return 0x25;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019087 else
19088 return 0;
19089}
19090
19091/* get MIX nid connected to the given pin targeted to DAC */
19092static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
19093 hda_nid_t dac)
19094{
David Henningssoncc1c4522010-11-24 14:17:47 +010019095 hda_nid_t mix[5];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019096 int i, num;
19097
19098 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
19099 for (i = 0; i < num; i++) {
19100 if (alc662_mix_to_dac(mix[i]) == dac)
19101 return mix[i];
19102 }
19103 return 0;
19104}
19105
19106/* look for an empty DAC slot */
19107static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
19108{
19109 struct alc_spec *spec = codec->spec;
19110 hda_nid_t srcs[5];
19111 int i, j, num;
19112
19113 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
19114 if (num < 0)
19115 return 0;
19116 for (i = 0; i < num; i++) {
19117 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
19118 if (!nid)
19119 continue;
19120 for (j = 0; j < spec->multiout.num_dacs; j++)
19121 if (spec->multiout.dac_nids[j] == nid)
19122 break;
19123 if (j >= spec->multiout.num_dacs)
19124 return nid;
19125 }
19126 return 0;
19127}
19128
19129/* fill in the dac_nids table from the parsed pin configuration */
19130static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
19131 const struct auto_pin_cfg *cfg)
19132{
19133 struct alc_spec *spec = codec->spec;
19134 int i;
19135 hda_nid_t dac;
19136
19137 spec->multiout.dac_nids = spec->private_dac_nids;
19138 for (i = 0; i < cfg->line_outs; i++) {
19139 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
19140 if (!dac)
19141 continue;
19142 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19143 }
19144 return 0;
19145}
19146
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019147static inline int __alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
19148 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019149{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019150 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019151 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
19152}
19153
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019154static inline int __alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
19155 hda_nid_t nid, int idx, unsigned int chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019156{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019157 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019158 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
19159}
19160
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019161#define alc662_add_vol_ctl(spec, pfx, nid, chs) \
19162 __alc662_add_vol_ctl(spec, pfx, nid, 0, chs)
19163#define alc662_add_sw_ctl(spec, pfx, nid, chs) \
19164 __alc662_add_sw_ctl(spec, pfx, nid, 0, chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019165#define alc662_add_stereo_vol(spec, pfx, nid) \
19166 alc662_add_vol_ctl(spec, pfx, nid, 3)
19167#define alc662_add_stereo_sw(spec, pfx, nid) \
19168 alc662_add_sw_ctl(spec, pfx, nid, 3)
19169
19170/* add playback controls from the parsed DAC table */
19171static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
19172 const struct auto_pin_cfg *cfg)
19173{
19174 struct alc_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +010019175 static const char * const chname[4] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019176 "Front", "Surround", NULL /*CLFE*/, "Side"
19177 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019178 const char *pfx = alc_get_line_out_pfx(cfg, true);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019179 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019180 int i, err;
19181
19182 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019183 nid = spec->multiout.dac_nids[i];
19184 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019185 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019186 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
19187 if (!mix)
19188 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019189 if (!pfx && i == 2) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019190 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019191 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019192 if (err < 0)
19193 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019194 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019195 if (err < 0)
19196 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019197 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019198 if (err < 0)
19199 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019200 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019201 if (err < 0)
19202 return err;
19203 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019204 const char *name = pfx;
19205 if (!name)
19206 name = chname[i];
19207 err = __alc662_add_vol_ctl(spec, name, nid, i, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019208 if (err < 0)
19209 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019210 err = __alc662_add_sw_ctl(spec, name, mix, i, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019211 if (err < 0)
19212 return err;
19213 }
19214 }
19215 return 0;
19216}
19217
19218/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019219/* return DAC nid if any new DAC is assigned */
19220static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019221 const char *pfx)
19222{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019223 struct alc_spec *spec = codec->spec;
19224 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019225 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019226
19227 if (!pin)
19228 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019229 nid = alc662_look_for_dac(codec, pin);
19230 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019231 /* the corresponding DAC is already occupied */
19232 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
19233 return 0; /* no way */
19234 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019235 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019236 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19237 }
19238
19239 mix = alc662_dac_to_mix(codec, pin, nid);
19240 if (!mix)
19241 return 0;
19242 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
19243 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020019244 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019245 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
19246 if (err < 0)
19247 return err;
19248 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019249}
19250
19251/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020019252#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020019253 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019254
19255static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
19256 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019257 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019258{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019259 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020019260 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019261
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019262 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019263 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019264 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
19265 if (num <= 1)
19266 return;
19267 for (i = 0; i < num; i++) {
19268 if (alc662_mix_to_dac(srcs[i]) != dac)
19269 continue;
19270 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
19271 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019272 }
19273}
19274
19275static void alc662_auto_init_multi_out(struct hda_codec *codec)
19276{
19277 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019278 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019279 int i;
19280
19281 for (i = 0; i <= HDA_SIDE; i++) {
19282 hda_nid_t nid = spec->autocfg.line_out_pins[i];
19283 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020019284 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019285 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019286 }
19287}
19288
19289static void alc662_auto_init_hp_out(struct hda_codec *codec)
19290{
19291 struct alc_spec *spec = codec->spec;
19292 hda_nid_t pin;
19293
19294 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019295 if (pin)
19296 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
19297 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019298 pin = spec->autocfg.speaker_pins[0];
19299 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019300 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
19301 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019302}
19303
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019304#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
19305
19306static void alc662_auto_init_analog_input(struct hda_codec *codec)
19307{
19308 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019309 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019310 int i;
19311
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019312 for (i = 0; i < cfg->num_inputs; i++) {
19313 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019314 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020019315 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010019316 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010019317 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019318 snd_hda_codec_write(codec, nid, 0,
19319 AC_VERB_SET_AMP_GAIN_MUTE,
19320 AMP_OUT_MUTE);
19321 }
19322 }
19323}
19324
Takashi Iwaif511b012008-08-15 16:46:42 +020019325#define alc662_auto_init_input_src alc882_auto_init_input_src
19326
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019327static int alc662_parse_auto_config(struct hda_codec *codec)
19328{
19329 struct alc_spec *spec = codec->spec;
19330 int err;
19331 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
19332
19333 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19334 alc662_ignore);
19335 if (err < 0)
19336 return err;
19337 if (!spec->autocfg.line_outs)
19338 return 0; /* can't find valid BIOS pin config */
19339
Takashi Iwai7085ec12009-10-02 09:03:58 +020019340 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019341 if (err < 0)
19342 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019343 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019344 if (err < 0)
19345 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019346 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019347 spec->autocfg.speaker_pins[0],
19348 "Speaker");
19349 if (err < 0)
19350 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019351 if (err)
19352 spec->multiout.extra_out_nid[0] = err;
19353 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019354 "Headphone");
19355 if (err < 0)
19356 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019357 if (err)
19358 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019359 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019360 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019361 return err;
19362
19363 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
19364
Takashi Iwai757899a2010-07-30 10:48:14 +020019365 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019366
Takashi Iwai603c4012008-07-30 15:01:44 +020019367 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010019368 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019369
19370 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020019371 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020019372
Kailang Yangcec27c82010-02-04 14:18:18 +010019373 add_verb(spec, alc662_init_verbs);
19374 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019375 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Kailang Yangcec27c82010-02-04 14:18:18 +010019376 add_verb(spec, alc663_init_verbs);
19377
19378 if (codec->vendor_id == 0x10ec0272)
19379 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020019380
19381 err = alc_auto_add_mic_boost(codec);
19382 if (err < 0)
19383 return err;
19384
Kailang Yang6227cdc2010-02-25 08:36:52 +010019385 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
19386 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
19387 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
19388 else
19389 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020019390
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019391 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019392}
19393
19394/* additional initialization for auto-configuration model */
19395static void alc662_auto_init(struct hda_codec *codec)
19396{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019397 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019398 alc662_auto_init_multi_out(codec);
19399 alc662_auto_init_hp_out(codec);
19400 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020019401 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019402 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019403 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020019404 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019405}
19406
Todd Broch6be79482010-12-07 16:51:05 -080019407static void alc272_fixup_mario(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019408 const struct alc_fixup *fix, int action)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010019409{
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019410 if (action != ALC_FIXUP_ACT_PROBE)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010019411 return;
Todd Broch6be79482010-12-07 16:51:05 -080019412 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
19413 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
19414 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
19415 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
19416 (0 << AC_AMPCAP_MUTE_SHIFT)))
19417 printk(KERN_WARNING
19418 "hda_codec: failed to override amp caps for NID 0x2\n");
19419}
19420
David Henningsson6cb3b702010-09-09 08:51:44 +020019421enum {
Daniel T Chen2df03512010-10-10 22:39:28 -040019422 ALC662_FIXUP_ASPIRE,
David Henningsson6cb3b702010-09-09 08:51:44 +020019423 ALC662_FIXUP_IDEAPAD,
Todd Broch6be79482010-12-07 16:51:05 -080019424 ALC272_FIXUP_MARIO,
Anisse Astierd2ebd472011-01-20 12:36:21 +010019425 ALC662_FIXUP_CZC_P10T,
David Henningsson6cb3b702010-09-09 08:51:44 +020019426};
19427
19428static const struct alc_fixup alc662_fixups[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019429 [ALC662_FIXUP_ASPIRE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019430 .type = ALC_FIXUP_PINS,
19431 .v.pins = (const struct alc_pincfg[]) {
Daniel T Chen2df03512010-10-10 22:39:28 -040019432 { 0x15, 0x99130112 }, /* subwoofer */
19433 { }
19434 }
19435 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019436 [ALC662_FIXUP_IDEAPAD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019437 .type = ALC_FIXUP_PINS,
19438 .v.pins = (const struct alc_pincfg[]) {
David Henningsson6cb3b702010-09-09 08:51:44 +020019439 { 0x17, 0x99130112 }, /* subwoofer */
19440 { }
19441 }
19442 },
Todd Broch6be79482010-12-07 16:51:05 -080019443 [ALC272_FIXUP_MARIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019444 .type = ALC_FIXUP_FUNC,
19445 .v.func = alc272_fixup_mario,
Anisse Astierd2ebd472011-01-20 12:36:21 +010019446 },
19447 [ALC662_FIXUP_CZC_P10T] = {
19448 .type = ALC_FIXUP_VERBS,
19449 .v.verbs = (const struct hda_verb[]) {
19450 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
19451 {}
19452 }
19453 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019454};
19455
19456static struct snd_pci_quirk alc662_fixup_tbl[] = {
David Henningssona6c47a82011-02-10 15:39:19 +010019457 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
Daniel T Chen2df03512010-10-10 22:39:28 -040019458 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
Daniel T Chena0e90ac2010-11-20 10:20:35 -050019459 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
Valentine Sinitsynd4118582010-10-01 22:24:08 +060019460 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
David Henningsson6cb3b702010-09-09 08:51:44 +020019461 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
Anisse Astierd2ebd472011-01-20 12:36:21 +010019462 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
David Henningsson6cb3b702010-09-09 08:51:44 +020019463 {}
19464};
19465
Todd Broch6be79482010-12-07 16:51:05 -080019466static const struct alc_model_fixup alc662_fixup_models[] = {
19467 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
19468 {}
19469};
David Henningsson6cb3b702010-09-09 08:51:44 +020019470
19471
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019472static int patch_alc662(struct hda_codec *codec)
19473{
19474 struct alc_spec *spec;
19475 int err, board_config;
Kailang Yang693194f2010-10-21 08:51:48 +020019476 int coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019477
19478 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19479 if (!spec)
19480 return -ENOMEM;
19481
19482 codec->spec = spec;
19483
Kailang Yangda00c242010-03-19 11:23:45 +010019484 alc_auto_parse_customize_define(codec);
19485
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020019486 alc_fix_pll_init(codec, 0x20, 0x04, 15);
19487
Kailang Yang693194f2010-10-21 08:51:48 +020019488 coef = alc_read_coef_idx(codec, 0);
19489 if (coef == 0x8020 || coef == 0x8011)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019490 alc_codec_rename(codec, "ALC661");
Kailang Yang693194f2010-10-21 08:51:48 +020019491 else if (coef & (1 << 14) &&
19492 codec->bus->pci->subsystem_vendor == 0x1025 &&
19493 spec->cdefine.platform_type == 1)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019494 alc_codec_rename(codec, "ALC272X");
Kailang Yang693194f2010-10-21 08:51:48 +020019495 else if (coef == 0x4011)
19496 alc_codec_rename(codec, "ALC656");
Kailang Yang274693f2009-12-03 10:07:50 +010019497
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019498 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19499 alc662_models,
19500 alc662_cfg_tbl);
19501 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019502 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19503 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019504 board_config = ALC662_AUTO;
19505 }
19506
19507 if (board_config == ALC662_AUTO) {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019508 alc_pick_fixup(codec, alc662_fixup_models,
19509 alc662_fixup_tbl, alc662_fixups);
19510 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019511 /* automatic parse from the BIOS config */
19512 err = alc662_parse_auto_config(codec);
19513 if (err < 0) {
19514 alc_free(codec);
19515 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019516 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019517 printk(KERN_INFO
19518 "hda_codec: Cannot set up configuration "
19519 "from BIOS. Using base mode...\n");
19520 board_config = ALC662_3ST_2ch_DIG;
19521 }
19522 }
19523
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019524 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019525 err = snd_hda_attach_beep_device(codec, 0x1);
19526 if (err < 0) {
19527 alc_free(codec);
19528 return err;
19529 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019530 }
19531
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019532 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019533 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019534
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019535 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19536 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19537
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019538 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19539 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19540
Takashi Iwaidd704692009-08-11 08:45:11 +020019541 if (!spec->adc_nids) {
19542 spec->adc_nids = alc662_adc_nids;
19543 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19544 }
19545 if (!spec->capsrc_nids)
19546 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019547
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019548 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019549 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019550
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019551 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019552 switch (codec->vendor_id) {
19553 case 0x10ec0662:
19554 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19555 break;
19556 case 0x10ec0272:
19557 case 0x10ec0663:
19558 case 0x10ec0665:
19559 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19560 break;
19561 case 0x10ec0273:
19562 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19563 break;
19564 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019565 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019566 spec->vmaster_nid = 0x02;
19567
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019568 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
19569
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019570 codec->patch_ops = alc_patch_ops;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019571 if (board_config == ALC662_AUTO)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019572 spec->init_hook = alc662_auto_init;
David Henningsson6cb3b702010-09-09 08:51:44 +020019573
Kailang Yangbf1b0222010-10-21 08:49:56 +020019574 alc_init_jacks(codec);
19575
Takashi Iwaicb53c622007-08-10 17:21:45 +020019576#ifdef CONFIG_SND_HDA_POWER_SAVE
19577 if (!spec->loopback.amplist)
19578 spec->loopback.amplist = alc662_loopbacks;
19579#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019580
19581 return 0;
19582}
19583
Kailang Yang274693f2009-12-03 10:07:50 +010019584static int patch_alc888(struct hda_codec *codec)
19585{
19586 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19587 kfree(codec->chip_name);
Kailang Yang01e0f132010-11-22 10:59:36 +010019588 if (codec->vendor_id == 0x10ec0887)
19589 codec->chip_name = kstrdup("ALC887-VD", GFP_KERNEL);
19590 else
19591 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019592 if (!codec->chip_name) {
19593 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019594 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019595 }
19596 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019597 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019598 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019599}
19600
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019601/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019602 * ALC680 support
19603 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019604#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019605#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19606#define alc680_modes alc260_modes
19607
19608static hda_nid_t alc680_dac_nids[3] = {
19609 /* Lout1, Lout2, hp */
19610 0x02, 0x03, 0x04
19611};
19612
19613static hda_nid_t alc680_adc_nids[3] = {
19614 /* ADC0-2 */
19615 /* DMIC, MIC, Line-in*/
19616 0x07, 0x08, 0x09
19617};
19618
Kailang Yangc69aefa2010-08-17 10:39:22 +020019619/*
19620 * Analog capture ADC cgange
19621 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019622static void alc680_rec_autoswitch(struct hda_codec *codec)
19623{
19624 struct alc_spec *spec = codec->spec;
19625 struct auto_pin_cfg *cfg = &spec->autocfg;
19626 int pin_found = 0;
19627 int type_found = AUTO_PIN_LAST;
19628 hda_nid_t nid;
19629 int i;
19630
19631 for (i = 0; i < cfg->num_inputs; i++) {
19632 nid = cfg->inputs[i].pin;
19633 if (!(snd_hda_query_pin_caps(codec, nid) &
19634 AC_PINCAP_PRES_DETECT))
19635 continue;
19636 if (snd_hda_jack_detect(codec, nid)) {
19637 if (cfg->inputs[i].type < type_found) {
19638 type_found = cfg->inputs[i].type;
19639 pin_found = nid;
19640 }
19641 }
19642 }
19643
19644 nid = 0x07;
19645 if (pin_found)
19646 snd_hda_get_connections(codec, pin_found, &nid, 1);
19647
19648 if (nid != spec->cur_adc)
19649 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19650 spec->cur_adc = nid;
19651 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19652 spec->cur_adc_format);
19653}
19654
Kailang Yangc69aefa2010-08-17 10:39:22 +020019655static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19656 struct hda_codec *codec,
19657 unsigned int stream_tag,
19658 unsigned int format,
19659 struct snd_pcm_substream *substream)
19660{
19661 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019662
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019663 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019664 spec->cur_adc_stream_tag = stream_tag;
19665 spec->cur_adc_format = format;
19666
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019667 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019668 return 0;
19669}
19670
19671static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19672 struct hda_codec *codec,
19673 struct snd_pcm_substream *substream)
19674{
19675 snd_hda_codec_cleanup_stream(codec, 0x07);
19676 snd_hda_codec_cleanup_stream(codec, 0x08);
19677 snd_hda_codec_cleanup_stream(codec, 0x09);
19678 return 0;
19679}
19680
19681static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19682 .substreams = 1, /* can be overridden */
19683 .channels_min = 2,
19684 .channels_max = 2,
19685 /* NID is set in alc_build_pcms */
19686 .ops = {
19687 .prepare = alc680_capture_pcm_prepare,
19688 .cleanup = alc680_capture_pcm_cleanup
19689 },
19690};
19691
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019692static struct snd_kcontrol_new alc680_base_mixer[] = {
19693 /* output mixer control */
19694 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19695 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19696 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19697 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010019698 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x12, 0, HDA_INPUT),
19699 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
19700 HDA_CODEC_VOLUME("Line In Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019701 { }
19702};
19703
Kailang Yangc69aefa2010-08-17 10:39:22 +020019704static struct hda_bind_ctls alc680_bind_cap_vol = {
19705 .ops = &snd_hda_bind_vol,
19706 .values = {
19707 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19708 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19709 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19710 0
19711 },
19712};
19713
19714static struct hda_bind_ctls alc680_bind_cap_switch = {
19715 .ops = &snd_hda_bind_sw,
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 snd_kcontrol_new alc680_master_capture_mixer[] = {
19725 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19726 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019727 { } /* end */
19728};
19729
19730/*
19731 * generic initialization of ADC, input mixers and output mixers
19732 */
19733static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019734 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19735 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19736 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019737
Kailang Yangc69aefa2010-08-17 10:39:22 +020019738 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19739 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19740 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19741 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19742 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19743 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019744
19745 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19746 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19747 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19748 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19749 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019750
19751 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19752 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019753 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019754
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019755 { }
19756};
19757
Kailang Yangc69aefa2010-08-17 10:39:22 +020019758/* toggle speaker-output according to the hp-jack state */
19759static void alc680_base_setup(struct hda_codec *codec)
19760{
19761 struct alc_spec *spec = codec->spec;
19762
19763 spec->autocfg.hp_pins[0] = 0x16;
19764 spec->autocfg.speaker_pins[0] = 0x14;
19765 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019766 spec->autocfg.num_inputs = 2;
19767 spec->autocfg.inputs[0].pin = 0x18;
19768 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19769 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019770 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019771}
19772
19773static void alc680_unsol_event(struct hda_codec *codec,
19774 unsigned int res)
19775{
19776 if ((res >> 26) == ALC880_HP_EVENT)
19777 alc_automute_amp(codec);
19778 if ((res >> 26) == ALC880_MIC_EVENT)
19779 alc680_rec_autoswitch(codec);
19780}
19781
19782static void alc680_inithook(struct hda_codec *codec)
19783{
19784 alc_automute_amp(codec);
19785 alc680_rec_autoswitch(codec);
19786}
19787
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019788/* create input playback/capture controls for the given pin */
19789static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19790 const char *ctlname, int idx)
19791{
19792 hda_nid_t dac;
19793 int err;
19794
19795 switch (nid) {
19796 case 0x14:
19797 dac = 0x02;
19798 break;
19799 case 0x15:
19800 dac = 0x03;
19801 break;
19802 case 0x16:
19803 dac = 0x04;
19804 break;
19805 default:
19806 return 0;
19807 }
19808 if (spec->multiout.dac_nids[0] != dac &&
19809 spec->multiout.dac_nids[1] != dac) {
19810 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19811 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19812 HDA_OUTPUT));
19813 if (err < 0)
19814 return err;
19815
19816 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19817 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19818
19819 if (err < 0)
19820 return err;
19821 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19822 }
19823
19824 return 0;
19825}
19826
19827/* add playback controls from the parsed DAC table */
19828static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19829 const struct auto_pin_cfg *cfg)
19830{
19831 hda_nid_t nid;
19832 int err;
19833
19834 spec->multiout.dac_nids = spec->private_dac_nids;
19835
19836 nid = cfg->line_out_pins[0];
19837 if (nid) {
19838 const char *name;
19839 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19840 name = "Speaker";
19841 else
19842 name = "Front";
19843 err = alc680_new_analog_output(spec, nid, name, 0);
19844 if (err < 0)
19845 return err;
19846 }
19847
19848 nid = cfg->speaker_pins[0];
19849 if (nid) {
19850 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19851 if (err < 0)
19852 return err;
19853 }
19854 nid = cfg->hp_pins[0];
19855 if (nid) {
19856 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19857 if (err < 0)
19858 return err;
19859 }
19860
19861 return 0;
19862}
19863
19864static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19865 hda_nid_t nid, int pin_type)
19866{
19867 alc_set_pin_output(codec, nid, pin_type);
19868}
19869
19870static void alc680_auto_init_multi_out(struct hda_codec *codec)
19871{
19872 struct alc_spec *spec = codec->spec;
19873 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19874 if (nid) {
19875 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19876 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19877 }
19878}
19879
19880static void alc680_auto_init_hp_out(struct hda_codec *codec)
19881{
19882 struct alc_spec *spec = codec->spec;
19883 hda_nid_t pin;
19884
19885 pin = spec->autocfg.hp_pins[0];
19886 if (pin)
19887 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19888 pin = spec->autocfg.speaker_pins[0];
19889 if (pin)
19890 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19891}
19892
19893/* pcm configuration: identical with ALC880 */
19894#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19895#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19896#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19897#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019898#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019899
19900/*
19901 * BIOS auto configuration
19902 */
19903static int alc680_parse_auto_config(struct hda_codec *codec)
19904{
19905 struct alc_spec *spec = codec->spec;
19906 int err;
19907 static hda_nid_t alc680_ignore[] = { 0 };
19908
19909 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19910 alc680_ignore);
19911 if (err < 0)
19912 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019913
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019914 if (!spec->autocfg.line_outs) {
19915 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19916 spec->multiout.max_channels = 2;
19917 spec->no_analog = 1;
19918 goto dig_only;
19919 }
19920 return 0; /* can't find valid BIOS pin config */
19921 }
19922 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19923 if (err < 0)
19924 return err;
19925
19926 spec->multiout.max_channels = 2;
19927
19928 dig_only:
19929 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019930 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019931 if (spec->kctls.list)
19932 add_mixer(spec, spec->kctls.list);
19933
19934 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019935
19936 err = alc_auto_add_mic_boost(codec);
19937 if (err < 0)
19938 return err;
19939
19940 return 1;
19941}
19942
19943#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19944
19945/* init callback for auto-configuration model -- overriding the default init */
19946static void alc680_auto_init(struct hda_codec *codec)
19947{
19948 struct alc_spec *spec = codec->spec;
19949 alc680_auto_init_multi_out(codec);
19950 alc680_auto_init_hp_out(codec);
19951 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019952 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019953 if (spec->unsol_event)
19954 alc_inithook(codec);
19955}
19956
19957/*
19958 * configuration and preset
19959 */
Takashi Iwaiea734962011-01-17 11:29:34 +010019960static const char * const alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019961 [ALC680_BASE] = "base",
19962 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019963};
19964
19965static struct snd_pci_quirk alc680_cfg_tbl[] = {
19966 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19967 {}
19968};
19969
19970static struct alc_config_preset alc680_presets[] = {
19971 [ALC680_BASE] = {
19972 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019973 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019974 .init_verbs = { alc680_init_verbs },
19975 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19976 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019977 .dig_out_nid = ALC680_DIGOUT_NID,
19978 .num_channel_mode = ARRAY_SIZE(alc680_modes),
19979 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020019980 .unsol_event = alc680_unsol_event,
19981 .setup = alc680_base_setup,
19982 .init_hook = alc680_inithook,
19983
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019984 },
19985};
19986
19987static int patch_alc680(struct hda_codec *codec)
19988{
19989 struct alc_spec *spec;
19990 int board_config;
19991 int err;
19992
19993 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19994 if (spec == NULL)
19995 return -ENOMEM;
19996
19997 codec->spec = spec;
19998
19999 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
20000 alc680_models,
20001 alc680_cfg_tbl);
20002
20003 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
20004 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
20005 codec->chip_name);
20006 board_config = ALC680_AUTO;
20007 }
20008
20009 if (board_config == ALC680_AUTO) {
20010 /* automatic parse from the BIOS config */
20011 err = alc680_parse_auto_config(codec);
20012 if (err < 0) {
20013 alc_free(codec);
20014 return err;
20015 } else if (!err) {
20016 printk(KERN_INFO
20017 "hda_codec: Cannot set up configuration "
20018 "from BIOS. Using base mode...\n");
20019 board_config = ALC680_BASE;
20020 }
20021 }
20022
20023 if (board_config != ALC680_AUTO)
20024 setup_preset(codec, &alc680_presets[board_config]);
20025
20026 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020020027 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020028 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020020029 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020030
20031 if (!spec->adc_nids) {
20032 spec->adc_nids = alc680_adc_nids;
20033 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
20034 }
20035
20036 if (!spec->cap_mixer)
20037 set_capture_mixer(codec);
20038
20039 spec->vmaster_nid = 0x02;
20040
20041 codec->patch_ops = alc_patch_ops;
20042 if (board_config == ALC680_AUTO)
20043 spec->init_hook = alc680_auto_init;
20044
20045 return 0;
20046}
20047
20048/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070020049 * patch entries
20050 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010020051static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070020052 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020053 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020054 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020020055 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020056 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020057 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020020058 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020059 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020060 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020061 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020062 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
20063 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
20064 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020065 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020066 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020067 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
20068 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020020069 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010020070 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010020071 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020072 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020073 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020074 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020075 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020020076 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020077 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020020078 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020079 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020080 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yang01e0f132010-11-22 10:59:36 +010020081 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc888 },
Kailang Yang44426082008-10-15 11:18:05 +020020082 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020083 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020084 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020085 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020086 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020087 {} /* terminator */
20088};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010020089
20090MODULE_ALIAS("snd-hda-codec-id:10ec*");
20091
20092MODULE_LICENSE("GPL");
20093MODULE_DESCRIPTION("Realtek HD-audio codec");
20094
20095static struct hda_codec_preset_list realtek_list = {
20096 .preset = snd_hda_preset_realtek,
20097 .owner = THIS_MODULE,
20098};
20099
20100static int __init patch_realtek_init(void)
20101{
20102 return snd_hda_add_codec_preset(&realtek_list);
20103}
20104
20105static void __exit patch_realtek_exit(void)
20106{
20107 snd_hda_delete_codec_preset(&realtek_list);
20108}
20109
20110module_init(patch_realtek_init)
20111module_exit(patch_realtek_exit)