blob: 1e5a786c8c27f893dad6f304a1e049e5e0adaeaa [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
Kailang Yang9ad0e492010-09-14 23:22:00 +020031#include <sound/jack.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include "hda_codec.h"
33#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090034#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
Kailang Yangccc656c2006-10-17 12:32:26 +020036#define ALC880_FRONT_EVENT 0x01
37#define ALC880_DCVOL_EVENT 0x02
38#define ALC880_HP_EVENT 0x04
39#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
41/* ALC880 board config type */
42enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 ALC880_3ST,
44 ALC880_3ST_DIG,
45 ALC880_5ST,
46 ALC880_5ST_DIG,
47 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020048 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020049 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020050 ALC880_6ST_DIG,
51 ALC880_F1734,
52 ALC880_ASUS,
53 ALC880_ASUS_DIG,
54 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010055 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010056 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020057 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020058 ALC880_UNIWILL,
59 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010060 ALC880_CLEVO,
61 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010062 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010063 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020064 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020065#ifdef CONFIG_SND_DEBUG
66 ALC880_TEST,
67#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010068 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020069 ALC880_MODEL_LAST /* last tag */
70};
71
72/* ALC260 models */
73enum {
74 ALC260_BASIC,
75 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020076 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010077 ALC260_HP_3013,
78 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010079 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020080 ALC260_WILL,
81 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010082 ALC260_FAVORIT100,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010083#ifdef CONFIG_SND_DEBUG
84 ALC260_TEST,
85#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010086 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020087 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070088};
89
Kailang Yangdf694da2005-12-05 19:42:22 +010090/* ALC262 models */
91enum {
92 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020093 ALC262_HIPPO,
94 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010095 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020096 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010097 ALC262_HP_BPC_D7000_WL,
98 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010099 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +0100100 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200101 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200102 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200103 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200104 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100105 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200106 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200107 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200108 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000109 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100110 ALC262_AUTO,
111 ALC262_MODEL_LAST /* last tag */
112};
113
Kailang Yanga361d842007-06-05 12:30:55 +0200114/* ALC268 models */
115enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200116 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200117 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200118 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200119 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100120 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200121 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100122 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100123 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100124#ifdef CONFIG_SND_DEBUG
125 ALC268_TEST,
126#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200127 ALC268_AUTO,
128 ALC268_MODEL_LAST /* last tag */
129};
130
Kailang Yangf6a92242007-12-13 16:52:54 +0100131/* ALC269 models */
132enum {
133 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200134 ALC269_QUANTA_FL1,
Kailang Yang84898e82010-02-04 14:16:14 +0100135 ALC269_AMIC,
136 ALC269_DMIC,
137 ALC269VB_AMIC,
138 ALC269VB_DMIC,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100139 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000140 ALC269_LIFEBOOK,
Kailang Yangfe3eb0a2010-08-06 10:02:57 +0200141 ALC271_ACER,
Kailang Yangf6a92242007-12-13 16:52:54 +0100142 ALC269_AUTO,
143 ALC269_MODEL_LAST /* last tag */
144};
145
Kailang Yangdf694da2005-12-05 19:42:22 +0100146/* ALC861 models */
147enum {
148 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200149 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100150 ALC861_3ST_DIG,
151 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200152 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200153 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200154 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100155 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100156 ALC861_AUTO,
157 ALC861_MODEL_LAST,
158};
159
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100160/* ALC861-VD models */
161enum {
162 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200163 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100164 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100165 ALC861VD_3ST,
166 ALC861VD_3ST_DIG,
167 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200168 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200169 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200170 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100171 ALC861VD_AUTO,
172 ALC861VD_MODEL_LAST,
173};
174
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200175/* ALC662 models */
176enum {
177 ALC662_3ST_2ch_DIG,
178 ALC662_3ST_6ch_DIG,
179 ALC662_3ST_6ch,
180 ALC662_5ST_DIG,
181 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200182 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100183 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200184 ALC663_ASUS_M51VA,
185 ALC663_ASUS_G71V,
186 ALC663_ASUS_H13,
187 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200188 ALC662_ECS,
189 ALC663_ASUS_MODE1,
190 ALC662_ASUS_MODE2,
191 ALC663_ASUS_MODE3,
192 ALC663_ASUS_MODE4,
193 ALC663_ASUS_MODE5,
194 ALC663_ASUS_MODE6,
Kailang Yangebb83ee2009-12-17 12:23:00 +0100195 ALC663_ASUS_MODE7,
196 ALC663_ASUS_MODE8,
Kailang Yang622e84c2009-04-21 07:39:04 +0200197 ALC272_DELL,
198 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200199 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200200 ALC662_AUTO,
201 ALC662_MODEL_LAST,
202};
203
Kailang Yangdf694da2005-12-05 19:42:22 +0100204/* ALC882 models */
205enum {
206 ALC882_3ST_DIG,
207 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200208 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200209 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200210 ALC882_TARGA,
211 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200212 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100213 ALC885_MACPRO,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -0800214 ALC885_MBA21,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200215 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200216 ALC885_MB5,
Luke Yelaviche458b1f2010-02-12 16:28:29 +1100217 ALC885_MACMINI3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200218 ALC885_IMAC24,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -0800219 ALC885_IMAC91,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200220 ALC883_3ST_2ch_DIG,
221 ALC883_3ST_6ch_DIG,
222 ALC883_3ST_6ch,
223 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200224 ALC883_TARGA_DIG,
225 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200226 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200227 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200228 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800229 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100230 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200231 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200232 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200233 ALC883_MEDION,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +0200234 ALC883_MEDION_WIM2160,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100235 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200236 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200237 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200238 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200239 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200240 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200241 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100242 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100243 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430244 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100245 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100246 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800247 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200248 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200249 ALC889A_INTEL,
250 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200251 ALC888_ASUS_M90V,
252 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200253 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100254 ALC1200_ASUS_P5Q,
Guido Günther3e1647c52009-06-05 00:47:26 +0200255 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200256 ALC882_AUTO,
257 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200258};
259
Takashi Iwaid4a86d82010-06-23 17:51:26 +0200260/* ALC680 models */
261enum {
262 ALC680_BASE,
263 ALC680_AUTO,
264 ALC680_MODEL_LAST,
265};
266
Kailang Yangdf694da2005-12-05 19:42:22 +0100267/* for GPIO Poll */
268#define GPIO_MASK 0x03
269
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200270/* extra amp-initialization sequence types */
271enum {
272 ALC_INIT_NONE,
273 ALC_INIT_DEFAULT,
274 ALC_INIT_GPIO1,
275 ALC_INIT_GPIO2,
276 ALC_INIT_GPIO3,
277};
278
Takashi Iwai6c819492009-08-10 18:47:44 +0200279struct alc_mic_route {
280 hda_nid_t pin;
281 unsigned char mux_idx;
282 unsigned char amix_idx;
283};
284
285#define MUX_IDX_UNDEF ((unsigned char)-1)
286
Kailang Yangda00c242010-03-19 11:23:45 +0100287struct alc_customize_define {
288 unsigned int sku_cfg;
289 unsigned char port_connectivity;
290 unsigned char check_sum;
291 unsigned char customization;
292 unsigned char external_amp;
293 unsigned int enable_pcbeep:1;
294 unsigned int platform_type:1;
295 unsigned int swap:1;
296 unsigned int override:1;
David Henningsson90622912010-10-14 14:50:18 +0200297 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
Kailang Yangda00c242010-03-19 11:23:45 +0100298};
299
Takashi Iwaib5bfbc62011-01-13 14:22:32 +0100300struct alc_fixup;
301
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302struct alc_spec {
303 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100304 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100306 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100307 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200309 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200310 * don't forget NULL
311 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200312 */
313 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200315 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 struct hda_pcm_stream *stream_analog_playback;
317 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100318 struct hda_pcm_stream *stream_analog_alt_playback;
319 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200321 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 struct hda_pcm_stream *stream_digital_playback;
323 struct hda_pcm_stream *stream_digital_capture;
324
325 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200326 struct hda_multi_out multiout; /* playback set-up
327 * max_channels, dacs must be set
328 * dig_out_nid and hp_nid are optional
329 */
Takashi Iwai63300792008-01-24 15:31:36 +0100330 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100331 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100332 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333
334 /* capture */
335 unsigned int num_adc_nids;
336 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100337 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200338 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339
Takashi Iwai840b64c2010-07-13 22:49:01 +0200340 /* capture setup for dynamic dual-adc switch */
341 unsigned int cur_adc_idx;
342 hda_nid_t cur_adc;
343 unsigned int cur_adc_stream_tag;
344 unsigned int cur_adc_format;
345
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200347 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 const struct hda_input_mux *input_mux;
349 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200350 struct alc_mic_route ext_mic;
351 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352
353 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100354 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200356 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200357 int const_channel_count;
358 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359
360 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100361 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200362
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200363 /* dynamic controls, init_verbs and input_mux */
364 struct auto_pin_cfg autocfg;
Kailang Yangda00c242010-03-19 11:23:45 +0100365 struct alc_customize_define cdefine;
Takashi Iwai603c4012008-07-30 15:01:44 +0200366 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200367 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200368 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200369 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
370 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100371
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100372 /* hooks */
373 void (*init_hook)(struct hda_codec *codec);
374 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100375#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -0500376 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100377#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100378
Takashi Iwai834be882006-03-01 14:16:17 +0100379 /* for pin sensing */
380 unsigned int sense_updated: 1;
381 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100382 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200383 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200384
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100385 /* other flags */
386 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai840b64c2010-07-13 22:49:01 +0200387 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */
Takashi Iwai584c0c42011-03-10 12:51:11 +0100388 unsigned int single_input_src:1;
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200389 int init_amp;
Takashi Iwaid433a672010-09-20 15:11:54 +0200390 int codec_variant; /* flag for other variants */
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100391
Takashi Iwai2134ea42008-01-10 16:53:55 +0100392 /* for virtual master */
393 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200394#ifdef CONFIG_SND_HDA_POWER_SAVE
395 struct hda_loopback_check loopback;
396#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200397
398 /* for PLL fix */
399 hda_nid_t pll_nid;
400 unsigned int pll_coef_idx, pll_coef_bit;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +0100401
402 /* fix-up list */
403 int fixup_id;
404 const struct alc_fixup *fixup_list;
405 const char *fixup_name;
Kailang Yangdf694da2005-12-05 19:42:22 +0100406};
407
408/*
409 * configuration template - to be copied to the spec instance
410 */
411struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200412 struct snd_kcontrol_new *mixers[5]; /* should be identical size
413 * with spec
414 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100415 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100416 const struct hda_verb *init_verbs[5];
417 unsigned int num_dacs;
418 hda_nid_t *dac_nids;
419 hda_nid_t dig_out_nid; /* optional */
420 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800421 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100422 unsigned int num_adc_nids;
423 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100424 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100425 hda_nid_t dig_in_nid;
426 unsigned int num_channel_mode;
427 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200428 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200429 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200430 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100431 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100432 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200433 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100434 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200435#ifdef CONFIG_SND_HDA_POWER_SAVE
436 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500437 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200438#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439};
440
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441
442/*
443 * input MUX handling
444 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200445static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
446 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447{
448 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
449 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200450 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
451 if (mux_idx >= spec->num_mux_defs)
452 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100453 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
454 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200455 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456}
457
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200458static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
459 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460{
461 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
462 struct alc_spec *spec = codec->spec;
463 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
464
465 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
466 return 0;
467}
468
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200469static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
470 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471{
472 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
473 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100474 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100476 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100477 hda_nid_t nid = spec->capsrc_nids ?
478 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200479 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480
Takashi Iwaicd896c32008-11-18 12:36:33 +0100481 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
482 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100483 if (!imux->num_items && mux_idx > 0)
484 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100485
Takashi Iwaia22d5432009-07-27 12:54:26 +0200486 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200487 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100488 /* Matrix-mixer style (e.g. ALC882) */
489 unsigned int *cur_val = &spec->cur_mux[adc_idx];
490 unsigned int i, idx;
491
492 idx = ucontrol->value.enumerated.item[0];
493 if (idx >= imux->num_items)
494 idx = imux->num_items - 1;
495 if (*cur_val == idx)
496 return 0;
497 for (i = 0; i < imux->num_items; i++) {
498 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
499 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
500 imux->items[i].index,
501 HDA_AMP_MUTE, v);
502 }
503 *cur_val = idx;
504 return 1;
505 } else {
506 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100507 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100508 &spec->cur_mux[adc_idx]);
509 }
510}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200511
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512/*
513 * channel mode setting
514 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200515static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
516 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517{
518 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
519 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100520 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
521 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522}
523
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200524static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
525 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526{
527 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
528 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100529 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200530 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200531 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532}
533
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200534static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
535 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536{
537 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
538 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200539 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
540 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200541 &spec->ext_channel_count);
542 if (err >= 0 && !spec->const_channel_count) {
543 spec->multiout.max_channels = spec->ext_channel_count;
544 if (spec->need_dac_fix)
545 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
546 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200547 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548}
549
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100551 * Control the mode of pin widget settings via the mixer. "pc" is used
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300552 * instead of "%" to avoid consequences of accidentally treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100553 * being part of a format specifier. Maximum allowed length of a value is
554 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100555 *
556 * Note: some retasking pin complexes seem to ignore requests for input
557 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
558 * are requested. Therefore order this list so that this behaviour will not
559 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200560 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
561 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200562 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100563static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100564 "Mic 50pc bias", "Mic 80pc bias",
565 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100566};
567static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100568 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100569};
570/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200571 * in the pin being assumed to be exclusively an input or an output pin. In
572 * addition, "input" pins may or may not process the mic bias option
573 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
574 * accept requests for bias as of chip versions up to March 2006) and/or
575 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100576 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200577#define ALC_PIN_DIR_IN 0x00
578#define ALC_PIN_DIR_OUT 0x01
579#define ALC_PIN_DIR_INOUT 0x02
580#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
581#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100582
Kailang Yangea1fb292008-08-26 12:58:38 +0200583/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100584 * For each direction the minimum and maximum values are given.
585 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200586static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100587 { 0, 2 }, /* ALC_PIN_DIR_IN */
588 { 3, 4 }, /* ALC_PIN_DIR_OUT */
589 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200590 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
591 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100592};
593#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
594#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
595#define alc_pin_mode_n_items(_dir) \
596 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
597
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200598static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
599 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200600{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100601 unsigned int item_num = uinfo->value.enumerated.item;
602 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
603
604 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200605 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100606 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
607
608 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
609 item_num = alc_pin_mode_min(dir);
610 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200611 return 0;
612}
613
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200614static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
615 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200616{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100617 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200618 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
619 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100620 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200621 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200622 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
623 AC_VERB_GET_PIN_WIDGET_CONTROL,
624 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200625
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100626 /* Find enumerated value for current pinctl setting */
627 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200628 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100629 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200630 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100631 return 0;
632}
633
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200634static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
635 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100636{
637 signed int change;
638 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
639 hda_nid_t nid = kcontrol->private_value & 0xffff;
640 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
641 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200642 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
643 AC_VERB_GET_PIN_WIDGET_CONTROL,
644 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100645
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200646 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100647 val = alc_pin_mode_min(dir);
648
649 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100650 if (change) {
651 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200652 snd_hda_codec_write_cache(codec, nid, 0,
653 AC_VERB_SET_PIN_WIDGET_CONTROL,
654 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100655
Kailang Yangea1fb292008-08-26 12:58:38 +0200656 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100657 * for the requested pin mode. Enum values of 2 or less are
658 * input modes.
659 *
660 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200661 * reduces noise slightly (particularly on input) so we'll
662 * do it. However, having both input and output buffers
663 * enabled simultaneously doesn't seem to be problematic if
664 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100665 */
666 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200667 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
668 HDA_AMP_MUTE, HDA_AMP_MUTE);
669 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
670 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100671 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200672 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
673 HDA_AMP_MUTE, HDA_AMP_MUTE);
674 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
675 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100676 }
677 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200678 return change;
679}
680
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100681#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200682 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100683 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100684 .info = alc_pin_mode_info, \
685 .get = alc_pin_mode_get, \
686 .put = alc_pin_mode_put, \
687 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100688
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100689/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
690 * together using a mask with more than one bit set. This control is
691 * currently used only by the ALC260 test model. At this stage they are not
692 * needed for any "production" models.
693 */
694#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200695#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200696
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200697static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
698 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100699{
700 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
701 hda_nid_t nid = kcontrol->private_value & 0xffff;
702 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
703 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200704 unsigned int val = snd_hda_codec_read(codec, nid, 0,
705 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100706
707 *valp = (val & mask) != 0;
708 return 0;
709}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200710static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
711 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100712{
713 signed int change;
714 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
715 hda_nid_t nid = kcontrol->private_value & 0xffff;
716 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
717 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200718 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
719 AC_VERB_GET_GPIO_DATA,
720 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100721
722 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200723 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
724 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100725 gpio_data &= ~mask;
726 else
727 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200728 snd_hda_codec_write_cache(codec, nid, 0,
729 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100730
731 return change;
732}
733#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
734 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100735 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100736 .info = alc_gpio_data_info, \
737 .get = alc_gpio_data_get, \
738 .put = alc_gpio_data_put, \
739 .private_value = nid | (mask<<16) }
740#endif /* CONFIG_SND_DEBUG */
741
Jonathan Woithe92621f12006-02-28 11:47:47 +0100742/* A switch control to allow the enabling of the digital IO pins on the
743 * ALC260. This is incredibly simplistic; the intention of this control is
744 * to provide something in the test model allowing digital outputs to be
745 * identified if present. If models are found which can utilise these
746 * outputs a more complete mixer control can be devised for those models if
747 * necessary.
748 */
749#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200750#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200751
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200752static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
753 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100754{
755 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
756 hda_nid_t nid = kcontrol->private_value & 0xffff;
757 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
758 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200759 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100760 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100761
762 *valp = (val & mask) != 0;
763 return 0;
764}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200765static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
766 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100767{
768 signed int change;
769 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
770 hda_nid_t nid = kcontrol->private_value & 0xffff;
771 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
772 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200773 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100774 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200775 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100776
777 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200778 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100779 if (val==0)
780 ctrl_data &= ~mask;
781 else
782 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200783 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
784 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100785
786 return change;
787}
788#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
789 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100790 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100791 .info = alc_spdif_ctrl_info, \
792 .get = alc_spdif_ctrl_get, \
793 .put = alc_spdif_ctrl_put, \
794 .private_value = nid | (mask<<16) }
795#endif /* CONFIG_SND_DEBUG */
796
Jonathan Woithef8225f62008-01-08 12:16:54 +0100797/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
798 * Again, this is only used in the ALC26x test models to help identify when
799 * the EAPD line must be asserted for features to work.
800 */
801#ifdef CONFIG_SND_DEBUG
802#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
803
804static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
805 struct snd_ctl_elem_value *ucontrol)
806{
807 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
808 hda_nid_t nid = kcontrol->private_value & 0xffff;
809 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
810 long *valp = ucontrol->value.integer.value;
811 unsigned int val = snd_hda_codec_read(codec, nid, 0,
812 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
813
814 *valp = (val & mask) != 0;
815 return 0;
816}
817
818static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
819 struct snd_ctl_elem_value *ucontrol)
820{
821 int change;
822 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
823 hda_nid_t nid = kcontrol->private_value & 0xffff;
824 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
825 long val = *ucontrol->value.integer.value;
826 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
827 AC_VERB_GET_EAPD_BTLENABLE,
828 0x00);
829
830 /* Set/unset the masked control bit(s) as needed */
831 change = (!val ? 0 : mask) != (ctrl_data & mask);
832 if (!val)
833 ctrl_data &= ~mask;
834 else
835 ctrl_data |= mask;
836 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
837 ctrl_data);
838
839 return change;
840}
841
842#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
843 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100844 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100845 .info = alc_eapd_ctrl_info, \
846 .get = alc_eapd_ctrl_get, \
847 .put = alc_eapd_ctrl_put, \
848 .private_value = nid | (mask<<16) }
849#endif /* CONFIG_SND_DEBUG */
850
Kailang Yangdf694da2005-12-05 19:42:22 +0100851/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100852 * set up the input pin config (depending on the given auto-pin type)
853 */
854static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
855 int auto_pin_type)
856{
857 unsigned int val = PIN_IN;
858
Takashi Iwai86e29592010-09-09 14:50:17 +0200859 if (auto_pin_type == AUTO_PIN_MIC) {
Takashi Iwai23f0c042009-02-26 13:03:58 +0100860 unsigned int pincap;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200861 unsigned int oldval;
862 oldval = snd_hda_codec_read(codec, nid, 0,
863 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Takashi Iwai1327a322009-03-23 13:07:47 +0100864 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100865 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200866 /* if the default pin setup is vref50, we give it priority */
867 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
Takashi Iwai23f0c042009-02-26 13:03:58 +0100868 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200869 else if (pincap & AC_PINCAP_VREF_50)
870 val = PIN_VREF50;
871 else if (pincap & AC_PINCAP_VREF_100)
872 val = PIN_VREF100;
873 else if (pincap & AC_PINCAP_VREF_GRD)
874 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100875 }
876 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
877}
878
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200879static void alc_fixup_autocfg_pin_nums(struct hda_codec *codec)
880{
881 struct alc_spec *spec = codec->spec;
882 struct auto_pin_cfg *cfg = &spec->autocfg;
883
884 if (!cfg->line_outs) {
885 while (cfg->line_outs < AUTO_CFG_MAX_OUTS &&
886 cfg->line_out_pins[cfg->line_outs])
887 cfg->line_outs++;
888 }
889 if (!cfg->speaker_outs) {
890 while (cfg->speaker_outs < AUTO_CFG_MAX_OUTS &&
891 cfg->speaker_pins[cfg->speaker_outs])
892 cfg->speaker_outs++;
893 }
894 if (!cfg->hp_outs) {
895 while (cfg->hp_outs < AUTO_CFG_MAX_OUTS &&
896 cfg->hp_pins[cfg->hp_outs])
897 cfg->hp_outs++;
898 }
899}
900
Takashi Iwai23f0c042009-02-26 13:03:58 +0100901/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100902 */
903static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
904{
905 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
906 return;
907 spec->mixers[spec->num_mixers++] = mix;
908}
909
910static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
911{
912 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
913 return;
914 spec->init_verbs[spec->num_init_verbs++] = verb;
915}
916
917/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100918 * set up from the preset table
919 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200920static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200921 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100922{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200923 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100924 int i;
925
926 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100927 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100928 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200929 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
930 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100931 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200932
Kailang Yangdf694da2005-12-05 19:42:22 +0100933 spec->channel_mode = preset->channel_mode;
934 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200935 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200936 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100937
Hector Martin3b315d72009-06-02 10:54:19 +0200938 if (preset->const_channel_count)
939 spec->multiout.max_channels = preset->const_channel_count;
940 else
941 spec->multiout.max_channels = spec->channel_mode[0].channels;
942 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100943
944 spec->multiout.num_dacs = preset->num_dacs;
945 spec->multiout.dac_nids = preset->dac_nids;
946 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800947 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100948 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200949
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200950 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200951 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200952 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100953 spec->input_mux = preset->input_mux;
954
955 spec->num_adc_nids = preset->num_adc_nids;
956 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100957 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100958 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100959
960 spec->unsol_event = preset->unsol_event;
961 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200962#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100963 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200964 spec->loopback.amplist = preset->loopbacks;
965#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200966
967 if (preset->setup)
968 preset->setup(codec);
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200969
970 alc_fixup_autocfg_pin_nums(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100971}
972
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200973/* Enable GPIO mask and set output */
974static struct hda_verb alc_gpio1_init_verbs[] = {
975 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
976 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
977 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
978 { }
979};
980
981static struct hda_verb alc_gpio2_init_verbs[] = {
982 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
983 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
984 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
985 { }
986};
987
Kailang Yangbdd148a2007-05-08 15:19:08 +0200988static struct hda_verb alc_gpio3_init_verbs[] = {
989 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
990 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
991 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
992 { }
993};
994
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200995/*
996 * Fix hardware PLL issue
997 * On some codecs, the analog PLL gating control must be off while
998 * the default value is 1.
999 */
1000static void alc_fix_pll(struct hda_codec *codec)
1001{
1002 struct alc_spec *spec = codec->spec;
1003 unsigned int val;
1004
1005 if (!spec->pll_nid)
1006 return;
1007 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1008 spec->pll_coef_idx);
1009 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
1010 AC_VERB_GET_PROC_COEF, 0);
1011 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1012 spec->pll_coef_idx);
1013 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
1014 val & ~(1 << spec->pll_coef_bit));
1015}
1016
1017static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
1018 unsigned int coef_idx, unsigned int coef_bit)
1019{
1020 struct alc_spec *spec = codec->spec;
1021 spec->pll_nid = nid;
1022 spec->pll_coef_idx = coef_idx;
1023 spec->pll_coef_bit = coef_bit;
1024 alc_fix_pll(codec);
1025}
1026
Kailang Yang9ad0e492010-09-14 23:22:00 +02001027static int alc_init_jacks(struct hda_codec *codec)
1028{
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001029#ifdef CONFIG_SND_HDA_INPUT_JACK
Kailang Yang9ad0e492010-09-14 23:22:00 +02001030 struct alc_spec *spec = codec->spec;
1031 int err;
1032 unsigned int hp_nid = spec->autocfg.hp_pins[0];
1033 unsigned int mic_nid = spec->ext_mic.pin;
1034
Takashi Iwai265a0242010-09-21 11:26:21 +02001035 if (hp_nid) {
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001036 err = snd_hda_input_jack_add(codec, hp_nid,
1037 SND_JACK_HEADPHONE, NULL);
Takashi Iwai265a0242010-09-21 11:26:21 +02001038 if (err < 0)
1039 return err;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001040 snd_hda_input_jack_report(codec, hp_nid);
Takashi Iwai265a0242010-09-21 11:26:21 +02001041 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001042
Takashi Iwai265a0242010-09-21 11:26:21 +02001043 if (mic_nid) {
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001044 err = snd_hda_input_jack_add(codec, mic_nid,
1045 SND_JACK_MICROPHONE, NULL);
Takashi Iwai265a0242010-09-21 11:26:21 +02001046 if (err < 0)
1047 return err;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001048 snd_hda_input_jack_report(codec, mic_nid);
Takashi Iwai265a0242010-09-21 11:26:21 +02001049 }
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001050#endif /* CONFIG_SND_HDA_INPUT_JACK */
Kailang Yang9ad0e492010-09-14 23:22:00 +02001051 return 0;
1052}
Kailang Yang9ad0e492010-09-14 23:22:00 +02001053
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001054static void alc_automute_speaker(struct hda_codec *codec, int pinctl)
Kailang Yangc9b58002007-10-16 14:30:01 +02001055{
1056 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001057 unsigned int mute;
1058 hda_nid_t nid;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001059 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +02001060
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001061 spec->jack_present = 0;
1062 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1063 nid = spec->autocfg.hp_pins[i];
1064 if (!nid)
1065 break;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001066 snd_hda_input_jack_report(codec, nid);
David Henningssonf0ce2792011-02-28 15:58:07 +01001067 spec->jack_present |= snd_hda_jack_detect(codec, nid);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001068 }
1069
1070 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1071 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001072 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1073 nid = spec->autocfg.speaker_pins[i];
1074 if (!nid)
1075 break;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001076 if (pinctl) {
1077 snd_hda_codec_write(codec, nid, 0,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001078 AC_VERB_SET_PIN_WIDGET_CONTROL,
1079 spec->jack_present ? 0 : PIN_OUT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001080 } else {
1081 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1082 HDA_AMP_MUTE, mute);
1083 }
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001084 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001085}
1086
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001087static void alc_automute_pin(struct hda_codec *codec)
1088{
1089 alc_automute_speaker(codec, 1);
1090}
1091
Takashi Iwai6c819492009-08-10 18:47:44 +02001092static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1093 hda_nid_t nid)
1094{
1095 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1096 int i, nums;
1097
1098 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1099 for (i = 0; i < nums; i++)
1100 if (conn[i] == nid)
1101 return i;
1102 return -1;
1103}
1104
Takashi Iwai840b64c2010-07-13 22:49:01 +02001105/* switch the current ADC according to the jack state */
1106static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1107{
1108 struct alc_spec *spec = codec->spec;
1109 unsigned int present;
1110 hda_nid_t new_adc;
1111
1112 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1113 if (present)
1114 spec->cur_adc_idx = 1;
1115 else
1116 spec->cur_adc_idx = 0;
1117 new_adc = spec->adc_nids[spec->cur_adc_idx];
1118 if (spec->cur_adc && spec->cur_adc != new_adc) {
1119 /* stream is running, let's swap the current ADC */
Takashi Iwaif0cea792010-08-13 11:56:53 +02001120 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
Takashi Iwai840b64c2010-07-13 22:49:01 +02001121 spec->cur_adc = new_adc;
1122 snd_hda_codec_setup_stream(codec, new_adc,
1123 spec->cur_adc_stream_tag, 0,
1124 spec->cur_adc_format);
1125 }
1126}
1127
Kailang Yang7fb0d782008-10-15 11:12:35 +02001128static void alc_mic_automute(struct hda_codec *codec)
1129{
1130 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001131 struct alc_mic_route *dead, *alive;
1132 unsigned int present, type;
1133 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001134
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001135 if (!spec->auto_mic)
1136 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001137 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1138 return;
1139 if (snd_BUG_ON(!spec->adc_nids))
1140 return;
1141
Takashi Iwai840b64c2010-07-13 22:49:01 +02001142 if (spec->dual_adc_switch) {
1143 alc_dual_mic_adc_auto_switch(codec);
1144 return;
1145 }
1146
Takashi Iwai6c819492009-08-10 18:47:44 +02001147 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1148
Wu Fengguang864f92b2009-11-18 12:38:02 +08001149 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001150 if (present) {
1151 alive = &spec->ext_mic;
1152 dead = &spec->int_mic;
1153 } else {
1154 alive = &spec->int_mic;
1155 dead = &spec->ext_mic;
1156 }
1157
Takashi Iwai6c819492009-08-10 18:47:44 +02001158 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1159 if (type == AC_WID_AUD_MIX) {
1160 /* Matrix-mixer style (e.g. ALC882) */
1161 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1162 alive->mux_idx,
1163 HDA_AMP_MUTE, 0);
1164 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1165 dead->mux_idx,
1166 HDA_AMP_MUTE, HDA_AMP_MUTE);
1167 } else {
1168 /* MUX style (e.g. ALC880) */
1169 snd_hda_codec_write_cache(codec, cap_nid, 0,
1170 AC_VERB_SET_CONNECT_SEL,
1171 alive->mux_idx);
1172 }
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001173 snd_hda_input_jack_report(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001174
1175 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001176}
1177
Kailang Yangc9b58002007-10-16 14:30:01 +02001178/* unsolicited event for HP jack sensing */
1179static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1180{
1181 if (codec->vendor_id == 0x10ec0880)
1182 res >>= 28;
1183 else
1184 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001185 switch (res) {
1186 case ALC880_HP_EVENT:
1187 alc_automute_pin(codec);
1188 break;
1189 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001190 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001191 break;
1192 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001193}
1194
1195static void alc_inithook(struct hda_codec *codec)
1196{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001197 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001198 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001199}
1200
Kailang Yangf9423e72008-05-27 12:32:25 +02001201/* additional initialization for ALC888 variants */
1202static void alc888_coef_init(struct hda_codec *codec)
1203{
1204 unsigned int tmp;
1205
1206 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1207 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1208 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001209 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001210 /* alc888S-VC */
1211 snd_hda_codec_read(codec, 0x20, 0,
1212 AC_VERB_SET_PROC_COEF, 0x830);
1213 else
1214 /* alc888-VB */
1215 snd_hda_codec_read(codec, 0x20, 0,
1216 AC_VERB_SET_PROC_COEF, 0x3030);
1217}
1218
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001219static void alc889_coef_init(struct hda_codec *codec)
1220{
1221 unsigned int tmp;
1222
1223 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1224 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1225 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1226 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1227}
1228
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001229/* turn on/off EAPD control (only if available) */
1230static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1231{
1232 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1233 return;
1234 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1235 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1236 on ? 2 : 0);
1237}
1238
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001239static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001240{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001241 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001242
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001243 switch (type) {
1244 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001245 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1246 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001247 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001248 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1249 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001250 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001251 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1252 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001253 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001254 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001255 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001256 set_eapd(codec, 0x0f, 1);
1257 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001258 break;
1259 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001260 case 0x10ec0267:
1261 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001262 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001263 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001264 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001265 case 0x10ec0660:
1266 case 0x10ec0662:
1267 case 0x10ec0663:
Andres Mejia75eb1c32011-03-20 14:07:40 -04001268 case 0x10ec0665:
Kailang Yangc9b58002007-10-16 14:30:01 +02001269 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001270 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001271 set_eapd(codec, 0x14, 1);
1272 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001273 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001274 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001275 switch (codec->vendor_id) {
1276 case 0x10ec0260:
1277 snd_hda_codec_write(codec, 0x1a, 0,
1278 AC_VERB_SET_COEF_INDEX, 7);
1279 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1280 AC_VERB_GET_PROC_COEF, 0);
1281 snd_hda_codec_write(codec, 0x1a, 0,
1282 AC_VERB_SET_COEF_INDEX, 7);
1283 snd_hda_codec_write(codec, 0x1a, 0,
1284 AC_VERB_SET_PROC_COEF,
1285 tmp | 0x2010);
1286 break;
1287 case 0x10ec0262:
1288 case 0x10ec0880:
1289 case 0x10ec0882:
1290 case 0x10ec0883:
1291 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001292 case 0x10ec0887:
Takashi Iwai20b67dd2011-03-23 22:54:32 +01001293 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001294 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001295 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001296 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001297 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001298 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001299#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001300 case 0x10ec0267:
1301 case 0x10ec0268:
1302 snd_hda_codec_write(codec, 0x20, 0,
1303 AC_VERB_SET_COEF_INDEX, 7);
1304 tmp = snd_hda_codec_read(codec, 0x20, 0,
1305 AC_VERB_GET_PROC_COEF, 0);
1306 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001307 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001308 snd_hda_codec_write(codec, 0x20, 0,
1309 AC_VERB_SET_PROC_COEF,
1310 tmp | 0x3000);
1311 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001312#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001313 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001314 break;
1315 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001316}
Kailang Yangea1fb292008-08-26 12:58:38 +02001317
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001318static void alc_init_auto_hp(struct hda_codec *codec)
1319{
1320 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001321 struct auto_pin_cfg *cfg = &spec->autocfg;
1322 int i;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001323
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001324 if (!cfg->hp_pins[0]) {
1325 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001326 return;
1327 }
1328
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001329 if (!cfg->speaker_pins[0]) {
1330 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
1331 return;
1332 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1333 sizeof(cfg->speaker_pins));
1334 cfg->speaker_outs = cfg->line_outs;
1335 }
1336
1337 if (!cfg->hp_pins[0]) {
1338 memcpy(cfg->hp_pins, cfg->line_out_pins,
1339 sizeof(cfg->hp_pins));
1340 cfg->hp_outs = cfg->line_outs;
1341 }
1342
1343 for (i = 0; i < cfg->hp_outs; i++) {
1344 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1345 cfg->hp_pins[i]);
1346 snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0,
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001347 AC_VERB_SET_UNSOLICITED_ENABLE,
1348 AC_USRSP_EN | ALC880_HP_EVENT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001349 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001350 spec->unsol_event = alc_sku_unsol_event;
1351}
1352
Takashi Iwai6c819492009-08-10 18:47:44 +02001353static void alc_init_auto_mic(struct hda_codec *codec)
1354{
1355 struct alc_spec *spec = codec->spec;
1356 struct auto_pin_cfg *cfg = &spec->autocfg;
1357 hda_nid_t fixed, ext;
1358 int i;
1359
1360 /* there must be only two mic inputs exclusively */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001361 for (i = 0; i < cfg->num_inputs; i++)
Takashi Iwai86e29592010-09-09 14:50:17 +02001362 if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
Takashi Iwai6c819492009-08-10 18:47:44 +02001363 return;
1364
1365 fixed = ext = 0;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001366 for (i = 0; i < cfg->num_inputs; i++) {
1367 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai6c819492009-08-10 18:47:44 +02001368 unsigned int defcfg;
Takashi Iwai6c819492009-08-10 18:47:44 +02001369 defcfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001370 switch (snd_hda_get_input_pin_attr(defcfg)) {
1371 case INPUT_PIN_ATTR_INT:
Takashi Iwai6c819492009-08-10 18:47:44 +02001372 if (fixed)
1373 return; /* already occupied */
1374 fixed = nid;
1375 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001376 case INPUT_PIN_ATTR_UNUSED:
1377 return; /* invalid entry */
1378 default:
Takashi Iwai6c819492009-08-10 18:47:44 +02001379 if (ext)
1380 return; /* already occupied */
1381 ext = nid;
1382 break;
Takashi Iwai6c819492009-08-10 18:47:44 +02001383 }
1384 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001385 if (!ext || !fixed)
1386 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001387 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1388 return; /* no unsol support */
1389 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1390 ext, fixed);
1391 spec->ext_mic.pin = ext;
1392 spec->int_mic.pin = fixed;
1393 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1394 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1395 spec->auto_mic = 1;
1396 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1397 AC_VERB_SET_UNSOLICITED_ENABLE,
1398 AC_USRSP_EN | ALC880_MIC_EVENT);
1399 spec->unsol_event = alc_sku_unsol_event;
1400}
1401
David Henningsson90622912010-10-14 14:50:18 +02001402/* Could be any non-zero and even value. When used as fixup, tells
1403 * the driver to ignore any present sku defines.
1404 */
1405#define ALC_FIXUP_SKU_IGNORE (2)
1406
Kailang Yangda00c242010-03-19 11:23:45 +01001407static int alc_auto_parse_customize_define(struct hda_codec *codec)
1408{
1409 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001410 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001411 struct alc_spec *spec = codec->spec;
1412
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001413 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1414
David Henningsson90622912010-10-14 14:50:18 +02001415 if (spec->cdefine.fixup) {
1416 ass = spec->cdefine.sku_cfg;
1417 if (ass == ALC_FIXUP_SKU_IGNORE)
1418 return -1;
1419 goto do_sku;
1420 }
1421
Kailang Yangda00c242010-03-19 11:23:45 +01001422 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001423 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +01001424 goto do_sku;
1425
1426 nid = 0x1d;
1427 if (codec->vendor_id == 0x10ec0260)
1428 nid = 0x17;
1429 ass = snd_hda_codec_get_pincfg(codec, nid);
1430
1431 if (!(ass & 1)) {
1432 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1433 codec->chip_name, ass);
1434 return -1;
1435 }
1436
1437 /* check sum */
1438 tmp = 0;
1439 for (i = 1; i < 16; i++) {
1440 if ((ass >> i) & 1)
1441 tmp++;
1442 }
1443 if (((ass >> 16) & 0xf) != tmp)
1444 return -1;
1445
1446 spec->cdefine.port_connectivity = ass >> 30;
1447 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1448 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1449 spec->cdefine.customization = ass >> 8;
1450do_sku:
1451 spec->cdefine.sku_cfg = ass;
1452 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1453 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1454 spec->cdefine.swap = (ass & 0x2) >> 1;
1455 spec->cdefine.override = ass & 0x1;
1456
1457 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1458 nid, spec->cdefine.sku_cfg);
1459 snd_printd("SKU: port_connectivity=0x%x\n",
1460 spec->cdefine.port_connectivity);
1461 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1462 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1463 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1464 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1465 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1466 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1467 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1468
1469 return 0;
1470}
1471
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001472/* check subsystem ID and set up device-specific initialization;
1473 * return 1 if initialized, 0 if invalid SSID
1474 */
1475/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1476 * 31 ~ 16 : Manufacture ID
1477 * 15 ~ 8 : SKU ID
1478 * 7 ~ 0 : Assembly ID
1479 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1480 */
1481static int alc_subsystem_id(struct hda_codec *codec,
1482 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001483 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001484{
1485 unsigned int ass, tmp, i;
1486 unsigned nid;
1487 struct alc_spec *spec = codec->spec;
1488
David Henningsson90622912010-10-14 14:50:18 +02001489 if (spec->cdefine.fixup) {
1490 ass = spec->cdefine.sku_cfg;
1491 if (ass == ALC_FIXUP_SKU_IGNORE)
1492 return 0;
1493 goto do_sku;
1494 }
1495
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001496 ass = codec->subsystem_id & 0xffff;
1497 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1498 goto do_sku;
1499
1500 /* invalid SSID, check the special NID pin defcfg instead */
1501 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001502 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001503 * 29~21 : reserve
1504 * 20 : PCBEEP input
1505 * 19~16 : Check sum (15:1)
1506 * 15~1 : Custom
1507 * 0 : override
1508 */
1509 nid = 0x1d;
1510 if (codec->vendor_id == 0x10ec0260)
1511 nid = 0x17;
1512 ass = snd_hda_codec_get_pincfg(codec, nid);
1513 snd_printd("realtek: No valid SSID, "
1514 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001515 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001516 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001517 return 0;
1518 if ((ass >> 30) != 1) /* no physical connection */
1519 return 0;
1520
1521 /* check sum */
1522 tmp = 0;
1523 for (i = 1; i < 16; i++) {
1524 if ((ass >> i) & 1)
1525 tmp++;
1526 }
1527 if (((ass >> 16) & 0xf) != tmp)
1528 return 0;
1529do_sku:
1530 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1531 ass & 0xffff, codec->vendor_id);
1532 /*
1533 * 0 : override
1534 * 1 : Swap Jack
1535 * 2 : 0 --> Desktop, 1 --> Laptop
1536 * 3~5 : External Amplifier control
1537 * 7~6 : Reserved
1538 */
1539 tmp = (ass & 0x38) >> 3; /* external Amp control */
1540 switch (tmp) {
1541 case 1:
1542 spec->init_amp = ALC_INIT_GPIO1;
1543 break;
1544 case 3:
1545 spec->init_amp = ALC_INIT_GPIO2;
1546 break;
1547 case 7:
1548 spec->init_amp = ALC_INIT_GPIO3;
1549 break;
1550 case 5:
Takashi Iwai5a8cfb42010-11-26 17:11:18 +01001551 default:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001552 spec->init_amp = ALC_INIT_DEFAULT;
1553 break;
1554 }
1555
1556 /* is laptop or Desktop and enable the function "Mute internal speaker
1557 * when the external headphone out jack is plugged"
1558 */
1559 if (!(ass & 0x8000))
1560 return 1;
1561 /*
1562 * 10~8 : Jack location
1563 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1564 * 14~13: Resvered
1565 * 15 : 1 --> enable the function "Mute internal speaker
1566 * when the external headphone out jack is plugged"
1567 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001568 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001569 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001570 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1571 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001572 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001573 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001574 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001575 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001576 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001577 else if (tmp == 3)
1578 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001579 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001580 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001581 for (i = 0; i < spec->autocfg.line_outs; i++)
1582 if (spec->autocfg.line_out_pins[i] == nid)
1583 return 1;
1584 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001585 }
1586
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001587 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001588 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001589 return 1;
1590}
Kailang Yangea1fb292008-08-26 12:58:38 +02001591
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001592static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001593 hda_nid_t porta, hda_nid_t porte,
1594 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001595{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001596 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001597 struct alc_spec *spec = codec->spec;
1598 snd_printd("realtek: "
1599 "Enable default setup for auto mode as fallback\n");
1600 spec->init_amp = ALC_INIT_DEFAULT;
1601 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001602 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001603 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001604}
1605
Takashi Iwai41e41f12005-06-08 14:48:49 +02001606/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001607 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001608 */
1609
1610struct alc_pincfg {
1611 hda_nid_t nid;
1612 u32 val;
1613};
1614
Todd Broche1eb5f12010-12-06 11:19:51 -08001615struct alc_model_fixup {
1616 const int id;
1617 const char *name;
1618};
1619
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001620struct alc_fixup {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001621 int type;
Takashi Iwai361fe6e2011-01-14 09:55:32 +01001622 bool chained;
1623 int chain_id;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001624 union {
1625 unsigned int sku;
1626 const struct alc_pincfg *pins;
1627 const struct hda_verb *verbs;
1628 void (*func)(struct hda_codec *codec,
1629 const struct alc_fixup *fix,
1630 int action);
1631 } v;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001632};
1633
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001634enum {
1635 ALC_FIXUP_INVALID,
1636 ALC_FIXUP_SKU,
1637 ALC_FIXUP_PINS,
1638 ALC_FIXUP_VERBS,
1639 ALC_FIXUP_FUNC,
1640};
Takashi Iwaif95474e2007-07-10 00:47:43 +02001641
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001642enum {
1643 ALC_FIXUP_ACT_PRE_PROBE,
1644 ALC_FIXUP_ACT_PROBE,
Takashi Iwai58701122011-01-13 15:41:45 +01001645 ALC_FIXUP_ACT_INIT,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001646};
1647
1648static void alc_apply_fixup(struct hda_codec *codec, int action)
1649{
1650 struct alc_spec *spec = codec->spec;
1651 int id = spec->fixup_id;
Takashi Iwaiaa1d0c52011-01-19 17:27:58 +01001652#ifdef CONFIG_SND_DEBUG_VERBOSE
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001653 const char *modelname = spec->fixup_name;
Takashi Iwaiaa1d0c52011-01-19 17:27:58 +01001654#endif
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001655 int depth = 0;
1656
1657 if (!spec->fixup_list)
1658 return;
1659
1660 while (id >= 0) {
1661 const struct alc_fixup *fix = spec->fixup_list + id;
1662 const struct alc_pincfg *cfg;
1663
1664 switch (fix->type) {
1665 case ALC_FIXUP_SKU:
1666 if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku)
1667 break;;
1668 snd_printdd(KERN_INFO "hda_codec: %s: "
1669 "Apply sku override for %s\n",
1670 codec->chip_name, modelname);
1671 spec->cdefine.sku_cfg = fix->v.sku;
1672 spec->cdefine.fixup = 1;
1673 break;
1674 case ALC_FIXUP_PINS:
1675 cfg = fix->v.pins;
1676 if (action != ALC_FIXUP_ACT_PRE_PROBE || !cfg)
1677 break;
1678 snd_printdd(KERN_INFO "hda_codec: %s: "
1679 "Apply pincfg for %s\n",
1680 codec->chip_name, modelname);
1681 for (; cfg->nid; cfg++)
1682 snd_hda_codec_set_pincfg(codec, cfg->nid,
1683 cfg->val);
1684 break;
1685 case ALC_FIXUP_VERBS:
1686 if (action != ALC_FIXUP_ACT_PROBE || !fix->v.verbs)
1687 break;
1688 snd_printdd(KERN_INFO "hda_codec: %s: "
1689 "Apply fix-verbs for %s\n",
1690 codec->chip_name, modelname);
1691 add_verb(codec->spec, fix->v.verbs);
1692 break;
1693 case ALC_FIXUP_FUNC:
1694 if (!fix->v.func)
1695 break;
1696 snd_printdd(KERN_INFO "hda_codec: %s: "
1697 "Apply fix-func for %s\n",
1698 codec->chip_name, modelname);
1699 fix->v.func(codec, fix, action);
1700 break;
1701 default:
1702 snd_printk(KERN_ERR "hda_codec: %s: "
1703 "Invalid fixup type %d\n",
1704 codec->chip_name, fix->type);
1705 break;
1706 }
1707 if (!fix[id].chained)
1708 break;
1709 if (++depth > 10)
1710 break;
1711 id = fix[id].chain_id;
Takashi Iwai9d578832010-11-22 13:29:19 +01001712 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001713}
1714
Todd Broche1eb5f12010-12-06 11:19:51 -08001715static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001716 const struct alc_model_fixup *models,
1717 const struct snd_pci_quirk *quirk,
1718 const struct alc_fixup *fixlist)
Todd Broche1eb5f12010-12-06 11:19:51 -08001719{
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001720 struct alc_spec *spec = codec->spec;
1721 int id = -1;
1722 const char *name = NULL;
Todd Broche1eb5f12010-12-06 11:19:51 -08001723
Todd Broche1eb5f12010-12-06 11:19:51 -08001724 if (codec->modelname && models) {
1725 while (models->name) {
1726 if (!strcmp(codec->modelname, models->name)) {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001727 id = models->id;
1728 name = models->name;
Todd Broche1eb5f12010-12-06 11:19:51 -08001729 break;
1730 }
1731 models++;
1732 }
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001733 }
1734 if (id < 0) {
1735 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1736 if (quirk) {
1737 id = quirk->value;
1738#ifdef CONFIG_SND_DEBUG_VERBOSE
1739 name = quirk->name;
1740#endif
1741 }
1742 }
1743
1744 spec->fixup_id = id;
1745 if (id >= 0) {
1746 spec->fixup_list = fixlist;
1747 spec->fixup_name = name;
Todd Broche1eb5f12010-12-06 11:19:51 -08001748 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001749}
1750
Kailang Yang274693f2009-12-03 10:07:50 +01001751static int alc_read_coef_idx(struct hda_codec *codec,
1752 unsigned int coef_idx)
1753{
1754 unsigned int val;
1755 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1756 coef_idx);
1757 val = snd_hda_codec_read(codec, 0x20, 0,
1758 AC_VERB_GET_PROC_COEF, 0);
1759 return val;
1760}
1761
Kailang Yang977ddd62010-09-15 10:02:29 +02001762static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1763 unsigned int coef_val)
1764{
1765 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1766 coef_idx);
1767 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1768 coef_val);
1769}
1770
Takashi Iwai757899a2010-07-30 10:48:14 +02001771/* set right pin controls for digital I/O */
1772static void alc_auto_init_digital(struct hda_codec *codec)
1773{
1774 struct alc_spec *spec = codec->spec;
1775 int i;
1776 hda_nid_t pin;
1777
1778 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1779 pin = spec->autocfg.dig_out_pins[i];
1780 if (pin) {
1781 snd_hda_codec_write(codec, pin, 0,
1782 AC_VERB_SET_PIN_WIDGET_CONTROL,
1783 PIN_OUT);
1784 }
1785 }
1786 pin = spec->autocfg.dig_in_pin;
1787 if (pin)
1788 snd_hda_codec_write(codec, pin, 0,
1789 AC_VERB_SET_PIN_WIDGET_CONTROL,
1790 PIN_IN);
1791}
1792
1793/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1794static void alc_auto_parse_digital(struct hda_codec *codec)
1795{
1796 struct alc_spec *spec = codec->spec;
1797 int i, err;
1798 hda_nid_t dig_nid;
1799
1800 /* support multiple SPDIFs; the secondary is set up as a slave */
1801 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1802 err = snd_hda_get_connections(codec,
1803 spec->autocfg.dig_out_pins[i],
1804 &dig_nid, 1);
1805 if (err < 0)
1806 continue;
1807 if (!i) {
1808 spec->multiout.dig_out_nid = dig_nid;
1809 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1810 } else {
1811 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1812 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1813 break;
1814 spec->slave_dig_outs[i - 1] = dig_nid;
1815 }
1816 }
1817
1818 if (spec->autocfg.dig_in_pin) {
Takashi Iwai01fdf182010-09-24 09:09:42 +02001819 dig_nid = codec->start_nid;
1820 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
1821 unsigned int wcaps = get_wcaps(codec, dig_nid);
1822 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
1823 continue;
1824 if (!(wcaps & AC_WCAP_DIGITAL))
1825 continue;
1826 if (!(wcaps & AC_WCAP_CONN_LIST))
1827 continue;
1828 err = get_connection_index(codec, dig_nid,
1829 spec->autocfg.dig_in_pin);
1830 if (err >= 0) {
1831 spec->dig_in_nid = dig_nid;
1832 break;
1833 }
1834 }
Takashi Iwai757899a2010-07-30 10:48:14 +02001835 }
1836}
1837
Takashi Iwaif95474e2007-07-10 00:47:43 +02001838/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001839 * ALC888
1840 */
1841
1842/*
1843 * 2ch mode
1844 */
1845static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1846/* Mic-in jack as mic in */
1847 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1848 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1849/* Line-in jack as Line in */
1850 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1851 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1852/* Line-Out as Front */
1853 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1854 { } /* end */
1855};
1856
1857/*
1858 * 4ch mode
1859 */
1860static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1861/* Mic-in jack as mic in */
1862 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1863 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1864/* Line-in jack as Surround */
1865 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1866 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1867/* Line-Out as Front */
1868 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1869 { } /* end */
1870};
1871
1872/*
1873 * 6ch mode
1874 */
1875static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1876/* Mic-in jack as CLFE */
1877 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1878 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1879/* Line-in jack as Surround */
1880 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1881 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1882/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1883 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1884 { } /* end */
1885};
1886
1887/*
1888 * 8ch mode
1889 */
1890static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1891/* Mic-in jack as CLFE */
1892 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1893 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1894/* Line-in jack as Surround */
1895 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1896 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1897/* Line-Out as Side */
1898 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1899 { } /* end */
1900};
1901
1902static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1903 { 2, alc888_4ST_ch2_intel_init },
1904 { 4, alc888_4ST_ch4_intel_init },
1905 { 6, alc888_4ST_ch6_intel_init },
1906 { 8, alc888_4ST_ch8_intel_init },
1907};
1908
1909/*
1910 * ALC888 Fujitsu Siemens Amillo xa3530
1911 */
1912
1913static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1914/* Front Mic: set to PIN_IN (empty by default) */
1915 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1916/* Connect Internal HP to Front */
1917 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1918 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1919 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1920/* Connect Bass HP to Front */
1921 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1922 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1923 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1924/* Connect Line-Out side jack (SPDIF) to Side */
1925 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1926 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1927 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1928/* Connect Mic jack to CLFE */
1929 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1930 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1931 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1932/* Connect Line-in jack to Surround */
1933 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1934 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1935 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1936/* Connect HP out jack to Front */
1937 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1938 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1939 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1940/* Enable unsolicited event for HP jack and Line-out jack */
1941 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1942 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1943 {}
1944};
1945
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001946static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001947{
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001948 alc_automute_speaker(codec, 0);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001949}
1950
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001951static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1952 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001953{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001954 if (codec->vendor_id == 0x10ec0880)
1955 res >>= 28;
1956 else
1957 res >>= 26;
1958 if (res == ALC880_HP_EVENT)
1959 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001960}
1961
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001962static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001963{
1964 struct alc_spec *spec = codec->spec;
1965
1966 spec->autocfg.hp_pins[0] = 0x15;
1967 spec->autocfg.speaker_pins[0] = 0x14;
1968 spec->autocfg.speaker_pins[1] = 0x16;
1969 spec->autocfg.speaker_pins[2] = 0x17;
1970 spec->autocfg.speaker_pins[3] = 0x19;
1971 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001972}
1973
1974static void alc889_intel_init_hook(struct hda_codec *codec)
1975{
1976 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001977 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001978}
1979
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001980static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001981{
1982 struct alc_spec *spec = codec->spec;
1983
1984 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1985 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1986 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1987 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001988}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001989
1990/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001991 * ALC888 Acer Aspire 4930G model
1992 */
1993
1994static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1995/* Front Mic: set to PIN_IN (empty by default) */
1996 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1997/* Unselect Front Mic by default in input mixer 3 */
1998 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001999/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002000 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2001/* Connect Internal HP to front */
2002 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2003 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2004 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2005/* Connect HP out to front */
2006 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2007 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2008 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie2e93292011-01-12 08:03:39 +01002009 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002010 { }
2011};
2012
Hector Martin3b315d72009-06-02 10:54:19 +02002013/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01002014 * ALC888 Acer Aspire 6530G model
2015 */
2016
2017static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01002018/* Route to built-in subwoofer as well as speakers */
2019 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2020 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2021 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2022 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002023/* Bias voltage on for external mic port */
2024 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02002025/* Front Mic: set to PIN_IN (empty by default) */
2026 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2027/* Unselect Front Mic by default in input mixer 3 */
2028 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002029/* Enable unsolicited event for HP jack */
2030 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2031/* Enable speaker output */
2032 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2033 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01002034 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002035/* Enable headphone output */
2036 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2037 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2038 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01002039 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002040 { }
2041};
2042
2043/*
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002044 *ALC888 Acer Aspire 7730G model
2045 */
2046
2047static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
2048/* Bias voltage on for external mic port */
2049 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
2050/* Front Mic: set to PIN_IN (empty by default) */
2051 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2052/* Unselect Front Mic by default in input mixer 3 */
2053 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2054/* Enable unsolicited event for HP jack */
2055 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2056/* Enable speaker output */
2057 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2058 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2059 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
2060/* Enable headphone output */
2061 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2062 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2063 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2064 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
2065/*Enable internal subwoofer */
2066 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2067 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2068 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
2069 {0x17, AC_VERB_SET_EAPD_BTLENABLE, 2},
2070 { }
2071};
2072
2073/*
Hector Martin018df412009-06-04 00:13:40 +02002074 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02002075 */
2076
Hector Martin018df412009-06-04 00:13:40 +02002077static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02002078/* Front Mic: set to PIN_IN (empty by default) */
2079 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2080/* Unselect Front Mic by default in input mixer 3 */
2081 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2082/* Enable unsolicited event for HP jack */
2083 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2084/* Connect Internal Front to Front */
2085 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2086 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2087 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2088/* Connect Internal Rear to Rear */
2089 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2090 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2091 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
2092/* Connect Internal CLFE to CLFE */
2093 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2094 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2095 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
2096/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02002097 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02002098 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2099 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2100/* Enable all DACs */
2101/* DAC DISABLE/MUTE 1? */
2102/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
2103 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
2104 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2105/* DAC DISABLE/MUTE 2? */
2106/* some bit here disables the other DACs. Init=0x4900 */
2107 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
2108 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02002109/* DMIC fix
2110 * This laptop has a stereo digital microphone. The mics are only 1cm apart
2111 * which makes the stereo useless. However, either the mic or the ALC889
2112 * makes the signal become a difference/sum signal instead of standard
2113 * stereo, which is annoying. So instead we flip this bit which makes the
2114 * codec replicate the sum signal to both channels, turning it into a
2115 * normal mono mic.
2116 */
2117/* DMIC_CONTROL? Init value = 0x0001 */
2118 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
2119 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02002120 { }
2121};
2122
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002123static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002124 /* Front mic only available on one ADC */
2125 {
2126 .num_items = 4,
2127 .items = {
2128 { "Mic", 0x0 },
2129 { "Line", 0x2 },
2130 { "CD", 0x4 },
2131 { "Front Mic", 0xb },
2132 },
2133 },
2134 {
2135 .num_items = 3,
2136 .items = {
2137 { "Mic", 0x0 },
2138 { "Line", 0x2 },
2139 { "CD", 0x4 },
2140 },
2141 }
2142};
2143
Tony Vroond2fd4b02009-06-21 00:40:10 +01002144static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2145 /* Interal mic only available on one ADC */
2146 {
Tony Vroon684a8842009-06-26 09:27:50 +01002147 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002148 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +01002149 { "Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002150 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002151 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002152 { "Input Mix", 0xa },
David Henningsson28c4edb2010-12-20 14:24:29 +01002153 { "Internal Mic", 0xb },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002154 },
2155 },
2156 {
Tony Vroon684a8842009-06-26 09:27:50 +01002157 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002158 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +01002159 { "Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002160 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002161 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002162 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002163 },
2164 }
2165};
2166
Hector Martin018df412009-06-04 00:13:40 +02002167static struct hda_input_mux alc889_capture_sources[3] = {
2168 /* Digital mic only available on first "ADC" */
2169 {
2170 .num_items = 5,
2171 .items = {
2172 { "Mic", 0x0 },
2173 { "Line", 0x2 },
2174 { "CD", 0x4 },
2175 { "Front Mic", 0xb },
2176 { "Input Mix", 0xa },
2177 },
2178 },
2179 {
2180 .num_items = 4,
2181 .items = {
2182 { "Mic", 0x0 },
2183 { "Line", 0x2 },
2184 { "CD", 0x4 },
2185 { "Input Mix", 0xa },
2186 },
2187 },
2188 {
2189 .num_items = 4,
2190 .items = {
2191 { "Mic", 0x0 },
2192 { "Line", 0x2 },
2193 { "CD", 0x4 },
2194 { "Input Mix", 0xa },
2195 },
2196 }
2197};
2198
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002199static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002200 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2201 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2202 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2203 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2204 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2205 HDA_OUTPUT),
2206 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2207 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2208 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2209 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2210 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2211 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2212 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2213 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2214 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2215 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01002216 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002217 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002218 { } /* end */
2219};
2220
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002221static struct snd_kcontrol_new alc888_acer_aspire_4930g_mixer[] = {
2222 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2223 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2224 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2225 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Łukasz Wojniłowicz786c51f2011-02-24 10:03:31 +01002226 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002227 HDA_OUTPUT),
Łukasz Wojniłowicz786c51f2011-02-24 10:03:31 +01002228 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2229 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2230 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2231 HDA_CODEC_VOLUME_MONO("Internal LFE Playback Volume", 0x0f, 1, 0x0, HDA_OUTPUT),
2232 HDA_BIND_MUTE_MONO("Internal LFE Playback Switch", 0x0f, 1, 2, HDA_INPUT),
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002233 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2234 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2235 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2236 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2237 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2238 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
2239 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2240 { } /* end */
2241};
2242
Hector Martin556eea92009-12-20 22:51:23 +01002243static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2244 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2245 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2246 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2247 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2248 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2249 HDA_OUTPUT),
2250 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2251 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2252 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2253 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2254 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2255 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01002256 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hector Martin556eea92009-12-20 22:51:23 +01002257 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2258 { } /* end */
2259};
2260
2261
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002262static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002263{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002264 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002265
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002266 spec->autocfg.hp_pins[0] = 0x15;
2267 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01002268 spec->autocfg.speaker_pins[1] = 0x16;
2269 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002270}
2271
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002272static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02002273{
2274 struct alc_spec *spec = codec->spec;
2275
2276 spec->autocfg.hp_pins[0] = 0x15;
2277 spec->autocfg.speaker_pins[0] = 0x14;
2278 spec->autocfg.speaker_pins[1] = 0x16;
2279 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02002280}
2281
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002282static void alc888_acer_aspire_7730g_setup(struct hda_codec *codec)
2283{
2284 struct alc_spec *spec = codec->spec;
2285
2286 spec->autocfg.hp_pins[0] = 0x15;
2287 spec->autocfg.speaker_pins[0] = 0x14;
2288 spec->autocfg.speaker_pins[1] = 0x16;
2289 spec->autocfg.speaker_pins[2] = 0x17;
2290}
2291
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002292static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02002293{
2294 struct alc_spec *spec = codec->spec;
2295
2296 spec->autocfg.hp_pins[0] = 0x15;
2297 spec->autocfg.speaker_pins[0] = 0x14;
2298 spec->autocfg.speaker_pins[1] = 0x16;
2299 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02002300}
2301
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002302/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002303 * ALC880 3-stack model
2304 *
2305 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002306 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2307 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07002308 */
2309
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002310static hda_nid_t alc880_dac_nids[4] = {
2311 /* front, rear, clfe, rear_surr */
2312 0x02, 0x05, 0x04, 0x03
2313};
2314
2315static hda_nid_t alc880_adc_nids[3] = {
2316 /* ADC0-2 */
2317 0x07, 0x08, 0x09,
2318};
2319
2320/* The datasheet says the node 0x07 is connected from inputs,
2321 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01002322 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07002323 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002324static hda_nid_t alc880_adc_nids_alt[2] = {
2325 /* ADC1-2 */
2326 0x08, 0x09,
2327};
2328
2329#define ALC880_DIGOUT_NID 0x06
2330#define ALC880_DIGIN_NID 0x0a
2331
2332static struct hda_input_mux alc880_capture_source = {
2333 .num_items = 4,
2334 .items = {
2335 { "Mic", 0x0 },
2336 { "Front Mic", 0x3 },
2337 { "Line", 0x2 },
2338 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002339 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002340};
2341
2342/* channel source setting (2/6 channel selection for 3-stack) */
2343/* 2ch mode */
2344static struct hda_verb alc880_threestack_ch2_init[] = {
2345 /* set line-in to input, mute it */
2346 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2347 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2348 /* set mic-in to input vref 80%, mute it */
2349 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2350 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002351 { } /* end */
2352};
2353
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002354/* 6ch mode */
2355static struct hda_verb alc880_threestack_ch6_init[] = {
2356 /* set line-in to output, unmute it */
2357 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2358 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2359 /* set mic-in to output, unmute it */
2360 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2361 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2362 { } /* end */
2363};
2364
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002365static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002366 { 2, alc880_threestack_ch2_init },
2367 { 6, alc880_threestack_ch6_init },
2368};
2369
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002370static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002371 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002372 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002373 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002374 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002375 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2376 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002377 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2378 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002379 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2380 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2381 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2382 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2383 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2384 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2385 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2386 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002387 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002388 {
2389 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2390 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002391 .info = alc_ch_mode_info,
2392 .get = alc_ch_mode_get,
2393 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002394 },
2395 { } /* end */
2396};
2397
2398/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002399static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2400 struct snd_ctl_elem_info *uinfo)
2401{
2402 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2403 struct alc_spec *spec = codec->spec;
2404 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002405
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002406 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002407 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2408 HDA_INPUT);
2409 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002410 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002411 return err;
2412}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002413
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002414static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2415 unsigned int size, unsigned int __user *tlv)
2416{
2417 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2418 struct alc_spec *spec = codec->spec;
2419 int err;
2420
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002421 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002422 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2423 HDA_INPUT);
2424 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002425 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002426 return err;
2427}
2428
2429typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2430 struct snd_ctl_elem_value *ucontrol);
2431
2432static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2433 struct snd_ctl_elem_value *ucontrol,
2434 getput_call_t func)
2435{
2436 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2437 struct alc_spec *spec = codec->spec;
2438 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2439 int err;
2440
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002441 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002442 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2443 3, 0, HDA_INPUT);
2444 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002445 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002446 return err;
2447}
2448
2449static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2450 struct snd_ctl_elem_value *ucontrol)
2451{
2452 return alc_cap_getput_caller(kcontrol, ucontrol,
2453 snd_hda_mixer_amp_volume_get);
2454}
2455
2456static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2457 struct snd_ctl_elem_value *ucontrol)
2458{
2459 return alc_cap_getput_caller(kcontrol, ucontrol,
2460 snd_hda_mixer_amp_volume_put);
2461}
2462
2463/* capture mixer elements */
2464#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2465
2466static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2467 struct snd_ctl_elem_value *ucontrol)
2468{
2469 return alc_cap_getput_caller(kcontrol, ucontrol,
2470 snd_hda_mixer_amp_switch_get);
2471}
2472
2473static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2474 struct snd_ctl_elem_value *ucontrol)
2475{
2476 return alc_cap_getput_caller(kcontrol, ucontrol,
2477 snd_hda_mixer_amp_switch_put);
2478}
2479
Takashi Iwaia23b6882009-03-23 15:21:36 +01002480#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002481 { \
2482 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2483 .name = "Capture Switch", \
2484 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2485 .count = num, \
2486 .info = alc_cap_sw_info, \
2487 .get = alc_cap_sw_get, \
2488 .put = alc_cap_sw_put, \
2489 }, \
2490 { \
2491 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2492 .name = "Capture Volume", \
2493 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2494 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2495 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2496 .count = num, \
2497 .info = alc_cap_vol_info, \
2498 .get = alc_cap_vol_get, \
2499 .put = alc_cap_vol_put, \
2500 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002501 }
2502
2503#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002504 { \
2505 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2506 /* .name = "Capture Source", */ \
2507 .name = "Input Source", \
2508 .count = num, \
2509 .info = alc_mux_enum_info, \
2510 .get = alc_mux_enum_get, \
2511 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002512 }
2513
2514#define DEFINE_CAPMIX(num) \
2515static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2516 _DEFINE_CAPMIX(num), \
2517 _DEFINE_CAPSRC(num), \
2518 { } /* end */ \
2519}
2520
2521#define DEFINE_CAPMIX_NOSRC(num) \
2522static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2523 _DEFINE_CAPMIX(num), \
2524 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002525}
2526
2527/* up to three ADCs */
2528DEFINE_CAPMIX(1);
2529DEFINE_CAPMIX(2);
2530DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002531DEFINE_CAPMIX_NOSRC(1);
2532DEFINE_CAPMIX_NOSRC(2);
2533DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002534
2535/*
2536 * ALC880 5-stack model
2537 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002538 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2539 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002540 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2541 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2542 */
2543
2544/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002545static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002546 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002547 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002548 { } /* end */
2549};
2550
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002551/* channel source setting (6/8 channel selection for 5-stack) */
2552/* 6ch mode */
2553static struct hda_verb alc880_fivestack_ch6_init[] = {
2554 /* set line-in to input, mute it */
2555 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2556 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002557 { } /* end */
2558};
2559
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002560/* 8ch mode */
2561static struct hda_verb alc880_fivestack_ch8_init[] = {
2562 /* set line-in to output, unmute it */
2563 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2564 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2565 { } /* end */
2566};
2567
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002568static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002569 { 6, alc880_fivestack_ch6_init },
2570 { 8, alc880_fivestack_ch8_init },
2571};
2572
2573
2574/*
2575 * ALC880 6-stack model
2576 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002577 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2578 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002579 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2580 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2581 */
2582
2583static hda_nid_t alc880_6st_dac_nids[4] = {
2584 /* front, rear, clfe, rear_surr */
2585 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002586};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002587
2588static struct hda_input_mux alc880_6stack_capture_source = {
2589 .num_items = 4,
2590 .items = {
2591 { "Mic", 0x0 },
2592 { "Front Mic", 0x1 },
2593 { "Line", 0x2 },
2594 { "CD", 0x4 },
2595 },
2596};
2597
2598/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002599static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002600 { 8, NULL },
2601};
2602
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002603static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002604 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002605 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002606 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002607 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002608 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2609 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002610 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2611 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002612 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002613 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002614 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2615 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2616 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2617 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2618 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2619 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2620 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2621 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002622 {
2623 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2624 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002625 .info = alc_ch_mode_info,
2626 .get = alc_ch_mode_get,
2627 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002628 },
2629 { } /* end */
2630};
2631
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002632
2633/*
2634 * ALC880 W810 model
2635 *
2636 * W810 has rear IO for:
2637 * Front (DAC 02)
2638 * Surround (DAC 03)
2639 * Center/LFE (DAC 04)
2640 * Digital out (06)
2641 *
2642 * The system also has a pair of internal speakers, and a headphone jack.
2643 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002644 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002645 * There is a variable resistor to control the speaker or headphone
2646 * volume. This is a hardware-only device without a software API.
2647 *
2648 * Plugging headphones in will disable the internal speakers. This is
2649 * implemented in hardware, not via the driver using jack sense. In
2650 * a similar fashion, plugging into the rear socket marked "front" will
2651 * disable both the speakers and headphones.
2652 *
2653 * For input, there's a microphone jack, and an "audio in" jack.
2654 * These may not do anything useful with this driver yet, because I
2655 * haven't setup any initialization verbs for these yet...
2656 */
2657
2658static hda_nid_t alc880_w810_dac_nids[3] = {
2659 /* front, rear/surround, clfe */
2660 0x02, 0x03, 0x04
2661};
2662
2663/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002664static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002665 { 6, NULL }
2666};
2667
2668/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002669static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002670 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002671 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002672 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002673 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002674 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2675 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002676 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2677 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002678 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2679 { } /* end */
2680};
2681
2682
2683/*
2684 * Z710V model
2685 *
2686 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002687 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2688 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002689 */
2690
2691static hda_nid_t alc880_z71v_dac_nids[1] = {
2692 0x02
2693};
2694#define ALC880_Z71V_HP_DAC 0x03
2695
2696/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002697static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002698 { 2, NULL }
2699};
2700
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002701static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002702 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002703 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002704 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002705 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002706 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2707 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2708 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2709 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2710 { } /* end */
2711};
2712
2713
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002714/*
2715 * ALC880 F1734 model
2716 *
2717 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2718 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2719 */
2720
2721static hda_nid_t alc880_f1734_dac_nids[1] = {
2722 0x03
2723};
2724#define ALC880_F1734_HP_DAC 0x02
2725
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002726static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002727 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002728 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002729 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2730 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002731 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2732 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002733 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2734 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002735 { } /* end */
2736};
2737
Takashi Iwai937b4162008-02-11 14:52:36 +01002738static struct hda_input_mux alc880_f1734_capture_source = {
2739 .num_items = 2,
2740 .items = {
2741 { "Mic", 0x1 },
2742 { "CD", 0x4 },
2743 },
2744};
2745
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002746
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002747/*
2748 * ALC880 ASUS model
2749 *
2750 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2751 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2752 * Mic = 0x18, Line = 0x1a
2753 */
2754
2755#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2756#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2757
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002758static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002759 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002760 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002761 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002762 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002763 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2764 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002765 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2766 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002767 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2768 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2769 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2770 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2771 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2772 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002773 {
2774 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2775 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002776 .info = alc_ch_mode_info,
2777 .get = alc_ch_mode_get,
2778 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002779 },
2780 { } /* end */
2781};
2782
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002783/*
2784 * ALC880 ASUS W1V model
2785 *
2786 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2787 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2788 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2789 */
2790
2791/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002792static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002793 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2794 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002795 { } /* end */
2796};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002797
Kailang Yangdf694da2005-12-05 19:42:22 +01002798/* TCL S700 */
2799static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2800 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2801 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2802 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2803 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2804 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2805 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2806 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2807 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2808 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002809 { } /* end */
2810};
2811
Kailang Yangccc656c2006-10-17 12:32:26 +02002812/* Uniwill */
2813static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002814 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2815 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2816 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2817 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002818 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2819 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2820 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2821 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2822 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2823 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2824 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2825 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2826 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2827 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2828 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2829 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002830 {
2831 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2832 .name = "Channel Mode",
2833 .info = alc_ch_mode_info,
2834 .get = alc_ch_mode_get,
2835 .put = alc_ch_mode_put,
2836 },
2837 { } /* end */
2838};
2839
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002840static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2841 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2842 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2843 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2844 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2845 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2846 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +01002847 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2848 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01002849 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2850 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002851 { } /* end */
2852};
2853
Kailang Yangccc656c2006-10-17 12:32:26 +02002854static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002855 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2856 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2857 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2858 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002859 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2860 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2861 { } /* end */
2862};
2863
Linus Torvalds1da177e2005-04-16 15:20:36 -07002864/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002865 * virtual master controls
2866 */
2867
2868/*
2869 * slave controls for virtual master
2870 */
Takashi Iwaiea734962011-01-17 11:29:34 +01002871static const char * const alc_slave_vols[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002872 "Front Playback Volume",
2873 "Surround Playback Volume",
2874 "Center Playback Volume",
2875 "LFE Playback Volume",
2876 "Side Playback Volume",
2877 "Headphone Playback Volume",
2878 "Speaker Playback Volume",
2879 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002880 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002881 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002882 NULL,
2883};
2884
Takashi Iwaiea734962011-01-17 11:29:34 +01002885static const char * const alc_slave_sws[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002886 "Front Playback Switch",
2887 "Surround Playback Switch",
2888 "Center Playback Switch",
2889 "LFE Playback Switch",
2890 "Side Playback Switch",
2891 "Headphone Playback Switch",
2892 "Speaker Playback Switch",
2893 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002894 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002895 "Line-Out Playback Switch",
2896 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002897 NULL,
2898};
2899
2900/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002901 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002902 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002903
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002904#define NID_MAPPING (-1)
2905
2906#define SUBDEV_SPEAKER_ (0 << 6)
2907#define SUBDEV_HP_ (1 << 6)
2908#define SUBDEV_LINE_ (2 << 6)
2909#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2910#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2911#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2912
Takashi Iwai603c4012008-07-30 15:01:44 +02002913static void alc_free_kctls(struct hda_codec *codec);
2914
Takashi Iwai67d634c2009-11-16 15:35:59 +01002915#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002916/* additional beep mixers; the actual parameters are overwritten at build */
2917static struct snd_kcontrol_new alc_beep_mixer[] = {
2918 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002919 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002920 { } /* end */
2921};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002922#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002923
Linus Torvalds1da177e2005-04-16 15:20:36 -07002924static int alc_build_controls(struct hda_codec *codec)
2925{
2926 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02002927 struct snd_kcontrol *kctl = NULL;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002928 struct snd_kcontrol_new *knew;
2929 int i, j, err;
2930 unsigned int u;
2931 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002932
2933 for (i = 0; i < spec->num_mixers; i++) {
2934 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2935 if (err < 0)
2936 return err;
2937 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002938 if (spec->cap_mixer) {
2939 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2940 if (err < 0)
2941 return err;
2942 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002943 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002944 err = snd_hda_create_spdif_out_ctls(codec,
2945 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002946 if (err < 0)
2947 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002948 if (!spec->no_analog) {
2949 err = snd_hda_create_spdif_share_sw(codec,
2950 &spec->multiout);
2951 if (err < 0)
2952 return err;
2953 spec->multiout.share_spdif = 1;
2954 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002955 }
2956 if (spec->dig_in_nid) {
2957 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2958 if (err < 0)
2959 return err;
2960 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002961
Takashi Iwai67d634c2009-11-16 15:35:59 +01002962#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002963 /* create beep controls if needed */
2964 if (spec->beep_amp) {
2965 struct snd_kcontrol_new *knew;
2966 for (knew = alc_beep_mixer; knew->name; knew++) {
2967 struct snd_kcontrol *kctl;
2968 kctl = snd_ctl_new1(knew, codec);
2969 if (!kctl)
2970 return -ENOMEM;
2971 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002972 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002973 if (err < 0)
2974 return err;
2975 }
2976 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002977#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002978
Takashi Iwai2134ea42008-01-10 16:53:55 +01002979 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002980 if (!spec->no_analog &&
2981 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002982 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002983 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002984 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002985 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002986 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002987 if (err < 0)
2988 return err;
2989 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002990 if (!spec->no_analog &&
2991 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002992 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2993 NULL, alc_slave_sws);
2994 if (err < 0)
2995 return err;
2996 }
2997
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002998 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02002999 if (spec->capsrc_nids || spec->adc_nids) {
3000 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
3001 if (!kctl)
3002 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
3003 for (i = 0; kctl && i < kctl->count; i++) {
3004 hda_nid_t *nids = spec->capsrc_nids;
3005 if (!nids)
3006 nids = spec->adc_nids;
3007 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
3008 if (err < 0)
3009 return err;
3010 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003011 }
3012 if (spec->cap_mixer) {
3013 const char *kname = kctl ? kctl->id.name : NULL;
3014 for (knew = spec->cap_mixer; knew->name; knew++) {
3015 if (kname && strcmp(knew->name, kname) == 0)
3016 continue;
3017 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3018 for (i = 0; kctl && i < kctl->count; i++) {
3019 err = snd_hda_add_nid(codec, kctl, i,
3020 spec->adc_nids[i]);
3021 if (err < 0)
3022 return err;
3023 }
3024 }
3025 }
3026
3027 /* other nid->control mapping */
3028 for (i = 0; i < spec->num_mixers; i++) {
3029 for (knew = spec->mixers[i]; knew->name; knew++) {
3030 if (knew->iface != NID_MAPPING)
3031 continue;
3032 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3033 if (kctl == NULL)
3034 continue;
3035 u = knew->subdevice;
3036 for (j = 0; j < 4; j++, u >>= 8) {
3037 nid = u & 0x3f;
3038 if (nid == 0)
3039 continue;
3040 switch (u & 0xc0) {
3041 case SUBDEV_SPEAKER_:
3042 nid = spec->autocfg.speaker_pins[nid];
3043 break;
3044 case SUBDEV_LINE_:
3045 nid = spec->autocfg.line_out_pins[nid];
3046 break;
3047 case SUBDEV_HP_:
3048 nid = spec->autocfg.hp_pins[nid];
3049 break;
3050 default:
3051 continue;
3052 }
3053 err = snd_hda_add_nid(codec, kctl, 0, nid);
3054 if (err < 0)
3055 return err;
3056 }
3057 u = knew->private_value;
3058 for (j = 0; j < 4; j++, u >>= 8) {
3059 nid = u & 0xff;
3060 if (nid == 0)
3061 continue;
3062 err = snd_hda_add_nid(codec, kctl, 0, nid);
3063 if (err < 0)
3064 return err;
3065 }
3066 }
3067 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01003068
3069 alc_free_kctls(codec); /* no longer needed */
3070
Linus Torvalds1da177e2005-04-16 15:20:36 -07003071 return 0;
3072}
3073
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003074
Linus Torvalds1da177e2005-04-16 15:20:36 -07003075/*
3076 * initialize the codec volumes, etc
3077 */
3078
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003079/*
3080 * generic initialization of ADC, input mixers and output mixers
3081 */
3082static struct hda_verb alc880_volume_init_verbs[] = {
3083 /*
3084 * Unmute ADC0-2 and set the default input to mic-in
3085 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003086 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003087 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003088 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003089 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003090 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003091 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003092
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003093 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3094 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003095 * Note: PASD motherboards uses the Line In 2 as the input for front
3096 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003097 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003098 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003099 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3101 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3104 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3105 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003106
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003107 /*
3108 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003109 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003110 /* set vol=0 to output mixers */
3111 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3112 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3113 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3114 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3115 /* set up input amps for analog loopback */
3116 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003117 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3118 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003119 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3120 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003121 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3122 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003123 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3124 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003125
3126 { }
3127};
3128
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003129/*
3130 * 3-stack pin configuration:
3131 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
3132 */
3133static struct hda_verb alc880_pin_3stack_init_verbs[] = {
3134 /*
3135 * preset connection lists of input pins
3136 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3137 */
3138 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3139 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3140 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3141
3142 /*
3143 * Set pin mode and muting
3144 */
3145 /* set front pin widgets 0x14 for output */
3146 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3147 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3148 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3149 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3150 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3151 /* Mic2 (as headphone out) for HP output */
3152 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3153 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3154 /* Line In pin widget for input */
3155 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3156 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3157 /* Line2 (as front mic) pin widget for input and vref at 80% */
3158 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3159 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3160 /* CD pin widget for input */
3161 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3162
3163 { }
3164};
3165
3166/*
3167 * 5-stack pin configuration:
3168 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3169 * line-in/side = 0x1a, f-mic = 0x1b
3170 */
3171static struct hda_verb alc880_pin_5stack_init_verbs[] = {
3172 /*
3173 * preset connection lists of input pins
3174 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3175 */
3176 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3177 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3178
3179 /*
3180 * Set pin mode and muting
3181 */
3182 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02003183 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3184 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3185 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3186 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003187 /* unmute pins for output (no gain on this amp) */
3188 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3189 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3190 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3191 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3192
Linus Torvalds1da177e2005-04-16 15:20:36 -07003193 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003194 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003195 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3196 /* Mic2 (as headphone out) for HP output */
3197 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003198 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003199 /* Line In pin widget for input */
3200 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3201 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3202 /* Line2 (as front mic) pin widget for input and vref at 80% */
3203 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3204 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3205 /* CD pin widget for input */
3206 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003207
3208 { }
3209};
3210
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003211/*
3212 * W810 pin configuration:
3213 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3214 */
3215static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003216 /* hphone/speaker input selector: front DAC */
3217 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3218
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003219 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3220 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3221 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3222 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3223 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3224 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3225
3226 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003227 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003228
Linus Torvalds1da177e2005-04-16 15:20:36 -07003229 { }
3230};
3231
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003232/*
3233 * Z71V pin configuration:
3234 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3235 */
3236static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003237 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003238 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02003239 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003240 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003241
Takashi Iwai16ded522005-06-10 19:58:24 +02003242 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003243 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003244 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003245 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003246
3247 { }
3248};
3249
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003250/*
3251 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003252 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3253 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003254 */
3255static struct hda_verb alc880_pin_6stack_init_verbs[] = {
3256 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3257
Takashi Iwai16ded522005-06-10 19:58:24 +02003258 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003259 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003260 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003261 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003262 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003263 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003264 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003265 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3266
Takashi Iwai16ded522005-06-10 19:58:24 +02003267 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003268 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003269 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003270 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003271 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003272 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003273 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003274 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003275 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003276
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003277 { }
3278};
Takashi Iwai16ded522005-06-10 19:58:24 +02003279
Kailang Yangccc656c2006-10-17 12:32:26 +02003280/*
3281 * Uniwill pin configuration:
3282 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3283 * line = 0x1a
3284 */
3285static struct hda_verb alc880_uniwill_init_verbs[] = {
3286 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3287
3288 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3289 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3290 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3291 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3292 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3293 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3294 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3295 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3296 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3297 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3298 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3299 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3300 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3301 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3302
3303 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3304 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3305 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3306 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3307 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3308 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3309 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3310 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3311 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3312
3313 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3314 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3315
3316 { }
3317};
3318
3319/*
3320* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003321* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003322 */
3323static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3324 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3325
3326 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3327 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3328 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3329 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3330 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3331 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3332 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3333 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3334 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3335 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3336 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3337 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3338
3339 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3340 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3341 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3342 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3343 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3344 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3345
3346 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3347 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3348
3349 { }
3350};
3351
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003352static struct hda_verb alc880_beep_init_verbs[] = {
3353 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3354 { }
3355};
3356
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003357/* auto-toggle front mic */
Anisse Astiereeb43382010-12-16 12:19:47 +01003358static void alc88x_simple_mic_automute(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003359{
3360 unsigned int present;
3361 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003362
Wu Fengguang864f92b2009-11-18 12:38:02 +08003363 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003364 bits = present ? HDA_AMP_MUTE : 0;
3365 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003366}
3367
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003368static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003369{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003370 struct alc_spec *spec = codec->spec;
3371
3372 spec->autocfg.hp_pins[0] = 0x14;
3373 spec->autocfg.speaker_pins[0] = 0x15;
3374 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003375}
3376
3377static void alc880_uniwill_init_hook(struct hda_codec *codec)
3378{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003379 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01003380 alc88x_simple_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003381}
3382
3383static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3384 unsigned int res)
3385{
3386 /* Looks like the unsol event is incompatible with the standard
3387 * definition. 4bit tag is placed at 28 bit!
3388 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003389 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003390 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01003391 alc88x_simple_mic_automute(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003392 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003393 default:
3394 alc_automute_amp_unsol_event(codec, res);
3395 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003396 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003397}
3398
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003399static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003400{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003401 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003402
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003403 spec->autocfg.hp_pins[0] = 0x14;
3404 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02003405}
3406
3407static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3408{
3409 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003410
Kailang Yangccc656c2006-10-17 12:32:26 +02003411 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003412 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3413 present &= HDA_AMP_VOLMASK;
3414 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3415 HDA_AMP_VOLMASK, present);
3416 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3417 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003418}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003419
Kailang Yangccc656c2006-10-17 12:32:26 +02003420static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3421 unsigned int res)
3422{
3423 /* Looks like the unsol event is incompatible with the standard
3424 * definition. 4bit tag is placed at 28 bit!
3425 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003426 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003427 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003428 else
3429 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003430}
3431
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003432/*
3433 * F1734 pin configuration:
3434 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3435 */
3436static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003437 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003438 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3439 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3440 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3441 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3442
3443 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3444 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3445 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3446 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3447
3448 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3449 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003450 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003451 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3452 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3453 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3454 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3455 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3456 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003457
Takashi Iwai937b4162008-02-11 14:52:36 +01003458 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3459 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3460
Takashi Iwai16ded522005-06-10 19:58:24 +02003461 { }
3462};
3463
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003464/*
3465 * ASUS pin configuration:
3466 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3467 */
3468static struct hda_verb alc880_pin_asus_init_verbs[] = {
3469 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3470 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3471 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3472 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3473
3474 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3475 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3476 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3477 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3478 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3479 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3480 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3481 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3482
3483 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3484 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3485 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3486 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3487 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3488 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3489 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3490 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3491 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003492
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003493 { }
3494};
3495
3496/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003497#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3498#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003499#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003500
Kailang Yangdf694da2005-12-05 19:42:22 +01003501/* Clevo m520g init */
3502static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3503 /* headphone output */
3504 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3505 /* line-out */
3506 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3507 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3508 /* Line-in */
3509 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3510 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3511 /* CD */
3512 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3513 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3514 /* Mic1 (rear panel) */
3515 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3516 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3517 /* Mic2 (front panel) */
3518 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3519 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3520 /* headphone */
3521 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3522 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3523 /* change to EAPD mode */
3524 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3525 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3526
3527 { }
3528};
3529
3530static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003531 /* change to EAPD mode */
3532 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3533 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3534
Kailang Yangdf694da2005-12-05 19:42:22 +01003535 /* Headphone output */
3536 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3537 /* Front output*/
3538 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3539 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3540
3541 /* Line In pin widget for input */
3542 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3543 /* CD pin widget for input */
3544 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3545 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3546 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3547
3548 /* change to EAPD mode */
3549 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3550 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3551
3552 { }
3553};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003554
3555/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003556 * LG m1 express dual
3557 *
3558 * Pin assignment:
3559 * Rear Line-In/Out (blue): 0x14
3560 * Build-in Mic-In: 0x15
3561 * Speaker-out: 0x17
3562 * HP-Out (green): 0x1b
3563 * Mic-In/Out (red): 0x19
3564 * SPDIF-Out: 0x1e
3565 */
3566
3567/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3568static hda_nid_t alc880_lg_dac_nids[3] = {
3569 0x05, 0x02, 0x03
3570};
3571
3572/* seems analog CD is not working */
3573static struct hda_input_mux alc880_lg_capture_source = {
3574 .num_items = 3,
3575 .items = {
3576 { "Mic", 0x1 },
3577 { "Line", 0x5 },
3578 { "Internal Mic", 0x6 },
3579 },
3580};
3581
3582/* 2,4,6 channel modes */
3583static struct hda_verb alc880_lg_ch2_init[] = {
3584 /* set line-in and mic-in to input */
3585 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3586 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3587 { }
3588};
3589
3590static struct hda_verb alc880_lg_ch4_init[] = {
3591 /* set line-in to out and mic-in to input */
3592 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3593 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3594 { }
3595};
3596
3597static struct hda_verb alc880_lg_ch6_init[] = {
3598 /* set line-in and mic-in to output */
3599 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3600 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3601 { }
3602};
3603
3604static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3605 { 2, alc880_lg_ch2_init },
3606 { 4, alc880_lg_ch4_init },
3607 { 6, alc880_lg_ch6_init },
3608};
3609
3610static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003611 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3612 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003613 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3614 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3615 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3616 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3617 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3618 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3619 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3620 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3621 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3622 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3623 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3624 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3625 {
3626 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3627 .name = "Channel Mode",
3628 .info = alc_ch_mode_info,
3629 .get = alc_ch_mode_get,
3630 .put = alc_ch_mode_put,
3631 },
3632 { } /* end */
3633};
3634
3635static struct hda_verb alc880_lg_init_verbs[] = {
3636 /* set capture source to mic-in */
3637 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3638 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3639 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3640 /* mute all amp mixer inputs */
3641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003644 /* line-in to input */
3645 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3646 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3647 /* built-in mic */
3648 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3649 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3650 /* speaker-out */
3651 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3652 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3653 /* mic-in to input */
3654 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3655 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3656 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3657 /* HP-out */
3658 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3659 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3660 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3661 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003662 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003663 { }
3664};
3665
3666/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003667static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003668{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003669 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003670
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003671 spec->autocfg.hp_pins[0] = 0x1b;
3672 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003673}
3674
3675/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003676 * LG LW20
3677 *
3678 * Pin assignment:
3679 * Speaker-out: 0x14
3680 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003681 * Built-in Mic-In: 0x19
3682 * Line-In: 0x1b
3683 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003684 * SPDIF-Out: 0x1e
3685 */
3686
Takashi Iwaid6815182006-03-23 16:06:23 +01003687static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003688 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003689 .items = {
3690 { "Mic", 0x0 },
3691 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003692 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003693 },
3694};
3695
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003696#define alc880_lg_lw_modes alc880_threestack_modes
3697
Takashi Iwaid6815182006-03-23 16:06:23 +01003698static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003699 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3700 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3701 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3702 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3703 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3704 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3705 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3706 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3707 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3708 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003709 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3710 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3711 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3712 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003713 {
3714 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3715 .name = "Channel Mode",
3716 .info = alc_ch_mode_info,
3717 .get = alc_ch_mode_get,
3718 .put = alc_ch_mode_put,
3719 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003720 { } /* end */
3721};
3722
3723static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003724 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3725 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3726 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3727
Takashi Iwaid6815182006-03-23 16:06:23 +01003728 /* set capture source to mic-in */
3729 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3730 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3731 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003732 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003733 /* speaker-out */
3734 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3735 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3736 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003737 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3738 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3739 /* mic-in to input */
3740 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3741 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3742 /* built-in mic */
3743 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3744 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3745 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003746 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003747 { }
3748};
3749
3750/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003751static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003752{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003753 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003754
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003755 spec->autocfg.hp_pins[0] = 0x1b;
3756 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003757}
3758
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003759static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3760 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3761 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3762 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3763 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3764 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3765 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3766 { } /* end */
3767};
3768
3769static struct hda_input_mux alc880_medion_rim_capture_source = {
3770 .num_items = 2,
3771 .items = {
3772 { "Mic", 0x0 },
3773 { "Internal Mic", 0x1 },
3774 },
3775};
3776
3777static struct hda_verb alc880_medion_rim_init_verbs[] = {
3778 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3779
3780 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3781 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3782
3783 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3784 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3785 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3786 /* Mic2 (as headphone out) for HP output */
3787 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3788 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3789 /* Internal Speaker */
3790 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3791 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3792
3793 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3794 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3795
3796 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3797 { }
3798};
3799
3800/* toggle speaker-output according to the hp-jack state */
3801static void alc880_medion_rim_automute(struct hda_codec *codec)
3802{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003803 struct alc_spec *spec = codec->spec;
3804 alc_automute_amp(codec);
3805 /* toggle EAPD */
3806 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003807 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3808 else
3809 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3810}
3811
3812static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3813 unsigned int res)
3814{
3815 /* Looks like the unsol event is incompatible with the standard
3816 * definition. 4bit tag is placed at 28 bit!
3817 */
3818 if ((res >> 28) == ALC880_HP_EVENT)
3819 alc880_medion_rim_automute(codec);
3820}
3821
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003822static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003823{
3824 struct alc_spec *spec = codec->spec;
3825
3826 spec->autocfg.hp_pins[0] = 0x14;
3827 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003828}
3829
Takashi Iwaicb53c622007-08-10 17:21:45 +02003830#ifdef CONFIG_SND_HDA_POWER_SAVE
3831static struct hda_amp_list alc880_loopbacks[] = {
3832 { 0x0b, HDA_INPUT, 0 },
3833 { 0x0b, HDA_INPUT, 1 },
3834 { 0x0b, HDA_INPUT, 2 },
3835 { 0x0b, HDA_INPUT, 3 },
3836 { 0x0b, HDA_INPUT, 4 },
3837 { } /* end */
3838};
3839
3840static struct hda_amp_list alc880_lg_loopbacks[] = {
3841 { 0x0b, HDA_INPUT, 1 },
3842 { 0x0b, HDA_INPUT, 6 },
3843 { 0x0b, HDA_INPUT, 7 },
3844 { } /* end */
3845};
3846#endif
3847
Takashi Iwaid6815182006-03-23 16:06:23 +01003848/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003849 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003850 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003851
Takashi Iwai584c0c42011-03-10 12:51:11 +01003852static void alc_init_special_input_src(struct hda_codec *codec);
3853
Linus Torvalds1da177e2005-04-16 15:20:36 -07003854static int alc_init(struct hda_codec *codec)
3855{
3856 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003857 unsigned int i;
3858
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003859 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003860 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003861
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003862 for (i = 0; i < spec->num_init_verbs; i++)
3863 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwai584c0c42011-03-10 12:51:11 +01003864 alc_init_special_input_src(codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003865
3866 if (spec->init_hook)
3867 spec->init_hook(codec);
3868
Takashi Iwai58701122011-01-13 15:41:45 +01003869 alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT);
3870
Takashi Iwai9e5341b2010-09-21 09:57:06 +02003871 hda_call_check_power_status(codec, 0x01);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003872 return 0;
3873}
3874
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003875static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3876{
3877 struct alc_spec *spec = codec->spec;
3878
3879 if (spec->unsol_event)
3880 spec->unsol_event(codec, res);
3881}
3882
Takashi Iwaicb53c622007-08-10 17:21:45 +02003883#ifdef CONFIG_SND_HDA_POWER_SAVE
3884static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3885{
3886 struct alc_spec *spec = codec->spec;
3887 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3888}
3889#endif
3890
Linus Torvalds1da177e2005-04-16 15:20:36 -07003891/*
3892 * Analog playback callbacks
3893 */
3894static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3895 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003896 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003897{
3898 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003899 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3900 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003901}
3902
3903static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3904 struct hda_codec *codec,
3905 unsigned int stream_tag,
3906 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003907 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003908{
3909 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003910 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3911 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003912}
3913
3914static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3915 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003916 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003917{
3918 struct alc_spec *spec = codec->spec;
3919 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3920}
3921
3922/*
3923 * Digital out
3924 */
3925static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3926 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003927 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003928{
3929 struct alc_spec *spec = codec->spec;
3930 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3931}
3932
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003933static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3934 struct hda_codec *codec,
3935 unsigned int stream_tag,
3936 unsigned int format,
3937 struct snd_pcm_substream *substream)
3938{
3939 struct alc_spec *spec = codec->spec;
3940 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3941 stream_tag, format, substream);
3942}
3943
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003944static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3945 struct hda_codec *codec,
3946 struct snd_pcm_substream *substream)
3947{
3948 struct alc_spec *spec = codec->spec;
3949 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3950}
3951
Linus Torvalds1da177e2005-04-16 15:20:36 -07003952static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3953 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003954 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003955{
3956 struct alc_spec *spec = codec->spec;
3957 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3958}
3959
3960/*
3961 * Analog capture
3962 */
Takashi Iwai63300792008-01-24 15:31:36 +01003963static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003964 struct hda_codec *codec,
3965 unsigned int stream_tag,
3966 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003967 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003968{
3969 struct alc_spec *spec = codec->spec;
3970
Takashi Iwai63300792008-01-24 15:31:36 +01003971 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003972 stream_tag, 0, format);
3973 return 0;
3974}
3975
Takashi Iwai63300792008-01-24 15:31:36 +01003976static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003977 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003978 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003979{
3980 struct alc_spec *spec = codec->spec;
3981
Takashi Iwai888afa12008-03-18 09:57:50 +01003982 snd_hda_codec_cleanup_stream(codec,
3983 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003984 return 0;
3985}
3986
Takashi Iwai840b64c2010-07-13 22:49:01 +02003987/* analog capture with dynamic dual-adc changes */
3988static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3989 struct hda_codec *codec,
3990 unsigned int stream_tag,
3991 unsigned int format,
3992 struct snd_pcm_substream *substream)
3993{
3994 struct alc_spec *spec = codec->spec;
3995 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
3996 spec->cur_adc_stream_tag = stream_tag;
3997 spec->cur_adc_format = format;
3998 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
3999 return 0;
4000}
4001
4002static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
4003 struct hda_codec *codec,
4004 struct snd_pcm_substream *substream)
4005{
4006 struct alc_spec *spec = codec->spec;
4007 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
4008 spec->cur_adc = 0;
4009 return 0;
4010}
4011
4012static struct hda_pcm_stream dualmic_pcm_analog_capture = {
4013 .substreams = 1,
4014 .channels_min = 2,
4015 .channels_max = 2,
4016 .nid = 0, /* fill later */
4017 .ops = {
4018 .prepare = dualmic_capture_pcm_prepare,
4019 .cleanup = dualmic_capture_pcm_cleanup
4020 },
4021};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004022
4023/*
4024 */
4025static struct hda_pcm_stream alc880_pcm_analog_playback = {
4026 .substreams = 1,
4027 .channels_min = 2,
4028 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004029 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004030 .ops = {
4031 .open = alc880_playback_pcm_open,
4032 .prepare = alc880_playback_pcm_prepare,
4033 .cleanup = alc880_playback_pcm_cleanup
4034 },
4035};
4036
4037static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01004038 .substreams = 1,
4039 .channels_min = 2,
4040 .channels_max = 2,
4041 /* NID is set in alc_build_pcms */
4042};
4043
4044static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
4045 .substreams = 1,
4046 .channels_min = 2,
4047 .channels_max = 2,
4048 /* NID is set in alc_build_pcms */
4049};
4050
4051static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
4052 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004053 .channels_min = 2,
4054 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004055 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004056 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01004057 .prepare = alc880_alt_capture_pcm_prepare,
4058 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004059 },
4060};
4061
4062static struct hda_pcm_stream alc880_pcm_digital_playback = {
4063 .substreams = 1,
4064 .channels_min = 2,
4065 .channels_max = 2,
4066 /* NID is set in alc_build_pcms */
4067 .ops = {
4068 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02004069 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01004070 .prepare = alc880_dig_playback_pcm_prepare,
4071 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004072 },
4073};
4074
4075static struct hda_pcm_stream alc880_pcm_digital_capture = {
4076 .substreams = 1,
4077 .channels_min = 2,
4078 .channels_max = 2,
4079 /* NID is set in alc_build_pcms */
4080};
4081
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004082/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01004083static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004084 .substreams = 0,
4085 .channels_min = 0,
4086 .channels_max = 0,
4087};
4088
Linus Torvalds1da177e2005-04-16 15:20:36 -07004089static int alc_build_pcms(struct hda_codec *codec)
4090{
4091 struct alc_spec *spec = codec->spec;
4092 struct hda_pcm *info = spec->pcm_rec;
4093 int i;
4094
4095 codec->num_pcms = 1;
4096 codec->pcm_info = info;
4097
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004098 if (spec->no_analog)
4099 goto skip_analog;
4100
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004101 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
4102 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004103 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01004104
Takashi Iwai4a471b72005-12-07 13:56:29 +01004105 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004106 if (snd_BUG_ON(!spec->multiout.dac_nids))
4107 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004108 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
4109 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
4110 }
4111 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004112 if (snd_BUG_ON(!spec->adc_nids))
4113 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004114 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
4115 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
4116 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004117
Takashi Iwai4a471b72005-12-07 13:56:29 +01004118 if (spec->channel_mode) {
4119 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
4120 for (i = 0; i < spec->num_channel_mode; i++) {
4121 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
4122 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
4123 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004124 }
4125 }
4126
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004127 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02004128 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004129 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004130 snprintf(spec->stream_name_digital,
4131 sizeof(spec->stream_name_digital),
4132 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02004133 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08004134 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004135 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004136 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01004137 if (spec->dig_out_type)
4138 info->pcm_type = spec->dig_out_type;
4139 else
4140 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004141 if (spec->multiout.dig_out_nid &&
4142 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004143 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
4144 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
4145 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004146 if (spec->dig_in_nid &&
4147 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004148 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
4149 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
4150 }
Takashi Iwai963f8032008-08-11 10:04:40 +02004151 /* FIXME: do we need this for all Realtek codec models? */
4152 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004153 }
4154
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004155 if (spec->no_analog)
4156 return 0;
4157
Takashi Iwaie08a0072006-09-07 17:52:14 +02004158 /* If the use of more than one ADC is requested for the current
4159 * model, configure a second analog capture-only PCM.
4160 */
4161 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01004162 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
4163 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02004164 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004165 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004166 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01004167 if (spec->alt_dac_nid) {
4168 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4169 *spec->stream_analog_alt_playback;
4170 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
4171 spec->alt_dac_nid;
4172 } else {
4173 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4174 alc_pcm_null_stream;
4175 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
4176 }
4177 if (spec->num_adc_nids > 1) {
4178 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4179 *spec->stream_analog_alt_capture;
4180 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
4181 spec->adc_nids[1];
4182 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
4183 spec->num_adc_nids - 1;
4184 } else {
4185 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4186 alc_pcm_null_stream;
4187 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004188 }
4189 }
4190
Linus Torvalds1da177e2005-04-16 15:20:36 -07004191 return 0;
4192}
4193
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004194static inline void alc_shutup(struct hda_codec *codec)
4195{
4196 snd_hda_shutup_pins(codec);
4197}
4198
Takashi Iwai603c4012008-07-30 15:01:44 +02004199static void alc_free_kctls(struct hda_codec *codec)
4200{
4201 struct alc_spec *spec = codec->spec;
4202
4203 if (spec->kctls.list) {
4204 struct snd_kcontrol_new *kctl = spec->kctls.list;
4205 int i;
4206 for (i = 0; i < spec->kctls.used; i++)
4207 kfree(kctl[i].name);
4208 }
4209 snd_array_free(&spec->kctls);
4210}
4211
Linus Torvalds1da177e2005-04-16 15:20:36 -07004212static void alc_free(struct hda_codec *codec)
4213{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004214 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004215
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004216 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004217 return;
4218
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004219 alc_shutup(codec);
Takashi Iwaicd372fb2011-03-03 14:40:14 +01004220 snd_hda_input_jack_free(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02004221 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004222 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004223 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004224}
4225
Hector Martinf5de24b2009-12-20 22:51:31 +01004226#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05004227static void alc_power_eapd(struct hda_codec *codec)
4228{
4229 /* We currently only handle front, HP */
4230 switch (codec->vendor_id) {
4231 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004232 set_eapd(codec, 0x0f, 0);
4233 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004234 break;
4235 case 0x10ec0262:
4236 case 0x10ec0267:
4237 case 0x10ec0268:
4238 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004239 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05004240 case 0x10ec0272:
4241 case 0x10ec0660:
4242 case 0x10ec0662:
4243 case 0x10ec0663:
Andres Mejia75eb1c32011-03-20 14:07:40 -04004244 case 0x10ec0665:
Daniel T Chenc97259d2009-12-27 18:52:08 -05004245 case 0x10ec0862:
4246 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004247 set_eapd(codec, 0x14, 0);
4248 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004249 break;
4250 }
4251}
4252
Hector Martinf5de24b2009-12-20 22:51:31 +01004253static int alc_suspend(struct hda_codec *codec, pm_message_t state)
4254{
4255 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004256 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004257 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05004258 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004259 return 0;
4260}
4261#endif
4262
Takashi Iwaie044c392008-10-27 16:56:24 +01004263#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01004264static int alc_resume(struct hda_codec *codec)
4265{
Takashi Iwaie044c392008-10-27 16:56:24 +01004266 codec->patch_ops.init(codec);
4267 snd_hda_codec_resume_amp(codec);
4268 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +02004269 hda_call_check_power_status(codec, 0x01);
Takashi Iwaie044c392008-10-27 16:56:24 +01004270 return 0;
4271}
Takashi Iwaie044c392008-10-27 16:56:24 +01004272#endif
4273
Linus Torvalds1da177e2005-04-16 15:20:36 -07004274/*
4275 */
4276static struct hda_codec_ops alc_patch_ops = {
4277 .build_controls = alc_build_controls,
4278 .build_pcms = alc_build_pcms,
4279 .init = alc_init,
4280 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004281 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004282#ifdef SND_HDA_NEEDS_RESUME
4283 .resume = alc_resume,
4284#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004285#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004286 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004287 .check_power_status = alc_check_power_status,
4288#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004289 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004290};
4291
Kailang Yangc027ddc2010-03-19 11:33:06 +01004292/* replace the codec chip_name with the given string */
4293static int alc_codec_rename(struct hda_codec *codec, const char *name)
4294{
4295 kfree(codec->chip_name);
4296 codec->chip_name = kstrdup(name, GFP_KERNEL);
4297 if (!codec->chip_name) {
4298 alc_free(codec);
4299 return -ENOMEM;
4300 }
4301 return 0;
4302}
4303
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004304/*
4305 * Test configuration for debugging
4306 *
4307 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4308 * enum controls.
4309 */
4310#ifdef CONFIG_SND_DEBUG
4311static hda_nid_t alc880_test_dac_nids[4] = {
4312 0x02, 0x03, 0x04, 0x05
4313};
4314
4315static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004316 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004317 .items = {
4318 { "In-1", 0x0 },
4319 { "In-2", 0x1 },
4320 { "In-3", 0x2 },
4321 { "In-4", 0x3 },
4322 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004323 { "Front", 0x5 },
4324 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004325 },
4326};
4327
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004328static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004329 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004330 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004331 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004332 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004333};
4334
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004335static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4336 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004337{
4338 static char *texts[] = {
4339 "N/A", "Line Out", "HP Out",
4340 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4341 };
4342 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4343 uinfo->count = 1;
4344 uinfo->value.enumerated.items = 8;
4345 if (uinfo->value.enumerated.item >= 8)
4346 uinfo->value.enumerated.item = 7;
4347 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4348 return 0;
4349}
4350
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004351static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4352 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004353{
4354 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4355 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4356 unsigned int pin_ctl, item = 0;
4357
4358 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4359 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4360 if (pin_ctl & AC_PINCTL_OUT_EN) {
4361 if (pin_ctl & AC_PINCTL_HP_EN)
4362 item = 2;
4363 else
4364 item = 1;
4365 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4366 switch (pin_ctl & AC_PINCTL_VREFEN) {
4367 case AC_PINCTL_VREF_HIZ: item = 3; break;
4368 case AC_PINCTL_VREF_50: item = 4; break;
4369 case AC_PINCTL_VREF_GRD: item = 5; break;
4370 case AC_PINCTL_VREF_80: item = 6; break;
4371 case AC_PINCTL_VREF_100: item = 7; break;
4372 }
4373 }
4374 ucontrol->value.enumerated.item[0] = item;
4375 return 0;
4376}
4377
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004378static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
4379 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004380{
4381 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4382 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4383 static unsigned int ctls[] = {
4384 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4385 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4386 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4387 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4388 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4389 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4390 };
4391 unsigned int old_ctl, new_ctl;
4392
4393 old_ctl = snd_hda_codec_read(codec, nid, 0,
4394 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4395 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4396 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004397 int val;
4398 snd_hda_codec_write_cache(codec, nid, 0,
4399 AC_VERB_SET_PIN_WIDGET_CONTROL,
4400 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004401 val = ucontrol->value.enumerated.item[0] >= 3 ?
4402 HDA_AMP_MUTE : 0;
4403 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4404 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004405 return 1;
4406 }
4407 return 0;
4408}
4409
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004410static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4411 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004412{
4413 static char *texts[] = {
4414 "Front", "Surround", "CLFE", "Side"
4415 };
4416 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4417 uinfo->count = 1;
4418 uinfo->value.enumerated.items = 4;
4419 if (uinfo->value.enumerated.item >= 4)
4420 uinfo->value.enumerated.item = 3;
4421 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4422 return 0;
4423}
4424
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004425static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4426 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004427{
4428 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4429 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4430 unsigned int sel;
4431
4432 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4433 ucontrol->value.enumerated.item[0] = sel & 3;
4434 return 0;
4435}
4436
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004437static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4438 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004439{
4440 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4441 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4442 unsigned int sel;
4443
4444 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4445 if (ucontrol->value.enumerated.item[0] != sel) {
4446 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004447 snd_hda_codec_write_cache(codec, nid, 0,
4448 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004449 return 1;
4450 }
4451 return 0;
4452}
4453
4454#define PIN_CTL_TEST(xname,nid) { \
4455 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4456 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004457 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004458 .info = alc_test_pin_ctl_info, \
4459 .get = alc_test_pin_ctl_get, \
4460 .put = alc_test_pin_ctl_put, \
4461 .private_value = nid \
4462 }
4463
4464#define PIN_SRC_TEST(xname,nid) { \
4465 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4466 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004467 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004468 .info = alc_test_pin_src_info, \
4469 .get = alc_test_pin_src_get, \
4470 .put = alc_test_pin_src_put, \
4471 .private_value = nid \
4472 }
4473
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004474static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004475 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4476 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4477 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4478 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004479 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4480 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4481 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4482 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004483 PIN_CTL_TEST("Front Pin Mode", 0x14),
4484 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4485 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4486 PIN_CTL_TEST("Side Pin Mode", 0x17),
4487 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4488 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4489 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4490 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4491 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4492 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4493 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4494 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4495 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4496 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4497 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4498 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4499 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4500 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4501 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4502 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4503 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4504 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004505 {
4506 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4507 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004508 .info = alc_ch_mode_info,
4509 .get = alc_ch_mode_get,
4510 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004511 },
4512 { } /* end */
4513};
4514
4515static struct hda_verb alc880_test_init_verbs[] = {
4516 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004517 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4518 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4519 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4520 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4521 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4522 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4523 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4524 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004525 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004526 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4527 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4528 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4529 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004530 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004531 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4532 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4533 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4534 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004535 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004536 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4537 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4538 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4539 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004540 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004541 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4542 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004543 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4544 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4545 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004546 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004547 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4548 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4549 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4550 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004551 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004552 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004553 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004554 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004555 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004556 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004557 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004558 /* Analog input/passthru */
4559 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4560 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4561 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4562 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4563 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004564 { }
4565};
4566#endif
4567
Linus Torvalds1da177e2005-04-16 15:20:36 -07004568/*
4569 */
4570
Takashi Iwaiea734962011-01-17 11:29:34 +01004571static const char * const alc880_models[ALC880_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004572 [ALC880_3ST] = "3stack",
4573 [ALC880_TCL_S700] = "tcl",
4574 [ALC880_3ST_DIG] = "3stack-digout",
4575 [ALC880_CLEVO] = "clevo",
4576 [ALC880_5ST] = "5stack",
4577 [ALC880_5ST_DIG] = "5stack-digout",
4578 [ALC880_W810] = "w810",
4579 [ALC880_Z71V] = "z71v",
4580 [ALC880_6ST] = "6stack",
4581 [ALC880_6ST_DIG] = "6stack-digout",
4582 [ALC880_ASUS] = "asus",
4583 [ALC880_ASUS_W1V] = "asus-w1v",
4584 [ALC880_ASUS_DIG] = "asus-dig",
4585 [ALC880_ASUS_DIG2] = "asus-dig2",
4586 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004587 [ALC880_UNIWILL_P53] = "uniwill-p53",
4588 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004589 [ALC880_F1734] = "F1734",
4590 [ALC880_LG] = "lg",
4591 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004592 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004593#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004594 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004595#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004596 [ALC880_AUTO] = "auto",
4597};
4598
4599static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004600 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004601 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4602 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4603 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4604 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4605 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4606 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4607 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4608 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004609 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4610 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004611 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4612 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4613 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4614 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4615 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4616 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4617 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4618 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4619 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4620 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004621 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004622 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4623 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4624 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004625 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004626 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004627 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4628 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004629 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4630 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004631 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4632 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4633 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4634 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004635 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4636 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004637 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004638 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004639 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Justin P. Mattocka2e2bc22011-02-24 22:16:02 -08004640 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004641 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4642 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004643 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004644 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004645 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004646 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004647 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004648 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004649 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004650 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004651 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004652 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
Daniel T Chen77c4d5c2010-12-02 22:45:45 -05004653 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004654 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004655 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004656 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4657 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4658 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4659 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004660 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4661 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004662 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004663 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004664 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4665 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004666 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4667 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4668 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004669 /* default Intel */
4670 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004671 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4672 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004673 {}
4674};
4675
Takashi Iwai16ded522005-06-10 19:58:24 +02004676/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004677 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004678 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004679static struct alc_config_preset alc880_presets[] = {
4680 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004681 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004682 .init_verbs = { alc880_volume_init_verbs,
4683 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004684 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004685 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004686 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4687 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004688 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004689 .input_mux = &alc880_capture_source,
4690 },
4691 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004692 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004693 .init_verbs = { alc880_volume_init_verbs,
4694 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004695 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004696 .dac_nids = alc880_dac_nids,
4697 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004698 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4699 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004700 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004701 .input_mux = &alc880_capture_source,
4702 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004703 [ALC880_TCL_S700] = {
4704 .mixers = { alc880_tcl_s700_mixer },
4705 .init_verbs = { alc880_volume_init_verbs,
4706 alc880_pin_tcl_S700_init_verbs,
4707 alc880_gpio2_init_verbs },
4708 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4709 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004710 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4711 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004712 .hp_nid = 0x03,
4713 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4714 .channel_mode = alc880_2_jack_modes,
4715 .input_mux = &alc880_capture_source,
4716 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004717 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004718 .mixers = { alc880_three_stack_mixer,
4719 alc880_five_stack_mixer},
4720 .init_verbs = { alc880_volume_init_verbs,
4721 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004722 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4723 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004724 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4725 .channel_mode = alc880_fivestack_modes,
4726 .input_mux = &alc880_capture_source,
4727 },
4728 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004729 .mixers = { alc880_three_stack_mixer,
4730 alc880_five_stack_mixer },
4731 .init_verbs = { alc880_volume_init_verbs,
4732 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004733 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4734 .dac_nids = alc880_dac_nids,
4735 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004736 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4737 .channel_mode = alc880_fivestack_modes,
4738 .input_mux = &alc880_capture_source,
4739 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004740 [ALC880_6ST] = {
4741 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004742 .init_verbs = { alc880_volume_init_verbs,
4743 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004744 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4745 .dac_nids = alc880_6st_dac_nids,
4746 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4747 .channel_mode = alc880_sixstack_modes,
4748 .input_mux = &alc880_6stack_capture_source,
4749 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004750 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004751 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004752 .init_verbs = { alc880_volume_init_verbs,
4753 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004754 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4755 .dac_nids = alc880_6st_dac_nids,
4756 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004757 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4758 .channel_mode = alc880_sixstack_modes,
4759 .input_mux = &alc880_6stack_capture_source,
4760 },
4761 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004762 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004763 .init_verbs = { alc880_volume_init_verbs,
4764 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004765 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004766 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4767 .dac_nids = alc880_w810_dac_nids,
4768 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004769 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4770 .channel_mode = alc880_w810_modes,
4771 .input_mux = &alc880_capture_source,
4772 },
4773 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004774 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004775 .init_verbs = { alc880_volume_init_verbs,
4776 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004777 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4778 .dac_nids = alc880_z71v_dac_nids,
4779 .dig_out_nid = ALC880_DIGOUT_NID,
4780 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004781 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4782 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004783 .input_mux = &alc880_capture_source,
4784 },
4785 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004786 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004787 .init_verbs = { alc880_volume_init_verbs,
4788 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004789 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4790 .dac_nids = alc880_f1734_dac_nids,
4791 .hp_nid = 0x02,
4792 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4793 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004794 .input_mux = &alc880_f1734_capture_source,
4795 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004796 .setup = alc880_uniwill_p53_setup,
4797 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004798 },
4799 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004800 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004801 .init_verbs = { alc880_volume_init_verbs,
4802 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004803 alc880_gpio1_init_verbs },
4804 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4805 .dac_nids = alc880_asus_dac_nids,
4806 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4807 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004808 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004809 .input_mux = &alc880_capture_source,
4810 },
4811 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004812 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004813 .init_verbs = { alc880_volume_init_verbs,
4814 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004815 alc880_gpio1_init_verbs },
4816 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4817 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004818 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004819 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4820 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004821 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004822 .input_mux = &alc880_capture_source,
4823 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004824 [ALC880_ASUS_DIG2] = {
4825 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004826 .init_verbs = { alc880_volume_init_verbs,
4827 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004828 alc880_gpio2_init_verbs }, /* use GPIO2 */
4829 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4830 .dac_nids = alc880_asus_dac_nids,
4831 .dig_out_nid = ALC880_DIGOUT_NID,
4832 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4833 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004834 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004835 .input_mux = &alc880_capture_source,
4836 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004837 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004838 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004839 .init_verbs = { alc880_volume_init_verbs,
4840 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004841 alc880_gpio1_init_verbs },
4842 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4843 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004844 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004845 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4846 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004847 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004848 .input_mux = &alc880_capture_source,
4849 },
4850 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004851 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004852 .init_verbs = { alc880_volume_init_verbs,
4853 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004854 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4855 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004856 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004857 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4858 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004859 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004860 .input_mux = &alc880_capture_source,
4861 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004862 [ALC880_UNIWILL] = {
4863 .mixers = { alc880_uniwill_mixer },
4864 .init_verbs = { alc880_volume_init_verbs,
4865 alc880_uniwill_init_verbs },
4866 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4867 .dac_nids = alc880_asus_dac_nids,
4868 .dig_out_nid = ALC880_DIGOUT_NID,
4869 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4870 .channel_mode = alc880_threestack_modes,
4871 .need_dac_fix = 1,
4872 .input_mux = &alc880_capture_source,
4873 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004874 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004875 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004876 },
4877 [ALC880_UNIWILL_P53] = {
4878 .mixers = { alc880_uniwill_p53_mixer },
4879 .init_verbs = { alc880_volume_init_verbs,
4880 alc880_uniwill_p53_init_verbs },
4881 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4882 .dac_nids = alc880_asus_dac_nids,
4883 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004884 .channel_mode = alc880_threestack_modes,
4885 .input_mux = &alc880_capture_source,
4886 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004887 .setup = alc880_uniwill_p53_setup,
4888 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004889 },
4890 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004891 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004892 .init_verbs = { alc880_volume_init_verbs,
4893 alc880_uniwill_p53_init_verbs,
4894 alc880_beep_init_verbs },
4895 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4896 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004897 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004898 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4899 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004900 .input_mux = &alc880_capture_source,
4901 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004902 .setup = alc880_uniwill_p53_setup,
4903 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004904 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004905 [ALC880_CLEVO] = {
4906 .mixers = { alc880_three_stack_mixer },
4907 .init_verbs = { alc880_volume_init_verbs,
4908 alc880_pin_clevo_init_verbs },
4909 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4910 .dac_nids = alc880_dac_nids,
4911 .hp_nid = 0x03,
4912 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4913 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004914 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004915 .input_mux = &alc880_capture_source,
4916 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004917 [ALC880_LG] = {
4918 .mixers = { alc880_lg_mixer },
4919 .init_verbs = { alc880_volume_init_verbs,
4920 alc880_lg_init_verbs },
4921 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4922 .dac_nids = alc880_lg_dac_nids,
4923 .dig_out_nid = ALC880_DIGOUT_NID,
4924 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4925 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004926 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004927 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004928 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004929 .setup = alc880_lg_setup,
4930 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004931#ifdef CONFIG_SND_HDA_POWER_SAVE
4932 .loopbacks = alc880_lg_loopbacks,
4933#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004934 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004935 [ALC880_LG_LW] = {
4936 .mixers = { alc880_lg_lw_mixer },
4937 .init_verbs = { alc880_volume_init_verbs,
4938 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004939 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004940 .dac_nids = alc880_dac_nids,
4941 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004942 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4943 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004944 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004945 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004946 .setup = alc880_lg_lw_setup,
4947 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004948 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004949 [ALC880_MEDION_RIM] = {
4950 .mixers = { alc880_medion_rim_mixer },
4951 .init_verbs = { alc880_volume_init_verbs,
4952 alc880_medion_rim_init_verbs,
4953 alc_gpio2_init_verbs },
4954 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4955 .dac_nids = alc880_dac_nids,
4956 .dig_out_nid = ALC880_DIGOUT_NID,
4957 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4958 .channel_mode = alc880_2_jack_modes,
4959 .input_mux = &alc880_medion_rim_capture_source,
4960 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004961 .setup = alc880_medion_rim_setup,
4962 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004963 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004964#ifdef CONFIG_SND_DEBUG
4965 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004966 .mixers = { alc880_test_mixer },
4967 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004968 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4969 .dac_nids = alc880_test_dac_nids,
4970 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004971 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4972 .channel_mode = alc880_test_modes,
4973 .input_mux = &alc880_test_capture_source,
4974 },
4975#endif
4976};
4977
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004978/*
4979 * Automatic parse of I/O pins from the BIOS configuration
4980 */
4981
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004982enum {
4983 ALC_CTL_WIDGET_VOL,
4984 ALC_CTL_WIDGET_MUTE,
4985 ALC_CTL_BIND_MUTE,
4986};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004987static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004988 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4989 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004990 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004991};
4992
4993/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004994static int add_control(struct alc_spec *spec, int type, const char *name,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004995 int cidx, unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004996{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004997 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004998
Takashi Iwai603c4012008-07-30 15:01:44 +02004999 snd_array_init(&spec->kctls, sizeof(*knew), 32);
5000 knew = snd_array_new(&spec->kctls);
5001 if (!knew)
5002 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005003 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07005004 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005005 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005006 return -ENOMEM;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005007 knew->index = cidx;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01005008 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01005009 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005010 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005011 return 0;
5012}
5013
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005014static int add_control_with_pfx(struct alc_spec *spec, int type,
5015 const char *pfx, const char *dir,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005016 const char *sfx, int cidx, unsigned long val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005017{
5018 char name[32];
5019 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005020 return add_control(spec, type, name, cidx, val);
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005021}
5022
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005023#define add_pb_vol_ctrl(spec, type, pfx, val) \
5024 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
5025#define add_pb_sw_ctrl(spec, type, pfx, val) \
5026 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
5027#define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
5028 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
5029#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
5030 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005031
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005032#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
5033#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
5034#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
5035#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005036#define alc880_idx_to_dac(nid) ((nid) + 0x02)
5037#define alc880_dac_to_idx(nid) ((nid) - 0x02)
5038#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
5039#define alc880_idx_to_selector(nid) ((nid) + 0x10)
5040#define ALC880_PIN_CD_NID 0x1c
5041
5042/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005043static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
5044 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005045{
5046 hda_nid_t nid;
5047 int assigned[4];
5048 int i, j;
5049
5050 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02005051 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005052
5053 /* check the pins hardwired to audio widget */
5054 for (i = 0; i < cfg->line_outs; i++) {
5055 nid = cfg->line_out_pins[i];
5056 if (alc880_is_fixed_pin(nid)) {
5057 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01005058 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005059 assigned[idx] = 1;
5060 }
5061 }
5062 /* left pins can be connect to any audio widget */
5063 for (i = 0; i < cfg->line_outs; i++) {
5064 nid = cfg->line_out_pins[i];
5065 if (alc880_is_fixed_pin(nid))
5066 continue;
5067 /* search for an empty channel */
5068 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005069 if (!assigned[j]) {
5070 spec->multiout.dac_nids[i] =
5071 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005072 assigned[j] = 1;
5073 break;
5074 }
5075 }
5076 }
5077 spec->multiout.num_dacs = cfg->line_outs;
5078 return 0;
5079}
5080
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005081static const char *alc_get_line_out_pfx(const struct auto_pin_cfg *cfg,
5082 bool can_be_master)
5083{
5084 if (!cfg->hp_outs && !cfg->speaker_outs && can_be_master)
5085 return "Master";
5086
5087 switch (cfg->line_out_type) {
5088 case AUTO_PIN_SPEAKER_OUT:
David Henningssonebbeb3d2011-03-04 14:08:30 +01005089 if (cfg->line_outs == 1)
5090 return "Speaker";
5091 break;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005092 case AUTO_PIN_HP_OUT:
5093 return "Headphone";
5094 default:
5095 if (cfg->line_outs == 1)
5096 return "PCM";
5097 break;
5098 }
5099 return NULL;
5100}
5101
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005102/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01005103static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
5104 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005105{
Takashi Iwaiea734962011-01-17 11:29:34 +01005106 static const char * const chname[4] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005107 "Front", "Surround", NULL /*CLFE*/, "Side"
5108 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005109 const char *pfx = alc_get_line_out_pfx(cfg, false);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005110 hda_nid_t nid;
5111 int i, err;
5112
5113 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005114 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005115 continue;
5116 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005117 if (!pfx && i == 2) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005118 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005119 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5120 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005121 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
5122 HDA_OUTPUT));
5123 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005124 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005125 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5126 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005127 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
5128 HDA_OUTPUT));
5129 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005130 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005131 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5132 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005133 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
5134 HDA_INPUT));
5135 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005136 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005137 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5138 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005139 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
5140 HDA_INPUT));
5141 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005142 return err;
5143 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005144 const char *name = pfx;
David Henningsson7e59e092011-03-04 14:22:25 +01005145 int index = i;
5146 if (!name) {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005147 name = chname[i];
David Henningsson7e59e092011-03-04 14:22:25 +01005148 index = 0;
5149 }
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005150 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
David Henningsson7e59e092011-03-04 14:22:25 +01005151 name, index,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005152 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
5153 HDA_OUTPUT));
5154 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005155 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005156 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
David Henningsson7e59e092011-03-04 14:22:25 +01005157 name, index,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005158 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
5159 HDA_INPUT));
5160 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005161 return err;
5162 }
5163 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005164 return 0;
5165}
5166
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005167/* add playback controls for speaker and HP outputs */
5168static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
5169 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005170{
5171 hda_nid_t nid;
5172 int err;
5173
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005174 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005175 return 0;
5176
5177 if (alc880_is_fixed_pin(pin)) {
5178 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01005179 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005180 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005181 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005182 else
5183 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005184 /* control HP volume/switch on the output mixer amp */
5185 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005186 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005187 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
5188 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005189 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005190 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005191 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
5192 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005193 return err;
5194 } else if (alc880_is_multi_pin(pin)) {
5195 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005196 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005197 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005198 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
5199 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005200 return err;
5201 }
5202 return 0;
5203}
5204
5205/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005206static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005207 const char *ctlname, int ctlidx,
Kailang Yangdf694da2005-12-05 19:42:22 +01005208 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005209{
Kailang Yangdf694da2005-12-05 19:42:22 +01005210 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005211
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005212 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005213 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5214 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005215 return err;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005216 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005217 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5218 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005219 return err;
5220 return 0;
5221}
5222
Takashi Iwai05f5f472009-08-25 13:10:18 +02005223static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005224{
Takashi Iwai05f5f472009-08-25 13:10:18 +02005225 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
5226 return (pincap & AC_PINCAP_IN) != 0;
5227}
5228
5229/* create playback/capture controls for input pins */
5230static int alc_auto_create_input_ctls(struct hda_codec *codec,
5231 const struct auto_pin_cfg *cfg,
5232 hda_nid_t mixer,
5233 hda_nid_t cap1, hda_nid_t cap2)
5234{
5235 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005236 struct hda_input_mux *imux = &spec->private_imux[0];
David Henningsson5322bf22011-01-05 11:03:56 +01005237 int i, err, idx, type_idx = 0;
5238 const char *prev_label = NULL;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005239
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005240 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02005241 hda_nid_t pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005242 const char *label;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005243
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005244 pin = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005245 if (!alc_is_input_pin(codec, pin))
5246 continue;
5247
David Henningsson5322bf22011-01-05 11:03:56 +01005248 label = hda_get_autocfg_input_label(codec, cfg, i);
5249 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005250 type_idx++;
5251 else
5252 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +01005253 prev_label = label;
5254
Takashi Iwai05f5f472009-08-25 13:10:18 +02005255 if (mixer) {
5256 idx = get_connection_index(codec, mixer, pin);
5257 if (idx >= 0) {
5258 err = new_analog_input(spec, pin,
Takashi Iwai10a20af2010-09-09 16:28:02 +02005259 label, type_idx,
5260 idx, mixer);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005261 if (err < 0)
5262 return err;
5263 }
5264 }
5265
5266 if (!cap1)
5267 continue;
5268 idx = get_connection_index(codec, cap1, pin);
5269 if (idx < 0 && cap2)
5270 idx = get_connection_index(codec, cap2, pin);
Takashi Iwai10a20af2010-09-09 16:28:02 +02005271 if (idx >= 0)
5272 snd_hda_add_imux_item(imux, label, idx, NULL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005273 }
5274 return 0;
5275}
5276
Takashi Iwai05f5f472009-08-25 13:10:18 +02005277static int alc880_auto_create_input_ctls(struct hda_codec *codec,
5278 const struct auto_pin_cfg *cfg)
5279{
5280 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
5281}
5282
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005283static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
5284 unsigned int pin_type)
5285{
5286 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5287 pin_type);
5288 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01005289 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5290 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005291}
5292
Kailang Yangdf694da2005-12-05 19:42:22 +01005293static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
5294 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005295 int dac_idx)
5296{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005297 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005298 /* need the manual connection? */
5299 if (alc880_is_multi_pin(nid)) {
5300 struct alc_spec *spec = codec->spec;
5301 int idx = alc880_multi_pin_idx(nid);
5302 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
5303 AC_VERB_SET_CONNECT_SEL,
5304 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
5305 }
5306}
5307
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005308static int get_pin_type(int line_out_type)
5309{
5310 if (line_out_type == AUTO_PIN_HP_OUT)
5311 return PIN_HP;
5312 else
5313 return PIN_OUT;
5314}
5315
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005316static void alc880_auto_init_multi_out(struct hda_codec *codec)
5317{
5318 struct alc_spec *spec = codec->spec;
5319 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005320
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005321 for (i = 0; i < spec->autocfg.line_outs; i++) {
5322 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005323 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5324 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005325 }
5326}
5327
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005328static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005329{
5330 struct alc_spec *spec = codec->spec;
5331 hda_nid_t pin;
5332
Takashi Iwai82bc9552006-03-21 11:24:42 +01005333 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005334 if (pin) /* connect to front */
5335 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005336 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005337 if (pin) /* connect to front */
5338 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5339}
5340
5341static void alc880_auto_init_analog_input(struct hda_codec *codec)
5342{
5343 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005344 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005345 int i;
5346
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005347 for (i = 0; i < cfg->num_inputs; i++) {
5348 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005349 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02005350 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005351 if (nid != ALC880_PIN_CD_NID &&
5352 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005353 snd_hda_codec_write(codec, nid, 0,
5354 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005355 AMP_OUT_MUTE);
5356 }
5357 }
5358}
5359
Takashi Iwai7f311a42010-04-09 17:32:23 +02005360static void alc880_auto_init_input_src(struct hda_codec *codec)
5361{
5362 struct alc_spec *spec = codec->spec;
5363 int c;
5364
5365 for (c = 0; c < spec->num_adc_nids; c++) {
5366 unsigned int mux_idx;
5367 const struct hda_input_mux *imux;
5368 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5369 imux = &spec->input_mux[mux_idx];
5370 if (!imux->num_items && mux_idx > 0)
5371 imux = &spec->input_mux[0];
5372 if (imux)
5373 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5374 AC_VERB_SET_CONNECT_SEL,
5375 imux->items[0].index);
5376 }
5377}
5378
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005379/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005380/* return 1 if successful, 0 if the proper config is not found,
5381 * or a negative error code
5382 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005383static int alc880_parse_auto_config(struct hda_codec *codec)
5384{
5385 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005386 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005387 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005388
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005389 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5390 alc880_ignore);
5391 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005392 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005393 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005394 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005395
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005396 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5397 if (err < 0)
5398 return err;
5399 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5400 if (err < 0)
5401 return err;
5402 err = alc880_auto_create_extra_out(spec,
5403 spec->autocfg.speaker_pins[0],
5404 "Speaker");
5405 if (err < 0)
5406 return err;
5407 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5408 "Headphone");
5409 if (err < 0)
5410 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005411 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005412 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005413 return err;
5414
5415 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5416
Takashi Iwai757899a2010-07-30 10:48:14 +02005417 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005418
Takashi Iwai603c4012008-07-30 15:01:44 +02005419 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005420 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005421
Takashi Iwaid88897e2008-10-31 15:01:37 +01005422 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005423
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005424 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005425 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005426
Kailang Yang6227cdc2010-02-25 08:36:52 +01005427 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005428
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005429 return 1;
5430}
5431
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005432/* additional initialization for auto-configuration model */
5433static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005434{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005435 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005436 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005437 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005438 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005439 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005440 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005441 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005442 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005443}
5444
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005445/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5446 * one of two digital mic pins, e.g. on ALC272
5447 */
5448static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005449{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005450 struct alc_spec *spec = codec->spec;
5451 int i;
5452
5453 for (i = 0; i < spec->num_adc_nids; i++) {
5454 hda_nid_t cap = spec->capsrc_nids ?
5455 spec->capsrc_nids[i] : spec->adc_nids[i];
5456 int iidx, eidx;
5457
5458 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5459 if (iidx < 0)
5460 continue;
5461 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5462 if (eidx < 0)
5463 continue;
5464 spec->int_mic.mux_idx = iidx;
5465 spec->ext_mic.mux_idx = eidx;
5466 if (spec->capsrc_nids)
5467 spec->capsrc_nids += i;
5468 spec->adc_nids += i;
5469 spec->num_adc_nids = 1;
5470 return;
5471 }
5472 snd_printd(KERN_INFO "hda_codec: %s: "
5473 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5474 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5475 spec->auto_mic = 0; /* disable auto-mic to be sure */
5476}
5477
Takashi Iwai748cce42010-08-04 07:37:39 +02005478/* select or unmute the given capsrc route */
5479static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5480 int idx)
5481{
5482 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5483 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5484 HDA_AMP_MUTE, 0);
5485 } else {
5486 snd_hda_codec_write_cache(codec, cap, 0,
5487 AC_VERB_SET_CONNECT_SEL, idx);
5488 }
5489}
5490
Takashi Iwai840b64c2010-07-13 22:49:01 +02005491/* set the default connection to that pin */
5492static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5493{
5494 struct alc_spec *spec = codec->spec;
5495 int i;
5496
5497 for (i = 0; i < spec->num_adc_nids; i++) {
5498 hda_nid_t cap = spec->capsrc_nids ?
5499 spec->capsrc_nids[i] : spec->adc_nids[i];
5500 int idx;
5501
5502 idx = get_connection_index(codec, cap, pin);
5503 if (idx < 0)
5504 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005505 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005506 return i; /* return the found index */
5507 }
5508 return -1; /* not found */
5509}
5510
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005511/* choose the ADC/MUX containing the input pin and initialize the setup */
5512static void fixup_single_adc(struct hda_codec *codec)
5513{
5514 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005515 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005516 int i;
5517
5518 /* search for the input pin; there must be only one */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005519 if (cfg->num_inputs != 1)
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005520 return;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005521 i = init_capsrc_for_pin(codec, cfg->inputs[0].pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005522 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005523 /* use only this ADC */
5524 if (spec->capsrc_nids)
5525 spec->capsrc_nids += i;
5526 spec->adc_nids += i;
5527 spec->num_adc_nids = 1;
Takashi Iwai584c0c42011-03-10 12:51:11 +01005528 spec->single_input_src = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005529 }
5530}
5531
Takashi Iwai840b64c2010-07-13 22:49:01 +02005532/* initialize dual adcs */
5533static void fixup_dual_adc_switch(struct hda_codec *codec)
5534{
5535 struct alc_spec *spec = codec->spec;
5536 init_capsrc_for_pin(codec, spec->ext_mic.pin);
5537 init_capsrc_for_pin(codec, spec->int_mic.pin);
5538}
5539
Takashi Iwai584c0c42011-03-10 12:51:11 +01005540/* initialize some special cases for input sources */
5541static void alc_init_special_input_src(struct hda_codec *codec)
5542{
5543 struct alc_spec *spec = codec->spec;
5544 if (spec->dual_adc_switch)
5545 fixup_dual_adc_switch(codec);
5546 else if (spec->single_input_src)
5547 init_capsrc_for_pin(codec, spec->autocfg.inputs[0].pin);
5548}
5549
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005550static void set_capture_mixer(struct hda_codec *codec)
5551{
5552 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005553 static struct snd_kcontrol_new *caps[2][3] = {
5554 { alc_capture_mixer_nosrc1,
5555 alc_capture_mixer_nosrc2,
5556 alc_capture_mixer_nosrc3 },
5557 { alc_capture_mixer1,
5558 alc_capture_mixer2,
5559 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005560 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005561 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005562 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005563 int num_adcs = spec->num_adc_nids;
5564 if (spec->dual_adc_switch)
Takashi Iwai584c0c42011-03-10 12:51:11 +01005565 num_adcs = 1;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005566 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005567 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005568 else if (spec->input_mux) {
5569 if (spec->input_mux->num_items > 1)
5570 mux = 1;
5571 else if (spec->input_mux->num_items == 1)
5572 fixup_single_adc(codec);
5573 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005574 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005575 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005576}
5577
Takashi Iwai66946352010-03-29 17:21:45 +02005578/* fill adc_nids (and capsrc_nids) containing all active input pins */
5579static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5580 int num_nids)
5581{
5582 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005583 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai66946352010-03-29 17:21:45 +02005584 int n;
5585 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5586
5587 for (n = 0; n < num_nids; n++) {
5588 hda_nid_t adc, cap;
5589 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5590 int nconns, i, j;
5591
5592 adc = nids[n];
5593 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5594 continue;
5595 cap = adc;
5596 nconns = snd_hda_get_connections(codec, cap, conn,
5597 ARRAY_SIZE(conn));
5598 if (nconns == 1) {
5599 cap = conn[0];
5600 nconns = snd_hda_get_connections(codec, cap, conn,
5601 ARRAY_SIZE(conn));
5602 }
5603 if (nconns <= 0)
5604 continue;
5605 if (!fallback_adc) {
5606 fallback_adc = adc;
5607 fallback_cap = cap;
5608 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005609 for (i = 0; i < cfg->num_inputs; i++) {
5610 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai66946352010-03-29 17:21:45 +02005611 for (j = 0; j < nconns; j++) {
5612 if (conn[j] == nid)
5613 break;
5614 }
5615 if (j >= nconns)
5616 break;
5617 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005618 if (i >= cfg->num_inputs) {
Takashi Iwai66946352010-03-29 17:21:45 +02005619 int num_adcs = spec->num_adc_nids;
5620 spec->private_adc_nids[num_adcs] = adc;
5621 spec->private_capsrc_nids[num_adcs] = cap;
5622 spec->num_adc_nids++;
5623 spec->adc_nids = spec->private_adc_nids;
5624 if (adc != cap)
5625 spec->capsrc_nids = spec->private_capsrc_nids;
5626 }
5627 }
5628 if (!spec->num_adc_nids) {
5629 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005630 " using fallback 0x%x\n",
5631 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005632 spec->private_adc_nids[0] = fallback_adc;
5633 spec->adc_nids = spec->private_adc_nids;
5634 if (fallback_adc != fallback_cap) {
5635 spec->private_capsrc_nids[0] = fallback_cap;
5636 spec->capsrc_nids = spec->private_adc_nids;
5637 }
5638 }
5639}
5640
Takashi Iwai67d634c2009-11-16 15:35:59 +01005641#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005642#define set_beep_amp(spec, nid, idx, dir) \
5643 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005644
5645static struct snd_pci_quirk beep_white_list[] = {
5646 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005647 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005648 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005649 {}
5650};
5651
5652static inline int has_cdefine_beep(struct hda_codec *codec)
5653{
5654 struct alc_spec *spec = codec->spec;
5655 const struct snd_pci_quirk *q;
5656 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5657 if (q)
5658 return q->value;
5659 return spec->cdefine.enable_pcbeep;
5660}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005661#else
5662#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005663#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005664#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005665
5666/*
5667 * OK, here we have finally the patch for ALC880
5668 */
5669
Linus Torvalds1da177e2005-04-16 15:20:36 -07005670static int patch_alc880(struct hda_codec *codec)
5671{
5672 struct alc_spec *spec;
5673 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005674 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005675
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005676 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005677 if (spec == NULL)
5678 return -ENOMEM;
5679
5680 codec->spec = spec;
5681
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005682 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5683 alc880_models,
5684 alc880_cfg_tbl);
5685 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005686 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5687 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005688 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005689 }
5690
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005691 if (board_config == ALC880_AUTO) {
5692 /* automatic parse from the BIOS config */
5693 err = alc880_parse_auto_config(codec);
5694 if (err < 0) {
5695 alc_free(codec);
5696 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005697 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005698 printk(KERN_INFO
5699 "hda_codec: Cannot set up configuration "
5700 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005701 board_config = ALC880_3ST;
5702 }
5703 }
5704
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005705 err = snd_hda_attach_beep_device(codec, 0x1);
5706 if (err < 0) {
5707 alc_free(codec);
5708 return err;
5709 }
5710
Kailang Yangdf694da2005-12-05 19:42:22 +01005711 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005712 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005713
Linus Torvalds1da177e2005-04-16 15:20:36 -07005714 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5715 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005716 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005717
Linus Torvalds1da177e2005-04-16 15:20:36 -07005718 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5719 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5720
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005721 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005722 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005723 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005724 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005725 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005726 if (wcap != AC_WID_AUD_IN) {
5727 spec->adc_nids = alc880_adc_nids_alt;
5728 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005729 } else {
5730 spec->adc_nids = alc880_adc_nids;
5731 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005732 }
5733 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005734 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005735 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005736
Takashi Iwai2134ea42008-01-10 16:53:55 +01005737 spec->vmaster_nid = 0x0c;
5738
Linus Torvalds1da177e2005-04-16 15:20:36 -07005739 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005740 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005741 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005742#ifdef CONFIG_SND_HDA_POWER_SAVE
5743 if (!spec->loopback.amplist)
5744 spec->loopback.amplist = alc880_loopbacks;
5745#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005746
5747 return 0;
5748}
5749
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005750
Linus Torvalds1da177e2005-04-16 15:20:36 -07005751/*
5752 * ALC260 support
5753 */
5754
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005755static hda_nid_t alc260_dac_nids[1] = {
5756 /* front */
5757 0x02,
5758};
5759
5760static hda_nid_t alc260_adc_nids[1] = {
5761 /* ADC0 */
5762 0x04,
5763};
5764
Kailang Yangdf694da2005-12-05 19:42:22 +01005765static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005766 /* ADC1 */
5767 0x05,
5768};
5769
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005770/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5771 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5772 */
5773static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005774 /* ADC0, ADC1 */
5775 0x04, 0x05
5776};
5777
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005778#define ALC260_DIGOUT_NID 0x03
5779#define ALC260_DIGIN_NID 0x06
5780
5781static struct hda_input_mux alc260_capture_source = {
5782 .num_items = 4,
5783 .items = {
5784 { "Mic", 0x0 },
5785 { "Front Mic", 0x1 },
5786 { "Line", 0x2 },
5787 { "CD", 0x4 },
5788 },
5789};
5790
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005791/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005792 * headphone jack and the internal CD lines since these are the only pins at
5793 * which audio can appear. For flexibility, also allow the option of
5794 * recording the mixer output on the second ADC (ADC0 doesn't have a
5795 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005796 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005797static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5798 {
5799 .num_items = 3,
5800 .items = {
5801 { "Mic/Line", 0x0 },
5802 { "CD", 0x4 },
5803 { "Headphone", 0x2 },
5804 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005805 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005806 {
5807 .num_items = 4,
5808 .items = {
5809 { "Mic/Line", 0x0 },
5810 { "CD", 0x4 },
5811 { "Headphone", 0x2 },
5812 { "Mixer", 0x5 },
5813 },
5814 },
5815
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005816};
5817
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005818/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5819 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005820 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005821static struct hda_input_mux alc260_acer_capture_sources[2] = {
5822 {
5823 .num_items = 4,
5824 .items = {
5825 { "Mic", 0x0 },
5826 { "Line", 0x2 },
5827 { "CD", 0x4 },
5828 { "Headphone", 0x5 },
5829 },
5830 },
5831 {
5832 .num_items = 5,
5833 .items = {
5834 { "Mic", 0x0 },
5835 { "Line", 0x2 },
5836 { "CD", 0x4 },
5837 { "Headphone", 0x6 },
5838 { "Mixer", 0x5 },
5839 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005840 },
5841};
Michael Schwingencc959482009-02-22 18:58:45 +01005842
5843/* Maxdata Favorit 100XS */
5844static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5845 {
5846 .num_items = 2,
5847 .items = {
5848 { "Line/Mic", 0x0 },
5849 { "CD", 0x4 },
5850 },
5851 },
5852 {
5853 .num_items = 3,
5854 .items = {
5855 { "Line/Mic", 0x0 },
5856 { "CD", 0x4 },
5857 { "Mixer", 0x5 },
5858 },
5859 },
5860};
5861
Linus Torvalds1da177e2005-04-16 15:20:36 -07005862/*
5863 * This is just place-holder, so there's something for alc_build_pcms to look
5864 * at when it calculates the maximum number of channels. ALC260 has no mixer
5865 * element which allows changing the channel mode, so the verb list is
5866 * never used.
5867 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005868static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005869 { 2, NULL },
5870};
5871
Kailang Yangdf694da2005-12-05 19:42:22 +01005872
5873/* Mixer combinations
5874 *
5875 * basic: base_output + input + pc_beep + capture
5876 * HP: base_output + input + capture_alt
5877 * HP_3013: hp_3013 + input + capture
5878 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005879 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005880 */
5881
5882static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005883 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005884 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005885 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5886 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5887 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5888 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5889 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005890};
Kailang Yangdf694da2005-12-05 19:42:22 +01005891
5892static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005893 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5894 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5895 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5896 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5897 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5898 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5899 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5900 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005901 { } /* end */
5902};
5903
Takashi Iwaibec15c32008-01-28 18:16:30 +01005904/* update HP, line and mono out pins according to the master switch */
5905static void alc260_hp_master_update(struct hda_codec *codec,
5906 hda_nid_t hp, hda_nid_t line,
5907 hda_nid_t mono)
5908{
5909 struct alc_spec *spec = codec->spec;
5910 unsigned int val = spec->master_sw ? PIN_HP : 0;
5911 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005912 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005913 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005914 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005915 val);
5916 /* mono (speaker) depending on the HP jack sense */
5917 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005918 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005919 val);
5920}
5921
5922static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5923 struct snd_ctl_elem_value *ucontrol)
5924{
5925 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5926 struct alc_spec *spec = codec->spec;
5927 *ucontrol->value.integer.value = spec->master_sw;
5928 return 0;
5929}
5930
5931static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5932 struct snd_ctl_elem_value *ucontrol)
5933{
5934 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5935 struct alc_spec *spec = codec->spec;
5936 int val = !!*ucontrol->value.integer.value;
5937 hda_nid_t hp, line, mono;
5938
5939 if (val == spec->master_sw)
5940 return 0;
5941 spec->master_sw = val;
5942 hp = (kcontrol->private_value >> 16) & 0xff;
5943 line = (kcontrol->private_value >> 8) & 0xff;
5944 mono = kcontrol->private_value & 0xff;
5945 alc260_hp_master_update(codec, hp, line, mono);
5946 return 1;
5947}
5948
5949static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5950 {
5951 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5952 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005953 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005954 .info = snd_ctl_boolean_mono_info,
5955 .get = alc260_hp_master_sw_get,
5956 .put = alc260_hp_master_sw_put,
5957 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5958 },
5959 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5960 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5961 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5962 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5963 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5964 HDA_OUTPUT),
5965 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5966 { } /* end */
5967};
5968
5969static struct hda_verb alc260_hp_unsol_verbs[] = {
5970 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5971 {},
5972};
5973
5974static void alc260_hp_automute(struct hda_codec *codec)
5975{
5976 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005977
Wu Fengguang864f92b2009-11-18 12:38:02 +08005978 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005979 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5980}
5981
5982static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5983{
5984 if ((res >> 26) == ALC880_HP_EVENT)
5985 alc260_hp_automute(codec);
5986}
5987
Kailang Yangdf694da2005-12-05 19:42:22 +01005988static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005989 {
5990 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5991 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005992 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005993 .info = snd_ctl_boolean_mono_info,
5994 .get = alc260_hp_master_sw_get,
5995 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005996 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005997 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005998 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5999 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
6000 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
6001 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
6002 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6003 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01006004 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6005 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02006006 { } /* end */
6007};
6008
Kailang Yang3f878302008-08-26 13:02:23 +02006009static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
6010 .ops = &snd_hda_bind_vol,
6011 .values = {
6012 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
6013 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
6014 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
6015 0
6016 },
6017};
6018
6019static struct hda_bind_ctls alc260_dc7600_bind_switch = {
6020 .ops = &snd_hda_bind_sw,
6021 .values = {
6022 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
6023 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
6024 0
6025 },
6026};
6027
6028static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
6029 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
6030 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
6031 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
6032 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
6033 { } /* end */
6034};
6035
Takashi Iwaibec15c32008-01-28 18:16:30 +01006036static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
6037 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6038 {},
6039};
6040
6041static void alc260_hp_3013_automute(struct hda_codec *codec)
6042{
6043 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006044
Wu Fengguang864f92b2009-11-18 12:38:02 +08006045 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01006046 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01006047}
6048
6049static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
6050 unsigned int res)
6051{
6052 if ((res >> 26) == ALC880_HP_EVENT)
6053 alc260_hp_3013_automute(codec);
6054}
6055
Kailang Yang3f878302008-08-26 13:02:23 +02006056static void alc260_hp_3012_automute(struct hda_codec *codec)
6057{
Wu Fengguang864f92b2009-11-18 12:38:02 +08006058 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02006059
Kailang Yang3f878302008-08-26 13:02:23 +02006060 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6061 bits);
6062 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6063 bits);
6064 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6065 bits);
6066}
6067
6068static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
6069 unsigned int res)
6070{
6071 if ((res >> 26) == ALC880_HP_EVENT)
6072 alc260_hp_3012_automute(codec);
6073}
6074
6075/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006076 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
6077 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006078static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006079 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006080 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006081 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006082 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6083 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6084 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
6085 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006086 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006087 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6088 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006089 { } /* end */
6090};
6091
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006092/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
6093 * versions of the ALC260 don't act on requests to enable mic bias from NID
6094 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
6095 * datasheet doesn't mention this restriction. At this stage it's not clear
6096 * whether this behaviour is intentional or is a hardware bug in chip
6097 * revisions available in early 2006. Therefore for now allow the
6098 * "Headphone Jack Mode" control to span all choices, but if it turns out
6099 * that the lack of mic bias for this NID is intentional we could change the
6100 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6101 *
6102 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
6103 * don't appear to make the mic bias available from the "line" jack, even
6104 * though the NID used for this jack (0x14) can supply it. The theory is
6105 * that perhaps Acer have included blocking capacitors between the ALC260
6106 * and the output jack. If this turns out to be the case for all such
6107 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
6108 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01006109 *
6110 * The C20x Tablet series have a mono internal speaker which is controlled
6111 * via the chip's Mono sum widget and pin complex, so include the necessary
6112 * controls for such models. On models without a "mono speaker" the control
6113 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006114 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006115static struct snd_kcontrol_new alc260_acer_mixer[] = {
6116 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6117 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006118 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006119 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01006120 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006121 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01006122 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006123 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6124 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6125 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6126 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6127 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6128 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6129 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6130 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006131 { } /* end */
6132};
6133
Michael Schwingencc959482009-02-22 18:58:45 +01006134/* Maxdata Favorit 100XS: one output and one input (0x12) jack
6135 */
6136static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
6137 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6138 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
6139 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
6140 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6141 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6142 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6143 { } /* end */
6144};
6145
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006146/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
6147 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
6148 */
6149static struct snd_kcontrol_new alc260_will_mixer[] = {
6150 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6151 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6152 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6153 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6154 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6155 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6156 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6157 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6158 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6159 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006160 { } /* end */
6161};
6162
6163/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
6164 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
6165 */
6166static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
6167 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6168 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6169 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6170 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6171 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6172 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
6173 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
6174 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6175 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6176 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6177 { } /* end */
6178};
6179
Kailang Yangdf694da2005-12-05 19:42:22 +01006180/*
6181 * initialization verbs
6182 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006183static struct hda_verb alc260_init_verbs[] = {
6184 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006185 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006186 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006187 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006188 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006189 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006190 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006191 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006192 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02006193 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006194 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01006195 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006196 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02006197 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006198 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02006199 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006200 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02006201 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6202 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02006203 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006204 /* set connection select to line in (default select for this ADC) */
6205 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02006206 /* mute capture amp left and right */
6207 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6208 /* set connection select to line in (default select for this ADC) */
6209 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02006210 /* set vol=0 Line-Out mixer amp left and right */
6211 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6212 /* unmute pin widget amp left and right (no gain on this amp) */
6213 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6214 /* set vol=0 HP mixer amp left and right */
6215 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6216 /* unmute pin widget amp left and right (no gain on this amp) */
6217 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6218 /* set vol=0 Mono mixer amp left and right */
6219 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6220 /* unmute pin widget amp left and right (no gain on this amp) */
6221 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6222 /* unmute LINE-2 out pin */
6223 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006224 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6225 * Line In 2 = 0x03
6226 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006227 /* mute analog inputs */
6228 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6229 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6230 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6231 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6232 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006233 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006234 /* mute Front out path */
6235 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6236 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6237 /* mute Headphone out path */
6238 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6239 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6240 /* mute Mono out path */
6241 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6242 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006243 { }
6244};
6245
Takashi Iwai474167d2006-05-17 17:17:43 +02006246#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01006247static struct hda_verb alc260_hp_init_verbs[] = {
6248 /* Headphone and output */
6249 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6250 /* mono output */
6251 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6252 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6253 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6254 /* Mic2 (front panel) pin widget for input and vref at 80% */
6255 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6256 /* Line In pin widget for input */
6257 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6258 /* Line-2 pin widget for output */
6259 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6260 /* CD pin widget for input */
6261 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6262 /* unmute amp left and right */
6263 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6264 /* set connection select to line in (default select for this ADC) */
6265 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6266 /* unmute Line-Out mixer amp left and right (volume = 0) */
6267 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6268 /* mute pin widget amp left and right (no gain on this amp) */
6269 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6270 /* unmute HP mixer amp left and right (volume = 0) */
6271 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6272 /* mute pin widget amp left and right (no gain on this amp) */
6273 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006274 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6275 * Line In 2 = 0x03
6276 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006277 /* mute analog inputs */
6278 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6279 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6280 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6281 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6282 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006283 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6284 /* Unmute Front out path */
6285 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6286 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6287 /* Unmute Headphone out path */
6288 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6289 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6290 /* Unmute Mono out path */
6291 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6292 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6293 { }
6294};
Takashi Iwai474167d2006-05-17 17:17:43 +02006295#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006296
6297static struct hda_verb alc260_hp_3013_init_verbs[] = {
6298 /* Line out and output */
6299 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6300 /* mono output */
6301 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6302 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6303 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6304 /* Mic2 (front panel) pin widget for input and vref at 80% */
6305 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6306 /* Line In pin widget for input */
6307 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6308 /* Headphone pin widget for output */
6309 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6310 /* CD pin widget for input */
6311 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6312 /* unmute amp left and right */
6313 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6314 /* set connection select to line in (default select for this ADC) */
6315 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6316 /* unmute Line-Out mixer amp left and right (volume = 0) */
6317 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6318 /* mute pin widget amp left and right (no gain on this amp) */
6319 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6320 /* unmute HP mixer amp left and right (volume = 0) */
6321 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6322 /* mute pin widget amp left and right (no gain on this amp) */
6323 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006324 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6325 * Line In 2 = 0x03
6326 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006327 /* mute analog inputs */
6328 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6329 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6330 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6331 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6332 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006333 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6334 /* Unmute Front out path */
6335 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6336 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6337 /* Unmute Headphone out path */
6338 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6339 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6340 /* Unmute Mono out path */
6341 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6342 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6343 { }
6344};
6345
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006346/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006347 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6348 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006349 */
6350static struct hda_verb alc260_fujitsu_init_verbs[] = {
6351 /* Disable all GPIOs */
6352 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6353 /* Internal speaker is connected to headphone pin */
6354 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6355 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6356 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006357 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6358 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6359 /* Ensure all other unused pins are disabled and muted. */
6360 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6361 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006362 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006363 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006364 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006365 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6366 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6367 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006368
Jonathan Woithef7ace402006-02-28 11:46:14 +01006369 /* Disable digital (SPDIF) pins */
6370 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6371 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006372
Kailang Yangea1fb292008-08-26 12:58:38 +02006373 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006374 * when acting as an output.
6375 */
6376 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6377
6378 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006379 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6380 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6381 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6382 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6383 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6384 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6385 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6386 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6387 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006388
Jonathan Woithef7ace402006-02-28 11:46:14 +01006389 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6390 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6391 /* Unmute Line1 pin widget output buffer since it starts as an output.
6392 * If the pin mode is changed by the user the pin mode control will
6393 * take care of enabling the pin's input/output buffers as needed.
6394 * Therefore there's no need to enable the input buffer at this
6395 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006396 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006397 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006398 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006399 * mixer ctrl)
6400 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006401 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006402
Jonathan Woithef7ace402006-02-28 11:46:14 +01006403 /* Mute capture amp left and right */
6404 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006405 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006406 * in (on mic1 pin)
6407 */
6408 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006409
Jonathan Woithef7ace402006-02-28 11:46:14 +01006410 /* Do the same for the second ADC: mute capture input amp and
6411 * set ADC connection to line in (on mic1 pin)
6412 */
6413 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6414 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006415
Jonathan Woithef7ace402006-02-28 11:46:14 +01006416 /* Mute all inputs to mixer widget (even unconnected ones) */
6417 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6418 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6419 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6420 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6421 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6422 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6423 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6424 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006425
6426 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006427};
6428
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006429/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6430 * similar laptops (adapted from Fujitsu init verbs).
6431 */
6432static struct hda_verb alc260_acer_init_verbs[] = {
6433 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6434 * the headphone jack. Turn this on and rely on the standard mute
6435 * methods whenever the user wants to turn these outputs off.
6436 */
6437 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6438 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6439 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6440 /* Internal speaker/Headphone jack is connected to Line-out pin */
6441 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6442 /* Internal microphone/Mic jack is connected to Mic1 pin */
6443 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6444 /* Line In jack is connected to Line1 pin */
6445 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006446 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6447 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006448 /* Ensure all other unused pins are disabled and muted. */
6449 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6450 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006451 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6452 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6453 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6454 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6455 /* Disable digital (SPDIF) pins */
6456 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6457 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6458
Kailang Yangea1fb292008-08-26 12:58:38 +02006459 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006460 * bus when acting as outputs.
6461 */
6462 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6463 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6464
6465 /* Start with output sum widgets muted and their output gains at min */
6466 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6467 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6468 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6469 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6470 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6471 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6472 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6473 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6474 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6475
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006476 /* Unmute Line-out pin widget amp left and right
6477 * (no equiv mixer ctrl)
6478 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006479 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006480 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6481 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006482 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6483 * inputs. If the pin mode is changed by the user the pin mode control
6484 * will take care of enabling the pin's input/output buffers as needed.
6485 * Therefore there's no need to enable the input buffer at this
6486 * stage.
6487 */
6488 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6489 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6490
6491 /* Mute capture amp left and right */
6492 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6493 /* Set ADC connection select to match default mixer setting - mic
6494 * (on mic1 pin)
6495 */
6496 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6497
6498 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006499 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006500 */
6501 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006502 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006503
6504 /* Mute all inputs to mixer widget (even unconnected ones) */
6505 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6506 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6507 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6508 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6509 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6510 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6511 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6512 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6513
6514 { }
6515};
6516
Michael Schwingencc959482009-02-22 18:58:45 +01006517/* Initialisation sequence for Maxdata Favorit 100XS
6518 * (adapted from Acer init verbs).
6519 */
6520static struct hda_verb alc260_favorit100_init_verbs[] = {
6521 /* GPIO 0 enables the output jack.
6522 * Turn this on and rely on the standard mute
6523 * methods whenever the user wants to turn these outputs off.
6524 */
6525 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6526 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6527 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6528 /* Line/Mic input jack is connected to Mic1 pin */
6529 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6530 /* Ensure all other unused pins are disabled and muted. */
6531 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6532 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6533 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6534 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6535 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6536 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6537 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6538 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6539 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6540 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6541 /* Disable digital (SPDIF) pins */
6542 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6543 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6544
6545 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6546 * bus when acting as outputs.
6547 */
6548 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6549 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6550
6551 /* Start with output sum widgets muted and their output gains at min */
6552 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6553 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6554 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6555 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6556 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6557 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6558 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6559 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6560 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6561
6562 /* Unmute Line-out pin widget amp left and right
6563 * (no equiv mixer ctrl)
6564 */
6565 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6566 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6567 * inputs. If the pin mode is changed by the user the pin mode control
6568 * will take care of enabling the pin's input/output buffers as needed.
6569 * Therefore there's no need to enable the input buffer at this
6570 * stage.
6571 */
6572 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6573
6574 /* Mute capture amp left and right */
6575 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6576 /* Set ADC connection select to match default mixer setting - mic
6577 * (on mic1 pin)
6578 */
6579 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6580
6581 /* Do similar with the second ADC: mute capture input amp and
6582 * set ADC connection to mic to match ALSA's default state.
6583 */
6584 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6585 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6586
6587 /* Mute all inputs to mixer widget (even unconnected ones) */
6588 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6589 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6590 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6591 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6592 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6593 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6594 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6595 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6596
6597 { }
6598};
6599
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006600static struct hda_verb alc260_will_verbs[] = {
6601 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6602 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6603 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6604 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6605 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6606 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6607 {}
6608};
6609
6610static struct hda_verb alc260_replacer_672v_verbs[] = {
6611 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6612 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6613 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6614
6615 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6616 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6617 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6618
6619 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6620 {}
6621};
6622
6623/* toggle speaker-output according to the hp-jack state */
6624static void alc260_replacer_672v_automute(struct hda_codec *codec)
6625{
6626 unsigned int present;
6627
6628 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006629 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006630 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006631 snd_hda_codec_write_cache(codec, 0x01, 0,
6632 AC_VERB_SET_GPIO_DATA, 1);
6633 snd_hda_codec_write_cache(codec, 0x0f, 0,
6634 AC_VERB_SET_PIN_WIDGET_CONTROL,
6635 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006636 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006637 snd_hda_codec_write_cache(codec, 0x01, 0,
6638 AC_VERB_SET_GPIO_DATA, 0);
6639 snd_hda_codec_write_cache(codec, 0x0f, 0,
6640 AC_VERB_SET_PIN_WIDGET_CONTROL,
6641 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006642 }
6643}
6644
6645static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6646 unsigned int res)
6647{
6648 if ((res >> 26) == ALC880_HP_EVENT)
6649 alc260_replacer_672v_automute(codec);
6650}
6651
Kailang Yang3f878302008-08-26 13:02:23 +02006652static struct hda_verb alc260_hp_dc7600_verbs[] = {
6653 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6654 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6655 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6656 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6657 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6658 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6659 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6660 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6661 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6662 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6663 {}
6664};
6665
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006666/* Test configuration for debugging, modelled after the ALC880 test
6667 * configuration.
6668 */
6669#ifdef CONFIG_SND_DEBUG
6670static hda_nid_t alc260_test_dac_nids[1] = {
6671 0x02,
6672};
6673static hda_nid_t alc260_test_adc_nids[2] = {
6674 0x04, 0x05,
6675};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006676/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006677 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006678 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006679 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006680static struct hda_input_mux alc260_test_capture_sources[2] = {
6681 {
6682 .num_items = 7,
6683 .items = {
6684 { "MIC1 pin", 0x0 },
6685 { "MIC2 pin", 0x1 },
6686 { "LINE1 pin", 0x2 },
6687 { "LINE2 pin", 0x3 },
6688 { "CD pin", 0x4 },
6689 { "LINE-OUT pin", 0x5 },
6690 { "HP-OUT pin", 0x6 },
6691 },
6692 },
6693 {
6694 .num_items = 8,
6695 .items = {
6696 { "MIC1 pin", 0x0 },
6697 { "MIC2 pin", 0x1 },
6698 { "LINE1 pin", 0x2 },
6699 { "LINE2 pin", 0x3 },
6700 { "CD pin", 0x4 },
6701 { "Mixer", 0x5 },
6702 { "LINE-OUT pin", 0x6 },
6703 { "HP-OUT pin", 0x7 },
6704 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006705 },
6706};
6707static struct snd_kcontrol_new alc260_test_mixer[] = {
6708 /* Output driver widgets */
6709 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6710 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6711 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6712 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6713 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6714 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6715
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006716 /* Modes for retasking pin widgets
6717 * Note: the ALC260 doesn't seem to act on requests to enable mic
6718 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6719 * mention this restriction. At this stage it's not clear whether
6720 * this behaviour is intentional or is a hardware bug in chip
6721 * revisions available at least up until early 2006. Therefore for
6722 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6723 * choices, but if it turns out that the lack of mic bias for these
6724 * NIDs is intentional we could change their modes from
6725 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6726 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006727 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6728 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6729 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6730 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6731 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6732 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6733
6734 /* Loopback mixer controls */
6735 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6736 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6737 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6738 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6739 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6740 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6741 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6742 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6743 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6744 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006745 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6746 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6747 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6748 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006749
6750 /* Controls for GPIO pins, assuming they are configured as outputs */
6751 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6752 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6753 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6754 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6755
Jonathan Woithe92621f12006-02-28 11:47:47 +01006756 /* Switches to allow the digital IO pins to be enabled. The datasheet
6757 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006758 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006759 */
6760 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6761 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6762
Jonathan Woithef8225f62008-01-08 12:16:54 +01006763 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6764 * this output to turn on an external amplifier.
6765 */
6766 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6767 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6768
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006769 { } /* end */
6770};
6771static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006772 /* Enable all GPIOs as outputs with an initial value of 0 */
6773 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6774 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6775 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6776
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006777 /* Enable retasking pins as output, initially without power amp */
6778 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6779 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6780 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6781 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6782 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6783 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6784
Jonathan Woithe92621f12006-02-28 11:47:47 +01006785 /* Disable digital (SPDIF) pins initially, but users can enable
6786 * them via a mixer switch. In the case of SPDIF-out, this initverb
6787 * payload also sets the generation to 0, output to be in "consumer"
6788 * PCM format, copyright asserted, no pre-emphasis and no validity
6789 * control.
6790 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006791 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6792 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6793
Kailang Yangea1fb292008-08-26 12:58:38 +02006794 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006795 * OUT1 sum bus when acting as an output.
6796 */
6797 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6798 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6799 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6800 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6801
6802 /* Start with output sum widgets muted and their output gains at min */
6803 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6804 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6805 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6806 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6807 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6808 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6809 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6810 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6811 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6812
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006813 /* Unmute retasking pin widget output buffers since the default
6814 * state appears to be output. As the pin mode is changed by the
6815 * user the pin mode control will take care of enabling the pin's
6816 * input/output buffers as needed.
6817 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006818 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6819 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6820 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6821 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6822 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6823 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6824 /* Also unmute the mono-out pin widget */
6825 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6826
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006827 /* Mute capture amp left and right */
6828 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006829 /* Set ADC connection select to match default mixer setting (mic1
6830 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006831 */
6832 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6833
6834 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006835 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006836 */
6837 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6838 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6839
6840 /* Mute all inputs to mixer widget (even unconnected ones) */
6841 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6842 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6843 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6844 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6845 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6846 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6847 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6848 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6849
6850 { }
6851};
6852#endif
6853
Takashi Iwai63300792008-01-24 15:31:36 +01006854#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6855#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006856
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006857#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6858#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6859
Kailang Yangdf694da2005-12-05 19:42:22 +01006860/*
6861 * for BIOS auto-configuration
6862 */
6863
6864static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006865 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006866{
6867 hda_nid_t nid_vol;
6868 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006869 int err;
6870
6871 if (nid >= 0x0f && nid < 0x11) {
6872 nid_vol = nid - 0x7;
6873 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6874 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6875 } else if (nid == 0x11) {
6876 nid_vol = nid - 0x7;
6877 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6878 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6879 } else if (nid >= 0x12 && nid <= 0x15) {
6880 nid_vol = 0x08;
6881 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6882 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6883 } else
6884 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006885
Takashi Iwai863b4512008-10-21 17:01:47 +02006886 if (!(*vol_bits & (1 << nid_vol))) {
6887 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006888 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006889 if (err < 0)
6890 return err;
6891 *vol_bits |= (1 << nid_vol);
6892 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006893 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006894 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006895 return err;
6896 return 1;
6897}
6898
6899/* add playback controls from the parsed DAC table */
6900static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6901 const struct auto_pin_cfg *cfg)
6902{
6903 hda_nid_t nid;
6904 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006905 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006906
6907 spec->multiout.num_dacs = 1;
6908 spec->multiout.dac_nids = spec->private_dac_nids;
6909 spec->multiout.dac_nids[0] = 0x02;
6910
6911 nid = cfg->line_out_pins[0];
6912 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006913 const char *pfx;
6914 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6915 pfx = "Master";
6916 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6917 pfx = "Speaker";
6918 else
6919 pfx = "Front";
6920 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006921 if (err < 0)
6922 return err;
6923 }
6924
Takashi Iwai82bc9552006-03-21 11:24:42 +01006925 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006926 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006927 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006928 if (err < 0)
6929 return err;
6930 }
6931
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006932 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006933 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006934 err = alc260_add_playback_controls(spec, nid, "Headphone",
6935 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006936 if (err < 0)
6937 return err;
6938 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006939 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006940}
6941
6942/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006943static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006944 const struct auto_pin_cfg *cfg)
6945{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006946 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006947}
6948
6949static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6950 hda_nid_t nid, int pin_type,
6951 int sel_idx)
6952{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006953 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006954 /* need the manual connection? */
6955 if (nid >= 0x12) {
6956 int idx = nid - 0x12;
6957 snd_hda_codec_write(codec, idx + 0x0b, 0,
6958 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006959 }
6960}
6961
6962static void alc260_auto_init_multi_out(struct hda_codec *codec)
6963{
6964 struct alc_spec *spec = codec->spec;
6965 hda_nid_t nid;
6966
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006967 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006968 if (nid) {
6969 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6970 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6971 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006972
Takashi Iwai82bc9552006-03-21 11:24:42 +01006973 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006974 if (nid)
6975 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6976
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006977 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006978 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006979 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006980}
Kailang Yangdf694da2005-12-05 19:42:22 +01006981
6982#define ALC260_PIN_CD_NID 0x16
6983static void alc260_auto_init_analog_input(struct hda_codec *codec)
6984{
6985 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006986 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +01006987 int i;
6988
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006989 for (i = 0; i < cfg->num_inputs; i++) {
6990 hda_nid_t nid = cfg->inputs[i].pin;
Kailang Yangdf694da2005-12-05 19:42:22 +01006991 if (nid >= 0x12) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02006992 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006993 if (nid != ALC260_PIN_CD_NID &&
6994 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006995 snd_hda_codec_write(codec, nid, 0,
6996 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006997 AMP_OUT_MUTE);
6998 }
6999 }
7000}
7001
Takashi Iwai7f311a42010-04-09 17:32:23 +02007002#define alc260_auto_init_input_src alc880_auto_init_input_src
7003
Kailang Yangdf694da2005-12-05 19:42:22 +01007004/*
7005 * generic initialization of ADC, input mixers and output mixers
7006 */
7007static struct hda_verb alc260_volume_init_verbs[] = {
7008 /*
7009 * Unmute ADC0-1 and set the default input to mic-in
7010 */
7011 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
7012 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7013 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
7014 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02007015
Kailang Yangdf694da2005-12-05 19:42:22 +01007016 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7017 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007018 * Note: PASD motherboards uses the Line In 2 as the input for
7019 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007020 */
7021 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007022 /* mute analog inputs */
7023 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7024 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7025 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7026 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7027 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007028
7029 /*
7030 * Set up output mixers (0x08 - 0x0a)
7031 */
7032 /* set vol=0 to output mixers */
7033 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7034 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7035 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7036 /* set up input amps for analog loopback */
7037 /* Amp Indices: DAC = 0, mixer = 1 */
7038 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7039 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7040 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7041 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7042 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7043 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02007044
Kailang Yangdf694da2005-12-05 19:42:22 +01007045 { }
7046};
7047
7048static int alc260_parse_auto_config(struct hda_codec *codec)
7049{
7050 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007051 int err;
7052 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
7053
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007054 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7055 alc260_ignore);
7056 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007057 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007058 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
7059 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01007060 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02007061 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01007062 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02007063 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007064 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007065 return err;
7066
7067 spec->multiout.max_channels = 2;
7068
Takashi Iwai0852d7a2009-02-11 11:35:15 +01007069 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007070 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02007071 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01007072 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01007073
Takashi Iwaid88897e2008-10-31 15:01:37 +01007074 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01007075
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007076 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007077 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007078
Kailang Yang6227cdc2010-02-25 08:36:52 +01007079 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02007080
Kailang Yangdf694da2005-12-05 19:42:22 +01007081 return 1;
7082}
7083
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007084/* additional initialization for auto-configuration model */
7085static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007086{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007087 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007088 alc260_auto_init_multi_out(codec);
7089 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02007090 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02007091 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007092 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007093 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007094}
7095
Takashi Iwaicb53c622007-08-10 17:21:45 +02007096#ifdef CONFIG_SND_HDA_POWER_SAVE
7097static struct hda_amp_list alc260_loopbacks[] = {
7098 { 0x07, HDA_INPUT, 0 },
7099 { 0x07, HDA_INPUT, 1 },
7100 { 0x07, HDA_INPUT, 2 },
7101 { 0x07, HDA_INPUT, 3 },
7102 { 0x07, HDA_INPUT, 4 },
7103 { } /* end */
7104};
7105#endif
7106
Kailang Yangdf694da2005-12-05 19:42:22 +01007107/*
Takashi Iwaifc091762010-08-04 23:53:36 +02007108 * Pin config fixes
7109 */
7110enum {
7111 PINFIX_HP_DC5750,
7112};
7113
Takashi Iwaifc091762010-08-04 23:53:36 +02007114static const struct alc_fixup alc260_fixups[] = {
7115 [PINFIX_HP_DC5750] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007116 .type = ALC_FIXUP_PINS,
7117 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +02007118 { 0x11, 0x90130110 }, /* speaker */
7119 { }
7120 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007121 },
7122};
7123
7124static struct snd_pci_quirk alc260_fixup_tbl[] = {
7125 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
7126 {}
7127};
7128
7129/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007130 * ALC260 configurations
7131 */
Takashi Iwaiea734962011-01-17 11:29:34 +01007132static const char * const alc260_models[ALC260_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007133 [ALC260_BASIC] = "basic",
7134 [ALC260_HP] = "hp",
7135 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02007136 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007137 [ALC260_FUJITSU_S702X] = "fujitsu",
7138 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007139 [ALC260_WILL] = "will",
7140 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01007141 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007142#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007143 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007144#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007145 [ALC260_AUTO] = "auto",
7146};
7147
7148static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01007149 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05007150 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007151 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01007152 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01007153 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01007154 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007155 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02007156 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02007157 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007158 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
7159 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
7160 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
7161 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
7162 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
7163 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
7164 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
7165 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
7166 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007167 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007168 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02007169 {}
7170};
7171
Kailang Yangdf694da2005-12-05 19:42:22 +01007172static struct alc_config_preset alc260_presets[] = {
7173 [ALC260_BASIC] = {
7174 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007175 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007176 .init_verbs = { alc260_init_verbs },
7177 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7178 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007179 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01007180 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007181 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7182 .channel_mode = alc260_modes,
7183 .input_mux = &alc260_capture_source,
7184 },
7185 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01007186 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007187 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007188 .init_verbs = { alc260_init_verbs,
7189 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007190 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7191 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007192 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7193 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007194 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7195 .channel_mode = alc260_modes,
7196 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007197 .unsol_event = alc260_hp_unsol_event,
7198 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007199 },
Kailang Yang3f878302008-08-26 13:02:23 +02007200 [ALC260_HP_DC7600] = {
7201 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007202 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02007203 .init_verbs = { alc260_init_verbs,
7204 alc260_hp_dc7600_verbs },
7205 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7206 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007207 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7208 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02007209 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7210 .channel_mode = alc260_modes,
7211 .input_mux = &alc260_capture_source,
7212 .unsol_event = alc260_hp_3012_unsol_event,
7213 .init_hook = alc260_hp_3012_automute,
7214 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007215 [ALC260_HP_3013] = {
7216 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007217 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007218 .init_verbs = { alc260_hp_3013_init_verbs,
7219 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007220 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7221 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007222 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7223 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007224 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7225 .channel_mode = alc260_modes,
7226 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007227 .unsol_event = alc260_hp_3013_unsol_event,
7228 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007229 },
7230 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007231 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007232 .init_verbs = { alc260_fujitsu_init_verbs },
7233 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7234 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01007235 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7236 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007237 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7238 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007239 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
7240 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01007241 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007242 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007243 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007244 .init_verbs = { alc260_acer_init_verbs },
7245 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7246 .dac_nids = alc260_dac_nids,
7247 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7248 .adc_nids = alc260_dual_adc_nids,
7249 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7250 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007251 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
7252 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007253 },
Michael Schwingencc959482009-02-22 18:58:45 +01007254 [ALC260_FAVORIT100] = {
7255 .mixers = { alc260_favorit100_mixer },
7256 .init_verbs = { alc260_favorit100_init_verbs },
7257 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7258 .dac_nids = alc260_dac_nids,
7259 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7260 .adc_nids = alc260_dual_adc_nids,
7261 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7262 .channel_mode = alc260_modes,
7263 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
7264 .input_mux = alc260_favorit100_capture_sources,
7265 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007266 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007267 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007268 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
7269 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7270 .dac_nids = alc260_dac_nids,
7271 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7272 .adc_nids = alc260_adc_nids,
7273 .dig_out_nid = ALC260_DIGOUT_NID,
7274 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7275 .channel_mode = alc260_modes,
7276 .input_mux = &alc260_capture_source,
7277 },
7278 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007279 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007280 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
7281 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7282 .dac_nids = alc260_dac_nids,
7283 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7284 .adc_nids = alc260_adc_nids,
7285 .dig_out_nid = ALC260_DIGOUT_NID,
7286 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7287 .channel_mode = alc260_modes,
7288 .input_mux = &alc260_capture_source,
7289 .unsol_event = alc260_replacer_672v_unsol_event,
7290 .init_hook = alc260_replacer_672v_automute,
7291 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007292#ifdef CONFIG_SND_DEBUG
7293 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007294 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007295 .init_verbs = { alc260_test_init_verbs },
7296 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
7297 .dac_nids = alc260_test_dac_nids,
7298 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
7299 .adc_nids = alc260_test_adc_nids,
7300 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7301 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007302 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7303 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007304 },
7305#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007306};
7307
Linus Torvalds1da177e2005-04-16 15:20:36 -07007308static int patch_alc260(struct hda_codec *codec)
7309{
7310 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007311 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007312
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007313 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007314 if (spec == NULL)
7315 return -ENOMEM;
7316
7317 codec->spec = spec;
7318
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007319 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7320 alc260_models,
7321 alc260_cfg_tbl);
7322 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007323 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007324 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007325 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007326 }
7327
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007328 if (board_config == ALC260_AUTO) {
7329 alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups);
7330 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
7331 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007332
Kailang Yangdf694da2005-12-05 19:42:22 +01007333 if (board_config == ALC260_AUTO) {
7334 /* automatic parse from the BIOS config */
7335 err = alc260_parse_auto_config(codec);
7336 if (err < 0) {
7337 alc_free(codec);
7338 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007339 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007340 printk(KERN_INFO
7341 "hda_codec: Cannot set up configuration "
7342 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007343 board_config = ALC260_BASIC;
7344 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007345 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007346
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007347 err = snd_hda_attach_beep_device(codec, 0x1);
7348 if (err < 0) {
7349 alc_free(codec);
7350 return err;
7351 }
7352
Kailang Yangdf694da2005-12-05 19:42:22 +01007353 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007354 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007355
Linus Torvalds1da177e2005-04-16 15:20:36 -07007356 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7357 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307358 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007359
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007360 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7361 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7362
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007363 if (!spec->adc_nids && spec->input_mux) {
7364 /* check whether NID 0x04 is valid */
7365 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007366 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007367 /* get type */
7368 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7369 spec->adc_nids = alc260_adc_nids_alt;
7370 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7371 } else {
7372 spec->adc_nids = alc260_adc_nids;
7373 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7374 }
7375 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007376 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007377 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007378
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007379 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaifc091762010-08-04 23:53:36 +02007380
Takashi Iwai2134ea42008-01-10 16:53:55 +01007381 spec->vmaster_nid = 0x08;
7382
Linus Torvalds1da177e2005-04-16 15:20:36 -07007383 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007384 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007385 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007386#ifdef CONFIG_SND_HDA_POWER_SAVE
7387 if (!spec->loopback.amplist)
7388 spec->loopback.amplist = alc260_loopbacks;
7389#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007390
7391 return 0;
7392}
7393
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007394
Linus Torvalds1da177e2005-04-16 15:20:36 -07007395/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007396 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007397 *
7398 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7399 * configuration. Each pin widget can choose any input DACs and a mixer.
7400 * Each ADC is connected from a mixer of all inputs. This makes possible
7401 * 6-channel independent captures.
7402 *
7403 * In addition, an independent DAC for the multi-playback (not used in this
7404 * driver yet).
7405 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007406#define ALC882_DIGOUT_NID 0x06
7407#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007408#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7409#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7410#define ALC1200_DIGOUT_NID 0x10
7411
Linus Torvalds1da177e2005-04-16 15:20:36 -07007412
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007413static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007414 { 8, NULL }
7415};
7416
Takashi Iwai4953550a2009-06-30 15:28:30 +02007417/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007418static hda_nid_t alc882_dac_nids[4] = {
7419 /* front, rear, clfe, rear_surr */
7420 0x02, 0x03, 0x04, 0x05
7421};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007422#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007423
Takashi Iwai4953550a2009-06-30 15:28:30 +02007424/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007425#define alc882_adc_nids alc880_adc_nids
7426#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007427#define alc883_adc_nids alc882_adc_nids_alt
7428static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7429static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7430#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007431
Takashi Iwaie1406342008-02-11 18:32:32 +01007432static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7433static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007434#define alc883_capsrc_nids alc882_capsrc_nids_alt
7435static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7436#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007437
Linus Torvalds1da177e2005-04-16 15:20:36 -07007438/* input MUX */
7439/* FIXME: should be a matrix-type input source selection */
7440
7441static struct hda_input_mux alc882_capture_source = {
7442 .num_items = 4,
7443 .items = {
7444 { "Mic", 0x0 },
7445 { "Front Mic", 0x1 },
7446 { "Line", 0x2 },
7447 { "CD", 0x4 },
7448 },
7449};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007450
Takashi Iwai4953550a2009-06-30 15:28:30 +02007451#define alc883_capture_source alc882_capture_source
7452
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007453static struct hda_input_mux alc889_capture_source = {
7454 .num_items = 3,
7455 .items = {
7456 { "Front Mic", 0x0 },
7457 { "Mic", 0x3 },
7458 { "Line", 0x2 },
7459 },
7460};
7461
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007462static struct hda_input_mux mb5_capture_source = {
7463 .num_items = 3,
7464 .items = {
7465 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307466 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007467 { "CD", 0x4 },
7468 },
7469};
7470
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007471static struct hda_input_mux macmini3_capture_source = {
7472 .num_items = 2,
7473 .items = {
7474 { "Line", 0x2 },
7475 { "CD", 0x4 },
7476 },
7477};
7478
Takashi Iwai4953550a2009-06-30 15:28:30 +02007479static struct hda_input_mux alc883_3stack_6ch_intel = {
7480 .num_items = 4,
7481 .items = {
7482 { "Mic", 0x1 },
7483 { "Front Mic", 0x0 },
7484 { "Line", 0x2 },
7485 { "CD", 0x4 },
7486 },
7487};
7488
7489static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7490 .num_items = 2,
7491 .items = {
7492 { "Mic", 0x1 },
7493 { "Line", 0x2 },
7494 },
7495};
7496
7497static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7498 .num_items = 4,
7499 .items = {
7500 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007501 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007502 { "Line", 0x2 },
7503 { "CD", 0x4 },
7504 },
7505};
7506
7507static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7508 .num_items = 2,
7509 .items = {
7510 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007511 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007512 },
7513};
7514
7515static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7516 .num_items = 3,
7517 .items = {
7518 { "Mic", 0x0 },
7519 { "Front Mic", 0x1 },
7520 { "Line", 0x4 },
7521 },
7522};
7523
7524static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7525 .num_items = 2,
7526 .items = {
7527 { "Mic", 0x0 },
7528 { "Line", 0x2 },
7529 },
7530};
7531
7532static struct hda_input_mux alc889A_mb31_capture_source = {
7533 .num_items = 2,
7534 .items = {
7535 { "Mic", 0x0 },
7536 /* Front Mic (0x01) unused */
7537 { "Line", 0x2 },
7538 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007539 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007540 },
7541};
7542
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007543static struct hda_input_mux alc889A_imac91_capture_source = {
7544 .num_items = 2,
7545 .items = {
7546 { "Mic", 0x01 },
7547 { "Line", 0x2 }, /* Not sure! */
7548 },
7549};
7550
Takashi Iwai4953550a2009-06-30 15:28:30 +02007551/*
7552 * 2ch mode
7553 */
7554static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7555 { 2, NULL }
7556};
7557
Kailang Yangdf694da2005-12-05 19:42:22 +01007558/*
Kailang Yang272a5272007-05-14 11:00:38 +02007559 * 2ch mode
7560 */
7561static struct hda_verb alc882_3ST_ch2_init[] = {
7562 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7563 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7564 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7565 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7566 { } /* end */
7567};
7568
7569/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007570 * 4ch mode
7571 */
7572static struct hda_verb alc882_3ST_ch4_init[] = {
7573 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7574 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7575 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7576 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7577 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7578 { } /* end */
7579};
7580
7581/*
Kailang Yang272a5272007-05-14 11:00:38 +02007582 * 6ch mode
7583 */
7584static struct hda_verb alc882_3ST_ch6_init[] = {
7585 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7586 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7587 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7588 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7589 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7590 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7591 { } /* end */
7592};
7593
Takashi Iwai4953550a2009-06-30 15:28:30 +02007594static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007595 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007596 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007597 { 6, alc882_3ST_ch6_init },
7598};
7599
Takashi Iwai4953550a2009-06-30 15:28:30 +02007600#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7601
Kailang Yang272a5272007-05-14 11:00:38 +02007602/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307603 * 2ch mode
7604 */
7605static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7606 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7607 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7608 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7609 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7610 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7611 { } /* end */
7612};
7613
7614/*
7615 * 4ch mode
7616 */
7617static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7618 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7619 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7620 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7621 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7622 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7623 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7624 { } /* end */
7625};
7626
7627/*
7628 * 6ch mode
7629 */
7630static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7631 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7632 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7633 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7634 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7635 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7636 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7637 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7638 { } /* end */
7639};
7640
7641static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7642 { 2, alc883_3ST_ch2_clevo_init },
7643 { 4, alc883_3ST_ch4_clevo_init },
7644 { 6, alc883_3ST_ch6_clevo_init },
7645};
7646
7647
7648/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007649 * 6ch mode
7650 */
7651static struct hda_verb alc882_sixstack_ch6_init[] = {
7652 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7653 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7654 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7655 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7656 { } /* end */
7657};
7658
7659/*
7660 * 8ch mode
7661 */
7662static struct hda_verb alc882_sixstack_ch8_init[] = {
7663 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7664 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7665 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7666 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7667 { } /* end */
7668};
7669
7670static struct hda_channel_mode alc882_sixstack_modes[2] = {
7671 { 6, alc882_sixstack_ch6_init },
7672 { 8, alc882_sixstack_ch8_init },
7673};
7674
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007675
7676/* Macbook Air 2,1 */
7677
7678static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7679 { 2, NULL },
7680};
7681
Takashi Iwai87350ad2007-08-16 18:19:38 +02007682/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007683 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007684 */
7685
7686/*
7687 * 2ch mode
7688 */
7689static struct hda_verb alc885_mbp_ch2_init[] = {
7690 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7691 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7692 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7693 { } /* end */
7694};
7695
7696/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007697 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007698 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007699static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007700 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7701 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7702 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7703 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7704 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7705 { } /* end */
7706};
7707
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007708static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007709 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007710 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007711};
7712
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007713/*
7714 * 2ch
7715 * Speakers/Woofer/HP = Front
7716 * LineIn = Input
7717 */
7718static struct hda_verb alc885_mb5_ch2_init[] = {
7719 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7720 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7721 { } /* end */
7722};
7723
7724/*
7725 * 6ch mode
7726 * Speakers/HP = Front
7727 * Woofer = LFE
7728 * LineIn = Surround
7729 */
7730static struct hda_verb alc885_mb5_ch6_init[] = {
7731 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7732 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7733 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7734 { } /* end */
7735};
7736
7737static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7738 { 2, alc885_mb5_ch2_init },
7739 { 6, alc885_mb5_ch6_init },
7740};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007741
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007742#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007743
7744/*
7745 * 2ch mode
7746 */
7747static struct hda_verb alc883_4ST_ch2_init[] = {
7748 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7749 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7750 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7751 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7752 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7753 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7754 { } /* end */
7755};
7756
7757/*
7758 * 4ch mode
7759 */
7760static struct hda_verb alc883_4ST_ch4_init[] = {
7761 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7762 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7763 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7764 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7765 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7766 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7767 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7768 { } /* end */
7769};
7770
7771/*
7772 * 6ch mode
7773 */
7774static struct hda_verb alc883_4ST_ch6_init[] = {
7775 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7776 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7777 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7778 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7779 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7780 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7781 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7782 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7783 { } /* end */
7784};
7785
7786/*
7787 * 8ch mode
7788 */
7789static struct hda_verb alc883_4ST_ch8_init[] = {
7790 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7791 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7792 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7793 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7794 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7795 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7796 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7797 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7798 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7799 { } /* end */
7800};
7801
7802static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7803 { 2, alc883_4ST_ch2_init },
7804 { 4, alc883_4ST_ch4_init },
7805 { 6, alc883_4ST_ch6_init },
7806 { 8, alc883_4ST_ch8_init },
7807};
7808
7809
7810/*
7811 * 2ch mode
7812 */
7813static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7814 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7815 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7816 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7817 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7818 { } /* end */
7819};
7820
7821/*
7822 * 4ch mode
7823 */
7824static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7825 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7826 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7827 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7828 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7829 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7830 { } /* end */
7831};
7832
7833/*
7834 * 6ch mode
7835 */
7836static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7837 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7838 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7839 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7840 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7841 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7842 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7843 { } /* end */
7844};
7845
7846static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7847 { 2, alc883_3ST_ch2_intel_init },
7848 { 4, alc883_3ST_ch4_intel_init },
7849 { 6, alc883_3ST_ch6_intel_init },
7850};
7851
7852/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007853 * 2ch mode
7854 */
7855static struct hda_verb alc889_ch2_intel_init[] = {
7856 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7857 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7858 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7859 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7860 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7861 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7862 { } /* end */
7863};
7864
7865/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007866 * 6ch mode
7867 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007868static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007869 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7870 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7871 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7872 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7873 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007874 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7875 { } /* end */
7876};
7877
7878/*
7879 * 8ch mode
7880 */
7881static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007882 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7883 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7884 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7885 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7886 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007887 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7888 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007889 { } /* end */
7890};
7891
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007892static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7893 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007894 { 6, alc889_ch6_intel_init },
7895 { 8, alc889_ch8_intel_init },
7896};
7897
7898/*
7899 * 6ch mode
7900 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007901static struct hda_verb alc883_sixstack_ch6_init[] = {
7902 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7903 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7904 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7905 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7906 { } /* end */
7907};
7908
7909/*
7910 * 8ch mode
7911 */
7912static struct hda_verb alc883_sixstack_ch8_init[] = {
7913 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7914 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7915 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7916 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7917 { } /* end */
7918};
7919
7920static struct hda_channel_mode alc883_sixstack_modes[2] = {
7921 { 6, alc883_sixstack_ch6_init },
7922 { 8, alc883_sixstack_ch8_init },
7923};
7924
7925
Linus Torvalds1da177e2005-04-16 15:20:36 -07007926/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7927 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7928 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007929static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007930 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007931 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007932 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007933 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007934 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7935 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007936 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7937 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007938 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007939 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007940 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7941 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7942 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7943 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7944 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7945 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007946 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007947 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7948 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007949 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007950 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007951 { } /* end */
7952};
7953
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007954/* Macbook Air 2,1 same control for HP and internal Speaker */
7955
7956static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7957 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7958 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7959 { }
7960};
7961
7962
Takashi Iwai87350ad2007-08-16 18:19:38 +02007963static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007964 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7965 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7966 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7967 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7968 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007969 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7970 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007971 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7972 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007973 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
7974 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007975 { } /* end */
7976};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007977
7978static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007979 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7980 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7981 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7982 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7983 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7984 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307985 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7986 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09307987 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7988 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007989 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7990 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007991 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
7992 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0x00, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007993 { } /* end */
7994};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007995
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007996static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7997 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7998 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7999 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8000 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8001 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
8002 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
8003 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
8004 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
8005 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
8006 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008007 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008008 { } /* end */
8009};
8010
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008011static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008012 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8013 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008014 { } /* end */
8015};
8016
8017
Kailang Yangbdd148a2007-05-08 15:19:08 +02008018static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
8019 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8020 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8021 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8022 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8023 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8024 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8025 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008026 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008027 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008028 { } /* end */
8029};
8030
Kailang Yang272a5272007-05-14 11:00:38 +02008031static struct snd_kcontrol_new alc882_targa_mixer[] = {
8032 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8033 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8034 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8035 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8036 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8037 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8038 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8039 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8040 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008041 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008042 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8043 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008044 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008045 { } /* end */
8046};
8047
8048/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
8049 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
8050 */
8051static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
8052 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8053 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8054 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8055 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8056 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8057 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8058 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8059 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8060 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
8061 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
8062 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8063 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008064 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008065 { } /* end */
8066};
8067
Takashi Iwai914759b2007-09-06 14:52:04 +02008068static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
8069 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8070 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8071 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8072 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8073 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8074 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8075 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8076 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008077 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008078 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008079 { } /* end */
8080};
8081
Kailang Yangdf694da2005-12-05 19:42:22 +01008082static struct snd_kcontrol_new alc882_chmode_mixer[] = {
8083 {
8084 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8085 .name = "Channel Mode",
8086 .info = alc_ch_mode_info,
8087 .get = alc_ch_mode_get,
8088 .put = alc_ch_mode_put,
8089 },
8090 { } /* end */
8091};
8092
Takashi Iwai4953550a2009-06-30 15:28:30 +02008093static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07008094 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008095 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8096 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008097 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008098 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8099 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008100 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008101 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8102 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008103 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008104 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8105 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008106
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008107 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008108 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008109 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008110 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008111 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008112 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008113 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008114 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008115 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008116 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008117 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008118 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008119 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008120 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008121 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008122 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008123 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008124 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008125 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8126 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008127 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008128 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8129 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008130 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008131 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8132 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8133 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8134 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8135 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008136 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008137 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008138
8139 /* FIXME: use matrix-type input source selection */
8140 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008141 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008142 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008143 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008144 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02008145 /* ADC2: mute amp left and right */
8146 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008147 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02008148 /* ADC3: mute amp left and right */
8149 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008150 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008151
8152 { }
8153};
8154
Takashi Iwai4953550a2009-06-30 15:28:30 +02008155static struct hda_verb alc882_adc1_init_verbs[] = {
8156 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8157 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8158 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8159 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8160 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8161 /* ADC1: mute amp left and right */
8162 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8163 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8164 { }
8165};
8166
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008167static struct hda_verb alc882_eapd_verbs[] = {
8168 /* change to EAPD mode */
8169 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008170 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008171 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008172};
8173
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008174static struct hda_verb alc889_eapd_verbs[] = {
8175 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8176 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8177 { }
8178};
8179
Wu Fengguang6732bd02009-07-30 09:19:14 +02008180static struct hda_verb alc_hp15_unsol_verbs[] = {
8181 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8182 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8183 {}
8184};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008185
8186static struct hda_verb alc885_init_verbs[] = {
8187 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01008188 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8189 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008190 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008191 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8192 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008193 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008194 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8195 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008196 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008197 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8198 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008199
8200 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02008201 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008202 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8203 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8204 /* Front Pin: output 0 (0x0c) */
8205 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8206 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8207 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8208 /* Rear Pin: output 1 (0x0d) */
8209 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8210 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8211 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
8212 /* CLFE Pin: output 2 (0x0e) */
8213 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8214 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8215 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8216 /* Side Pin: output 3 (0x0f) */
8217 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8218 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8219 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8220 /* Mic (rear) pin: input vref at 80% */
8221 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8222 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8223 /* Front Mic pin: input vref at 80% */
8224 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8225 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8226 /* Line In pin: input */
8227 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8228 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8229
8230 /* Mixer elements: 0x18, , 0x1a, 0x1b */
8231 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01008232 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008233 /* Input mixer2 */
8234 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008235 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008236 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008237 /* ADC2: mute amp left and right */
8238 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8239 /* ADC3: mute amp left and right */
8240 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8241
8242 { }
8243};
8244
8245static struct hda_verb alc885_init_input_verbs[] = {
8246 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8247 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8248 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8249 { }
8250};
8251
8252
8253/* Unmute Selector 24h and set the default input to front mic */
8254static struct hda_verb alc889_init_input_verbs[] = {
8255 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8256 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8257 { }
8258};
8259
8260
Takashi Iwai4953550a2009-06-30 15:28:30 +02008261#define alc883_init_verbs alc882_base_init_verbs
8262
Tobin Davis9102cd12006-12-15 10:02:12 +01008263/* Mac Pro test */
8264static struct snd_kcontrol_new alc882_macpro_mixer[] = {
8265 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8266 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8267 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
8268 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8269 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008270 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01008271 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
8272 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008273 */
Tobin Davis9102cd12006-12-15 10:02:12 +01008274 { } /* end */
8275};
8276
8277static struct hda_verb alc882_macpro_init_verbs[] = {
8278 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8279 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8280 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8281 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8282 /* Front Pin: output 0 (0x0c) */
8283 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8284 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8285 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8286 /* Front Mic pin: input vref at 80% */
8287 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8288 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8289 /* Speaker: output */
8290 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8291 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8292 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
8293 /* Headphone output (output 0 - 0x0c) */
8294 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8295 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8296 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8297
8298 /* FIXME: use matrix-type input source selection */
8299 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8300 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8301 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8302 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8303 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8304 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8305 /* Input mixer2 */
8306 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8307 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8308 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8309 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8310 /* Input mixer3 */
8311 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8312 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8313 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8315 /* ADC1: mute amp left and right */
8316 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8317 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8318 /* ADC2: mute amp left and right */
8319 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8320 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8321 /* ADC3: mute amp left and right */
8322 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8323 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8324
8325 { }
8326};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008327
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008328/* Macbook 5,1 */
8329static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008330 /* DACs */
8331 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8332 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8333 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8334 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008335 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008336 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8337 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8338 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008339 /* Surround mixer */
8340 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8341 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8342 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8343 /* LFE mixer */
8344 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8345 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8346 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8347 /* HP mixer */
8348 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8349 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8350 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8351 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008352 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8353 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008354 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8355 /* LFE Pin (0x0e) */
8356 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8357 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8358 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8359 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008360 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8361 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008362 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308363 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008364 /* Front Mic pin: input vref at 80% */
8365 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8366 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8367 /* Line In pin */
8368 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8369 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8370
Alex Murrayb8f171e2010-06-14 12:08:43 +09308371 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8372 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8373 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008374 { }
8375};
8376
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008377/* Macmini 3,1 */
8378static struct hda_verb alc885_macmini3_init_verbs[] = {
8379 /* DACs */
8380 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8381 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8382 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8383 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8384 /* Front mixer */
8385 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8386 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8387 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8388 /* Surround mixer */
8389 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8390 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8391 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8392 /* LFE mixer */
8393 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8394 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8395 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8396 /* HP mixer */
8397 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8398 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8399 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8400 /* Front Pin (0x0c) */
8401 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8402 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8403 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8404 /* LFE Pin (0x0e) */
8405 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8406 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8407 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8408 /* HP Pin (0x0f) */
8409 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8410 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8411 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8412 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8413 /* Line In pin */
8414 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8415 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8416
8417 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8418 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8419 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8420 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8421 { }
8422};
8423
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008424
8425static struct hda_verb alc885_mba21_init_verbs[] = {
8426 /*Internal and HP Speaker Mixer*/
8427 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8428 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8429 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8430 /*Internal Speaker Pin (0x0c)*/
8431 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8432 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8433 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8434 /* HP Pin: output 0 (0x0e) */
8435 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8436 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8437 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8438 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8439 /* Line in (is hp when jack connected)*/
8440 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8441 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8442
8443 { }
8444 };
8445
8446
Takashi Iwai87350ad2007-08-16 18:19:38 +02008447/* Macbook Pro rev3 */
8448static struct hda_verb alc885_mbp3_init_verbs[] = {
8449 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8450 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8451 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8452 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8453 /* Rear mixer */
8454 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8455 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8456 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008457 /* HP mixer */
8458 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8459 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8460 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008461 /* Front Pin: output 0 (0x0c) */
8462 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8463 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8464 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008465 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008466 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008467 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8468 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008469 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8470 /* Mic (rear) pin: input vref at 80% */
8471 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8472 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8473 /* Front Mic pin: input vref at 80% */
8474 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8475 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8476 /* Line In pin: use output 1 when in LineOut mode */
8477 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8478 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8479 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8480
8481 /* FIXME: use matrix-type input source selection */
8482 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8483 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8484 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8485 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8486 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8487 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8488 /* Input mixer2 */
8489 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8490 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8491 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8492 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8493 /* Input mixer3 */
8494 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8495 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8496 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8497 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8498 /* ADC1: mute amp left and right */
8499 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8500 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8501 /* ADC2: mute amp left and right */
8502 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8503 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8504 /* ADC3: mute amp left and right */
8505 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8506 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8507
8508 { }
8509};
8510
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008511/* iMac 9,1 */
8512static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008513 /* Internal Speaker Pin (0x0c) */
8514 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8515 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8516 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8517 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8518 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8519 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8520 /* HP Pin: Rear */
8521 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8522 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8523 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8524 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8525 /* Line in Rear */
8526 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8527 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8528 /* Front Mic pin: input vref at 80% */
8529 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8530 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008531 /* Rear mixer */
8532 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8533 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8534 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008535 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8536 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8537 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8538 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8539 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008540 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8541 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8542 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8543 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008544 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008545 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8546 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8547 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8548 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008549 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008550 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8551 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8552 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8553 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008554 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008555 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8556 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008557 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008558 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8559 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008560 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008561 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8562 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008563 { }
8564};
8565
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008566/* iMac 24 mixer. */
8567static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8568 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8569 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8570 { } /* end */
8571};
8572
8573/* iMac 24 init verbs. */
8574static struct hda_verb alc885_imac24_init_verbs[] = {
8575 /* Internal speakers: output 0 (0x0c) */
8576 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8577 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8578 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8579 /* Internal speakers: output 0 (0x0c) */
8580 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8581 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8582 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8583 /* Headphone: output 0 (0x0c) */
8584 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8585 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8586 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8587 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8588 /* Front Mic: input vref at 80% */
8589 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8590 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8591 { }
8592};
8593
8594/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008595static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008596{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008597 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008598
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008599 spec->autocfg.hp_pins[0] = 0x14;
8600 spec->autocfg.speaker_pins[0] = 0x18;
8601 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008602}
8603
Takashi Iwai9d54f082010-02-22 08:34:40 +01008604#define alc885_mb5_setup alc885_imac24_setup
8605#define alc885_macmini3_setup alc885_imac24_setup
8606
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008607/* Macbook Air 2,1 */
8608static void alc885_mba21_setup(struct hda_codec *codec)
8609{
8610 struct alc_spec *spec = codec->spec;
8611
8612 spec->autocfg.hp_pins[0] = 0x14;
8613 spec->autocfg.speaker_pins[0] = 0x18;
8614}
8615
8616
8617
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008618static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008619{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008620 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008621
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008622 spec->autocfg.hp_pins[0] = 0x15;
8623 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008624}
8625
Takashi Iwai9d54f082010-02-22 08:34:40 +01008626static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308627{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008628 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308629
Takashi Iwai9d54f082010-02-22 08:34:40 +01008630 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008631 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008632 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008633}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008634
Kailang Yang272a5272007-05-14 11:00:38 +02008635static struct hda_verb alc882_targa_verbs[] = {
8636 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8637 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8638
8639 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8640 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008641
Kailang Yang272a5272007-05-14 11:00:38 +02008642 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8643 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8644 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8645
8646 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008647 { } /* end */
8648};
8649
8650/* toggle speaker-output according to the hp-jack state */
8651static void alc882_targa_automute(struct hda_codec *codec)
8652{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008653 struct alc_spec *spec = codec->spec;
8654 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008655 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008656 spec->jack_present ? 1 : 3);
8657}
8658
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008659static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008660{
8661 struct alc_spec *spec = codec->spec;
8662
8663 spec->autocfg.hp_pins[0] = 0x14;
8664 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008665}
8666
8667static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8668{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008669 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008670 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008671}
8672
8673static struct hda_verb alc882_asus_a7j_verbs[] = {
8674 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8675 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8676
8677 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8678 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8679 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008680
Kailang Yang272a5272007-05-14 11:00:38 +02008681 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8682 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8683 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8684
8685 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8686 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8687 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8688 { } /* end */
8689};
8690
Takashi Iwai914759b2007-09-06 14:52:04 +02008691static struct hda_verb alc882_asus_a7m_verbs[] = {
8692 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8693 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8694
8695 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8696 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8697 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008698
Takashi Iwai914759b2007-09-06 14:52:04 +02008699 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8700 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8701 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8702
8703 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8704 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8705 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8706 { } /* end */
8707};
8708
Tobin Davis9102cd12006-12-15 10:02:12 +01008709static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8710{
8711 unsigned int gpiostate, gpiomask, gpiodir;
8712
8713 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8714 AC_VERB_GET_GPIO_DATA, 0);
8715
8716 if (!muted)
8717 gpiostate |= (1 << pin);
8718 else
8719 gpiostate &= ~(1 << pin);
8720
8721 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8722 AC_VERB_GET_GPIO_MASK, 0);
8723 gpiomask |= (1 << pin);
8724
8725 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8726 AC_VERB_GET_GPIO_DIRECTION, 0);
8727 gpiodir |= (1 << pin);
8728
8729
8730 snd_hda_codec_write(codec, codec->afg, 0,
8731 AC_VERB_SET_GPIO_MASK, gpiomask);
8732 snd_hda_codec_write(codec, codec->afg, 0,
8733 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8734
8735 msleep(1);
8736
8737 snd_hda_codec_write(codec, codec->afg, 0,
8738 AC_VERB_SET_GPIO_DATA, gpiostate);
8739}
8740
Takashi Iwai7debbe52007-08-16 15:01:03 +02008741/* set up GPIO at initialization */
8742static void alc885_macpro_init_hook(struct hda_codec *codec)
8743{
8744 alc882_gpio_mute(codec, 0, 0);
8745 alc882_gpio_mute(codec, 1, 0);
8746}
8747
8748/* set up GPIO and update auto-muting at initialization */
8749static void alc885_imac24_init_hook(struct hda_codec *codec)
8750{
8751 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008752 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008753}
8754
Kailang Yangdf694da2005-12-05 19:42:22 +01008755/*
8756 * generic initialization of ADC, input mixers and output mixers
8757 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008758static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008759 /*
8760 * Unmute ADC0-2 and set the default input to mic-in
8761 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008762 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8763 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8764 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8765 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8766
Kailang Yangdf694da2005-12-05 19:42:22 +01008767 /*
8768 * Set up output mixers (0x0c - 0x0f)
8769 */
8770 /* set vol=0 to output mixers */
8771 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8772 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8773 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8774 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8775 /* set up input amps for analog loopback */
8776 /* Amp Indices: DAC = 0, mixer = 1 */
8777 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8778 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8779 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8780 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8781 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8782 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8783 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8784 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8785 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8786 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8787
8788 /* FIXME: use matrix-type input source selection */
8789 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008790 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008791 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008792 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008793 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008794 { }
8795};
8796
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008797/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8798static struct hda_verb alc889A_mb31_ch2_init[] = {
8799 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8800 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8801 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8802 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8803 { } /* end */
8804};
8805
8806/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8807static struct hda_verb alc889A_mb31_ch4_init[] = {
8808 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8809 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8810 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8811 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8812 { } /* end */
8813};
8814
8815/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8816static struct hda_verb alc889A_mb31_ch5_init[] = {
8817 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8818 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8819 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8820 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8821 { } /* end */
8822};
8823
8824/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8825static struct hda_verb alc889A_mb31_ch6_init[] = {
8826 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8827 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8828 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8829 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8830 { } /* end */
8831};
8832
8833static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8834 { 2, alc889A_mb31_ch2_init },
8835 { 4, alc889A_mb31_ch4_init },
8836 { 5, alc889A_mb31_ch5_init },
8837 { 6, alc889A_mb31_ch6_init },
8838};
8839
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008840static struct hda_verb alc883_medion_eapd_verbs[] = {
8841 /* eanable EAPD on medion laptop */
8842 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8843 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8844 { }
8845};
8846
Takashi Iwai4953550a2009-06-30 15:28:30 +02008847#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008848
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008849static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8850 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8851 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8852 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8853 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8854 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8855 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8856 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8857 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008858 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008859 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8860 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008861 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008862 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008863 { } /* end */
8864};
8865
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008866static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008867 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8868 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8869 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8870 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8871 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008872 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008873 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008874 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008875 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008876 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008877 { } /* end */
8878};
8879
Jiang zhefb97dc62008-03-06 11:07:11 +01008880static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8881 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8882 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8883 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8884 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8885 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008886 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008887 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008888 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008889 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008890 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008891 { } /* end */
8892};
8893
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008894static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8895 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8896 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8897 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8898 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8899 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8900 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8901 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8902 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008903 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008904 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8905 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008906 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008907 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008908 { } /* end */
8909};
8910
8911static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8912 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8913 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8914 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8915 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8916 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8917 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8918 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8919 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8920 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8921 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8922 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8923 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8924 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8925 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008926 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008927 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8928 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008929 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008930 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008931 { } /* end */
8932};
8933
Jiang zhe17bba1b2008-06-04 12:11:07 +02008934static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8935 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8936 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8937 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8938 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8939 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8940 HDA_OUTPUT),
8941 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8942 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8943 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8944 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8945 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8946 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8947 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8948 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8949 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008950 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008951 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8952 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008953 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008954 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008955 { } /* end */
8956};
8957
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008958static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8959 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8960 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8961 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8962 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8963 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8964 HDA_OUTPUT),
8965 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8966 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8967 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8968 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8969 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8970 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8971 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8972 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8973 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008974 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008975 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8976 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008977 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008978 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8979 { } /* end */
8980};
8981
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008982static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008983 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008984 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008985 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008986 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008987 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8988 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008989 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8990 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008991 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8992 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8993 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8994 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8995 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8996 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008997 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008998 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8999 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009000 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009001 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02009002 { } /* end */
9003};
9004
Sasha Alexandrc2592492009-06-16 14:52:54 -04009005static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009006 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009007 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009008 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009009 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009010 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9011 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9012 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9013 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9014 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9015 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9016 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9017 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9018 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9019 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9020 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009021 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009022 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009023 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009024};
Kailang Yangccc656c2006-10-17 12:32:26 +02009025
Sasha Alexandrc2592492009-06-16 14:52:54 -04009026static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009027 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009028 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009029 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009030 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009031 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9032 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9033 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009034 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009035 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009036 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009037 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009038 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009039 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009040};
Kailang Yangccc656c2006-10-17 12:32:26 +02009041
Takashi Iwaib99dba32009-09-17 18:23:00 +02009042static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
9043 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9044 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009045 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009046 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009047 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009048 { } /* end */
9049};
9050
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009051static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
9052 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9053 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009054 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9055 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009056 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9057 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009058 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009059 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009060 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009061};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009062
Kailang Yang272a5272007-05-14 11:00:38 +02009063static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
9064 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9065 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
9066 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9067 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9068 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9069 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9070 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009071 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9072 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02009073 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02009074};
Kailang Yang272a5272007-05-14 11:00:38 +02009075
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009076static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
9077 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9078 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9079 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9080 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
9081 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
9082 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
9083 { } /* end */
9084};
9085
9086static struct hda_verb alc883_medion_wim2160_verbs[] = {
9087 /* Unmute front mixer */
9088 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9089 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9090
9091 /* Set speaker pin to front mixer */
9092 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9093
9094 /* Init headphone pin */
9095 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9096 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9097 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9098 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9099
9100 { } /* end */
9101};
9102
9103/* toggle speaker-output according to the hp-jack state */
9104static void alc883_medion_wim2160_setup(struct hda_codec *codec)
9105{
9106 struct alc_spec *spec = codec->spec;
9107
9108 spec->autocfg.hp_pins[0] = 0x1a;
9109 spec->autocfg.speaker_pins[0] = 0x15;
9110}
9111
Tobin Davis2880a862007-08-07 11:50:26 +02009112static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02009113 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9114 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009115 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009116 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9117 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009118 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009119 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009120 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009121 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02009122};
Tobin Davis2880a862007-08-07 11:50:26 +02009123
Tony Vroond2fd4b02009-06-21 00:40:10 +01009124static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
9125 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009126 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01009127 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9128 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009129 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("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009132 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009133 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9134 { } /* end */
9135};
9136
Kailang Yange2757d52008-08-26 13:17:46 +02009137static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
9138 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9139 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9140 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9141 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
9142 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
9143 0x0d, 1, 0x0, HDA_OUTPUT),
9144 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
9145 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
9146 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
9147 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9148 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009149 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9150 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9151 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9152 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9153 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009154 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009155 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9156 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009157 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009158 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009159 { } /* end */
9160};
9161
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009162static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
9163 /* Output mixers */
9164 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
9165 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
9166 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
9167 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
9168 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
9169 HDA_OUTPUT),
9170 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
9171 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
9172 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
9173 /* Output switches */
9174 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
9175 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
9176 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
9177 /* Boost mixers */
David Henningsson5f99f862011-01-04 15:24:24 +01009178 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
9179 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009180 /* Input mixers */
9181 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
9182 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
9183 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9184 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9185 { } /* end */
9186};
9187
Guido Günther3e1647c52009-06-05 00:47:26 +02009188static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
9189 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9190 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9191 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9192 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009193 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Guido Günther3e1647c52009-06-05 00:47:26 +02009194 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9195 { } /* end */
9196};
9197
Kailang Yange2757d52008-08-26 13:17:46 +02009198static struct hda_bind_ctls alc883_bind_cap_vol = {
9199 .ops = &snd_hda_bind_vol,
9200 .values = {
9201 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9202 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9203 0
9204 },
9205};
9206
9207static struct hda_bind_ctls alc883_bind_cap_switch = {
9208 .ops = &snd_hda_bind_sw,
9209 .values = {
9210 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9211 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9212 0
9213 },
9214};
9215
9216static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
9217 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9218 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9219 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9220 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9221 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9222 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009223 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009224 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009225 { } /* end */
9226};
9227
9228static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009229 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
9230 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
9231 {
9232 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9233 /* .name = "Capture Source", */
9234 .name = "Input Source",
9235 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009236 .info = alc_mux_enum_info,
9237 .get = alc_mux_enum_get,
9238 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02009239 },
9240 { } /* end */
9241};
9242
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009243static struct snd_kcontrol_new alc883_chmode_mixer[] = {
9244 {
9245 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9246 .name = "Channel Mode",
9247 .info = alc_ch_mode_info,
9248 .get = alc_ch_mode_get,
9249 .put = alc_ch_mode_put,
9250 },
9251 { } /* end */
9252};
9253
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009254/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009255static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009256{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009257 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009258
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009259 spec->autocfg.hp_pins[0] = 0x15;
9260 spec->autocfg.speaker_pins[0] = 0x14;
9261 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009262}
9263
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009264static struct hda_verb alc883_mitac_verbs[] = {
9265 /* HP */
9266 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9267 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9268 /* Subwoofer */
9269 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9270 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9271
9272 /* enable unsolicited event */
9273 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9274 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
9275
9276 { } /* end */
9277};
9278
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309279static struct hda_verb alc883_clevo_m540r_verbs[] = {
9280 /* HP */
9281 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9282 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9283 /* Int speaker */
9284 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9285
9286 /* enable unsolicited event */
9287 /*
9288 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9289 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9290 */
9291
9292 { } /* end */
9293};
9294
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009295static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009296 /* HP */
9297 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9298 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9299 /* Int speaker */
9300 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9301 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9302
9303 /* enable unsolicited event */
9304 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009305 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009306
9307 { } /* end */
9308};
9309
Jiang zhefb97dc62008-03-06 11:07:11 +01009310static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9311 /* HP */
9312 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9313 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9314 /* Subwoofer */
9315 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9316 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9317
9318 /* enable unsolicited event */
9319 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9320
9321 { } /* end */
9322};
9323
Sasha Alexandrc2592492009-06-16 14:52:54 -04009324static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009325 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9326 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9327
9328 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9329 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009330
David Heidelberger64a8be72009-06-08 16:15:18 +02009331/* Connect Line-Out side jack (SPDIF) to Side */
9332 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9333 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9334 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9335/* Connect Mic jack to CLFE */
9336 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9337 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9338 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9339/* Connect Line-in jack to Surround */
9340 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9341 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9342 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9343/* Connect HP out jack to Front */
9344 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9345 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9346 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009347
9348 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009349
9350 { } /* end */
9351};
9352
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009353static struct hda_verb alc883_lenovo_101e_verbs[] = {
9354 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9355 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9356 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9357 { } /* end */
9358};
9359
Kailang Yang272a5272007-05-14 11:00:38 +02009360static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9361 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9362 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9363 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9364 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9365 { } /* end */
9366};
9367
9368static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
9369 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9370 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9371 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9372 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9373 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9374 { } /* end */
9375};
9376
Kailang Yang189609a2007-08-20 11:31:23 +02009377static struct hda_verb alc883_haier_w66_verbs[] = {
9378 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9379 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9380
9381 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9382
9383 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9384 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9385 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9386 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9387 { } /* end */
9388};
9389
Kailang Yange2757d52008-08-26 13:17:46 +02009390static struct hda_verb alc888_lenovo_sky_verbs[] = {
9391 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9392 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9393 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9394 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9395 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9396 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9397 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9398 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9399 { } /* end */
9400};
9401
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009402static struct hda_verb alc888_6st_dell_verbs[] = {
9403 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9404 { }
9405};
9406
Guido Günther3e1647c52009-06-05 00:47:26 +02009407static struct hda_verb alc883_vaiott_verbs[] = {
9408 /* HP */
9409 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9410 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9411
9412 /* enable unsolicited event */
9413 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9414
9415 { } /* end */
9416};
9417
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009418static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009419{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009420 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009421
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009422 spec->autocfg.hp_pins[0] = 0x1b;
9423 spec->autocfg.speaker_pins[0] = 0x14;
9424 spec->autocfg.speaker_pins[1] = 0x16;
9425 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009426}
9427
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009428static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009429 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009430 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9431 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009432 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009433 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009434};
9435
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009436/*
9437 * 2ch mode
9438 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009439static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009440 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9441 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9442 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9443 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009444 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009445};
9446
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009447/*
9448 * 4ch mode
9449 */
9450static struct hda_verb alc888_3st_hp_4ch_init[] = {
9451 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9452 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9453 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9454 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9455 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9456 { } /* end */
9457};
9458
9459/*
9460 * 6ch mode
9461 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009462static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009463 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9464 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009465 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009466 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9467 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009468 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9469 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009470};
9471
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009472static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009473 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009474 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009475 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009476};
9477
Kailang Yang272a5272007-05-14 11:00:38 +02009478/* toggle front-jack and RCA according to the hp-jack state */
9479static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9480{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009481 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02009482
Takashi Iwai47fd8302007-08-10 17:11:07 +02009483 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9484 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9485 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9486 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009487}
9488
9489/* toggle RCA according to the front-jack state */
9490static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9491{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009492 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009493
Takashi Iwai47fd8302007-08-10 17:11:07 +02009494 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9495 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009496}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009497
Kailang Yang272a5272007-05-14 11:00:38 +02009498static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9499 unsigned int res)
9500{
9501 if ((res >> 26) == ALC880_HP_EVENT)
9502 alc888_lenovo_ms7195_front_automute(codec);
9503 if ((res >> 26) == ALC880_FRONT_EVENT)
9504 alc888_lenovo_ms7195_rca_automute(codec);
9505}
9506
Kailang Yang272a5272007-05-14 11:00:38 +02009507/* toggle speaker-output according to the hp-jack state */
Takashi Iwaidc4271702010-11-29 07:42:59 +01009508static void alc883_lenovo_nb0763_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009509{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009510 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009511
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009512 spec->autocfg.hp_pins[0] = 0x14;
9513 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009514}
9515
Kailang Yangccc656c2006-10-17 12:32:26 +02009516/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009517#define alc883_targa_init_hook alc882_targa_init_hook
9518#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009519
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009520static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009521{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009522 struct alc_spec *spec = codec->spec;
9523
9524 spec->autocfg.hp_pins[0] = 0x15;
9525 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009526}
9527
9528static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9529{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009530 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01009531 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009532}
9533
9534static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009535 unsigned int res)
9536{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009537 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009538 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01009539 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009540 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009541 default:
9542 alc_automute_amp_unsol_event(codec, res);
9543 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009544 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009545}
9546
Jiang zhefb97dc62008-03-06 11:07:11 +01009547/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009548static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009549{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009550 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009551
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009552 spec->autocfg.hp_pins[0] = 0x14;
9553 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009554}
9555
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009556static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009557{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009558 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009559
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009560 spec->autocfg.hp_pins[0] = 0x1b;
9561 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009562}
9563
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009564static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9565{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009566 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009567
Takashi Iwai47fd8302007-08-10 17:11:07 +02009568 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9569 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009570}
9571
9572static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9573{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009574 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009575
Takashi Iwai47fd8302007-08-10 17:11:07 +02009576 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9577 HDA_AMP_MUTE, bits);
9578 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9579 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009580}
9581
9582static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9583 unsigned int res)
9584{
9585 if ((res >> 26) == ALC880_HP_EVENT)
9586 alc883_lenovo_101e_all_automute(codec);
9587 if ((res >> 26) == ALC880_FRONT_EVENT)
9588 alc883_lenovo_101e_ispeaker_automute(codec);
9589}
9590
Takashi Iwai676a9b52007-08-16 15:23:35 +02009591/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009592static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009593{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009594 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009595
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009596 spec->autocfg.hp_pins[0] = 0x14;
9597 spec->autocfg.speaker_pins[0] = 0x15;
9598 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009599}
9600
Kailang Yangd1a991a2007-08-15 16:21:59 +02009601static struct hda_verb alc883_acer_eapd_verbs[] = {
9602 /* HP Pin: output 0 (0x0c) */
9603 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9604 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9605 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9606 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009607 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9608 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009609 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009610 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9611 /* eanable EAPD on medion laptop */
9612 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9613 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009614 /* enable unsolicited event */
9615 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009616 { }
9617};
9618
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009619static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009620{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009621 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009622
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009623 spec->autocfg.hp_pins[0] = 0x1b;
9624 spec->autocfg.speaker_pins[0] = 0x14;
9625 spec->autocfg.speaker_pins[1] = 0x15;
9626 spec->autocfg.speaker_pins[2] = 0x16;
9627 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009628}
9629
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009630static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009631{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009632 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009633
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009634 spec->autocfg.hp_pins[0] = 0x1b;
9635 spec->autocfg.speaker_pins[0] = 0x14;
9636 spec->autocfg.speaker_pins[1] = 0x15;
9637 spec->autocfg.speaker_pins[2] = 0x16;
9638 spec->autocfg.speaker_pins[3] = 0x17;
9639 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009640}
9641
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009642static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c52009-06-05 00:47:26 +02009643{
9644 struct alc_spec *spec = codec->spec;
9645
9646 spec->autocfg.hp_pins[0] = 0x15;
9647 spec->autocfg.speaker_pins[0] = 0x14;
9648 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c52009-06-05 00:47:26 +02009649}
9650
Kailang Yange2757d52008-08-26 13:17:46 +02009651static struct hda_verb alc888_asus_m90v_verbs[] = {
9652 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9653 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9654 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9655 /* enable unsolicited event */
9656 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9657 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9658 { } /* end */
9659};
9660
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009661static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009662{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009663 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009664
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009665 spec->autocfg.hp_pins[0] = 0x1b;
9666 spec->autocfg.speaker_pins[0] = 0x14;
9667 spec->autocfg.speaker_pins[1] = 0x15;
9668 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009669 spec->ext_mic.pin = 0x18;
9670 spec->int_mic.pin = 0x19;
9671 spec->ext_mic.mux_idx = 0;
9672 spec->int_mic.mux_idx = 1;
9673 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009674}
9675
9676static struct hda_verb alc888_asus_eee1601_verbs[] = {
9677 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9678 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9679 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9680 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9681 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9682 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9683 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9684 /* enable unsolicited event */
9685 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9686 { } /* end */
9687};
9688
Kailang Yange2757d52008-08-26 13:17:46 +02009689static void alc883_eee1601_inithook(struct hda_codec *codec)
9690{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009691 struct alc_spec *spec = codec->spec;
9692
9693 spec->autocfg.hp_pins[0] = 0x14;
9694 spec->autocfg.speaker_pins[0] = 0x1b;
9695 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009696}
9697
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009698static struct hda_verb alc889A_mb31_verbs[] = {
9699 /* Init rear pin (used as headphone output) */
9700 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9701 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9702 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9703 /* Init line pin (used as output in 4ch and 6ch mode) */
9704 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9705 /* Init line 2 pin (used as headphone out by default) */
9706 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9707 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9708 { } /* end */
9709};
9710
9711/* Mute speakers according to the headphone jack state */
9712static void alc889A_mb31_automute(struct hda_codec *codec)
9713{
9714 unsigned int present;
9715
9716 /* Mute only in 2ch or 4ch mode */
9717 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9718 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009719 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009720 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9721 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9722 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9723 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9724 }
9725}
9726
9727static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9728{
9729 if ((res >> 26) == ALC880_HP_EVENT)
9730 alc889A_mb31_automute(codec);
9731}
9732
Takashi Iwai4953550a2009-06-30 15:28:30 +02009733
Takashi Iwaicb53c622007-08-10 17:21:45 +02009734#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009735#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009736#endif
9737
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009738/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009739#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9740#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9741#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9742#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9743
9744static hda_nid_t alc883_slave_dig_outs[] = {
9745 ALC1200_DIGOUT_NID, 0,
9746};
9747
9748static hda_nid_t alc1200_slave_dig_outs[] = {
9749 ALC883_DIGOUT_NID, 0,
9750};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009751
9752/*
9753 * configuration and preset
9754 */
Takashi Iwaiea734962011-01-17 11:29:34 +01009755static const char * const alc882_models[ALC882_MODEL_LAST] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009756 [ALC882_3ST_DIG] = "3stack-dig",
9757 [ALC882_6ST_DIG] = "6stack-dig",
9758 [ALC882_ARIMA] = "arima",
9759 [ALC882_W2JC] = "w2jc",
9760 [ALC882_TARGA] = "targa",
9761 [ALC882_ASUS_A7J] = "asus-a7j",
9762 [ALC882_ASUS_A7M] = "asus-a7m",
9763 [ALC885_MACPRO] = "macpro",
9764 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009765 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009766 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009767 [ALC885_MBP3] = "mbp3",
9768 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009769 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009770 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009771 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9772 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009773 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009774 [ALC883_TARGA_DIG] = "targa-dig",
9775 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009776 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009777 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009778 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009779 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009780 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009781 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009782 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009783 [ALC883_MEDION] = "medion",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009784 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009785 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009786 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009787 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9788 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009789 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009790 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009791 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009792 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009793 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309794 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009795 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009796 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009797 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009798 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009799 [ALC889A_INTEL] = "intel-alc889a",
9800 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009801 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009802 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c52009-06-05 00:47:26 +02009803 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009804 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009805};
9806
Takashi Iwai4953550a2009-06-30 15:28:30 +02009807static struct snd_pci_quirk alc882_cfg_tbl[] = {
9808 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9809
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009810 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009811 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009812 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009813 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9814 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009815 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009816 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9817 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009818 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009819 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009820 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9821 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009822 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9823 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009824 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9825 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009826 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009827 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009828 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009829 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009830 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9831 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009832 /* default Acer -- disabled as it causes more problems.
9833 * model=auto should work fine now
9834 */
9835 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009836
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009837 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009838
Lucas De Marchi25985ed2011-03-30 22:57:33 -03009839 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavilion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009840 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9841 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009842 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009843 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009844 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009845
9846 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9847 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9848 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009849 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009850 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9851 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9852 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009853 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009854 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009855 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009856 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009857
9858 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009859 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009860 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009861 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009862 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9863 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009864 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009865 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009866 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9867
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009868 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9869 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9870 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009871 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009872 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009873 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009874 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009875 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009876 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9877 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9878 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9879 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9880 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9881 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009882 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009883 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9884 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9885 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009886 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009887 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009888 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9889 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009890 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009891 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009892 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009893 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009894 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009895 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009896 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009897 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009898 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009899
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009900 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009901 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009902 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9903 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309904 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009905 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009906 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009907 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009908 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009909 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009910 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009911 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009912 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009913 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009914 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009915 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9916 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009917 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Takashi Iwai959973b2008-11-05 11:30:56 +01009918 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009919 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009920 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009921
Jiang zhe17bba1b2008-06-04 12:11:07 +02009922 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9923 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009924 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009925 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9926 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9927 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009928 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009929
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009930 {}
9931};
9932
Takashi Iwai4953550a2009-06-30 15:28:30 +02009933/* codec SSID table for Intel Mac */
9934static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9935 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9936 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9937 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9938 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9939 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9940 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9941 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009942 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009943 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009944 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009945 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009946 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9947 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9948 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009949 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009950 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +10009951 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009952 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9953 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009954 */
9955 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009956 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009957 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009958 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009959};
9960
Takashi Iwai4953550a2009-06-30 15:28:30 +02009961static struct alc_config_preset alc882_presets[] = {
9962 [ALC882_3ST_DIG] = {
9963 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009964 .init_verbs = { alc882_base_init_verbs,
9965 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009966 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9967 .dac_nids = alc882_dac_nids,
9968 .dig_out_nid = ALC882_DIGOUT_NID,
9969 .dig_in_nid = ALC882_DIGIN_NID,
9970 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9971 .channel_mode = alc882_ch_modes,
9972 .need_dac_fix = 1,
9973 .input_mux = &alc882_capture_source,
9974 },
9975 [ALC882_6ST_DIG] = {
9976 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009977 .init_verbs = { alc882_base_init_verbs,
9978 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009979 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9980 .dac_nids = alc882_dac_nids,
9981 .dig_out_nid = ALC882_DIGOUT_NID,
9982 .dig_in_nid = ALC882_DIGIN_NID,
9983 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9984 .channel_mode = alc882_sixstack_modes,
9985 .input_mux = &alc882_capture_source,
9986 },
9987 [ALC882_ARIMA] = {
9988 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009989 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9990 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009991 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9992 .dac_nids = alc882_dac_nids,
9993 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9994 .channel_mode = alc882_sixstack_modes,
9995 .input_mux = &alc882_capture_source,
9996 },
9997 [ALC882_W2JC] = {
9998 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009999 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10000 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010001 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10002 .dac_nids = alc882_dac_nids,
10003 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10004 .channel_mode = alc880_threestack_modes,
10005 .need_dac_fix = 1,
10006 .input_mux = &alc882_capture_source,
10007 .dig_out_nid = ALC882_DIGOUT_NID,
10008 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -080010009 [ALC885_MBA21] = {
10010 .mixers = { alc885_mba21_mixer },
10011 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
10012 .num_dacs = 2,
10013 .dac_nids = alc882_dac_nids,
10014 .channel_mode = alc885_mba21_ch_modes,
10015 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10016 .input_mux = &alc882_capture_source,
10017 .unsol_event = alc_automute_amp_unsol_event,
10018 .setup = alc885_mba21_setup,
10019 .init_hook = alc_automute_amp,
10020 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010021 [ALC885_MBP3] = {
10022 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
10023 .init_verbs = { alc885_mbp3_init_verbs,
10024 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010025 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010026 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010027 .hp_nid = 0x04,
10028 .channel_mode = alc885_mbp_4ch_modes,
10029 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010030 .input_mux = &alc882_capture_source,
10031 .dig_out_nid = ALC882_DIGOUT_NID,
10032 .dig_in_nid = ALC882_DIGIN_NID,
10033 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010034 .setup = alc885_mbp3_setup,
10035 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010036 },
10037 [ALC885_MB5] = {
10038 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
10039 .init_verbs = { alc885_mb5_init_verbs,
10040 alc880_gpio1_init_verbs },
10041 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10042 .dac_nids = alc882_dac_nids,
10043 .channel_mode = alc885_mb5_6ch_modes,
10044 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
10045 .input_mux = &mb5_capture_source,
10046 .dig_out_nid = ALC882_DIGOUT_NID,
10047 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010048 .unsol_event = alc_automute_amp_unsol_event,
10049 .setup = alc885_mb5_setup,
10050 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010051 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010052 [ALC885_MACMINI3] = {
10053 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
10054 .init_verbs = { alc885_macmini3_init_verbs,
10055 alc880_gpio1_init_verbs },
10056 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10057 .dac_nids = alc882_dac_nids,
10058 .channel_mode = alc885_macmini3_6ch_modes,
10059 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
10060 .input_mux = &macmini3_capture_source,
10061 .dig_out_nid = ALC882_DIGOUT_NID,
10062 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010063 .unsol_event = alc_automute_amp_unsol_event,
10064 .setup = alc885_macmini3_setup,
10065 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010066 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010067 [ALC885_MACPRO] = {
10068 .mixers = { alc882_macpro_mixer },
10069 .init_verbs = { alc882_macpro_init_verbs },
10070 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10071 .dac_nids = alc882_dac_nids,
10072 .dig_out_nid = ALC882_DIGOUT_NID,
10073 .dig_in_nid = ALC882_DIGIN_NID,
10074 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10075 .channel_mode = alc882_ch_modes,
10076 .input_mux = &alc882_capture_source,
10077 .init_hook = alc885_macpro_init_hook,
10078 },
10079 [ALC885_IMAC24] = {
10080 .mixers = { alc885_imac24_mixer },
10081 .init_verbs = { alc885_imac24_init_verbs },
10082 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10083 .dac_nids = alc882_dac_nids,
10084 .dig_out_nid = ALC882_DIGOUT_NID,
10085 .dig_in_nid = ALC882_DIGIN_NID,
10086 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10087 .channel_mode = alc882_ch_modes,
10088 .input_mux = &alc882_capture_source,
10089 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010090 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010091 .init_hook = alc885_imac24_init_hook,
10092 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010093 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010094 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010095 .init_verbs = { alc885_imac91_init_verbs,
10096 alc880_gpio1_init_verbs },
10097 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10098 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010099 .channel_mode = alc885_mba21_ch_modes,
10100 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10101 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010102 .dig_out_nid = ALC882_DIGOUT_NID,
10103 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010104 .unsol_event = alc_automute_amp_unsol_event,
10105 .setup = alc885_imac91_setup,
10106 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010107 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010108 [ALC882_TARGA] = {
10109 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010110 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +020010111 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010112 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10113 .dac_nids = alc882_dac_nids,
10114 .dig_out_nid = ALC882_DIGOUT_NID,
10115 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10116 .adc_nids = alc882_adc_nids,
10117 .capsrc_nids = alc882_capsrc_nids,
10118 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10119 .channel_mode = alc882_3ST_6ch_modes,
10120 .need_dac_fix = 1,
10121 .input_mux = &alc882_capture_source,
10122 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010123 .setup = alc882_targa_setup,
10124 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010125 },
10126 [ALC882_ASUS_A7J] = {
10127 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010128 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10129 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010130 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10131 .dac_nids = alc882_dac_nids,
10132 .dig_out_nid = ALC882_DIGOUT_NID,
10133 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10134 .adc_nids = alc882_adc_nids,
10135 .capsrc_nids = alc882_capsrc_nids,
10136 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10137 .channel_mode = alc882_3ST_6ch_modes,
10138 .need_dac_fix = 1,
10139 .input_mux = &alc882_capture_source,
10140 },
10141 [ALC882_ASUS_A7M] = {
10142 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010143 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10144 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010145 alc882_asus_a7m_verbs },
10146 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10147 .dac_nids = alc882_dac_nids,
10148 .dig_out_nid = ALC882_DIGOUT_NID,
10149 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10150 .channel_mode = alc880_threestack_modes,
10151 .need_dac_fix = 1,
10152 .input_mux = &alc882_capture_source,
10153 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010154 [ALC883_3ST_2ch_DIG] = {
10155 .mixers = { alc883_3ST_2ch_mixer },
10156 .init_verbs = { alc883_init_verbs },
10157 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10158 .dac_nids = alc883_dac_nids,
10159 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010160 .dig_in_nid = ALC883_DIGIN_NID,
10161 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10162 .channel_mode = alc883_3ST_2ch_modes,
10163 .input_mux = &alc883_capture_source,
10164 },
10165 [ALC883_3ST_6ch_DIG] = {
10166 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10167 .init_verbs = { alc883_init_verbs },
10168 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10169 .dac_nids = alc883_dac_nids,
10170 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010171 .dig_in_nid = ALC883_DIGIN_NID,
10172 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10173 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010174 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010175 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010176 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010177 [ALC883_3ST_6ch] = {
10178 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10179 .init_verbs = { alc883_init_verbs },
10180 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10181 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010182 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10183 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010184 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010185 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010186 },
Jiang zhe17bba1b2008-06-04 12:11:07 +020010187 [ALC883_3ST_6ch_INTEL] = {
10188 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
10189 .init_verbs = { alc883_init_verbs },
10190 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10191 .dac_nids = alc883_dac_nids,
10192 .dig_out_nid = ALC883_DIGOUT_NID,
10193 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010194 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +020010195 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
10196 .channel_mode = alc883_3ST_6ch_intel_modes,
10197 .need_dac_fix = 1,
10198 .input_mux = &alc883_3stack_6ch_intel,
10199 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010200 [ALC889A_INTEL] = {
10201 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020010202 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
10203 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,
10216 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010217 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010218 .need_dac_fix = 1,
10219 },
10220 [ALC889_INTEL] = {
10221 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
10222 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010223 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010224 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10225 .dac_nids = alc883_dac_nids,
10226 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10227 .adc_nids = alc889_adc_nids,
10228 .dig_out_nid = ALC883_DIGOUT_NID,
10229 .dig_in_nid = ALC883_DIGIN_NID,
10230 .slave_dig_outs = alc883_slave_dig_outs,
10231 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10232 .channel_mode = alc889_8ch_intel_modes,
10233 .capsrc_nids = alc889_capsrc_nids,
10234 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010235 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010236 .init_hook = alc889_intel_init_hook,
10237 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010238 .need_dac_fix = 1,
10239 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010240 [ALC883_6ST_DIG] = {
10241 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10242 .init_verbs = { alc883_init_verbs },
10243 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10244 .dac_nids = alc883_dac_nids,
10245 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010246 .dig_in_nid = ALC883_DIGIN_NID,
10247 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10248 .channel_mode = alc883_sixstack_modes,
10249 .input_mux = &alc883_capture_source,
10250 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010251 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010252 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010253 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10254 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010255 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10256 .dac_nids = alc883_dac_nids,
10257 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010258 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10259 .channel_mode = alc883_3ST_6ch_modes,
10260 .need_dac_fix = 1,
10261 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010262 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010263 .setup = alc882_targa_setup,
10264 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010265 },
10266 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010267 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010268 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10269 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010270 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10271 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010272 .adc_nids = alc883_adc_nids_alt,
10273 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010274 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010275 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010276 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10277 .channel_mode = alc883_3ST_2ch_modes,
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,
Kailang Yangccc656c2006-10-17 12:32:26 +020010282 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010283 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010284 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10285 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010286 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010287 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010288 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10289 .dac_nids = alc883_dac_nids,
10290 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10291 .adc_nids = alc883_adc_nids_rev,
10292 .capsrc_nids = alc883_capsrc_nids_rev,
10293 .dig_out_nid = ALC883_DIGOUT_NID,
10294 .dig_in_nid = ALC883_DIGIN_NID,
10295 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10296 .channel_mode = alc883_4ST_8ch_modes,
10297 .need_dac_fix = 1,
10298 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010299 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010300 .setup = alc882_targa_setup,
10301 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010302 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010303 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010304 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010305 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10306 * and the headphone jack. Turn this on and rely on the
10307 * standard mute methods whenever the user wants to turn
10308 * these outputs off.
10309 */
10310 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10311 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10312 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010313 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10314 .channel_mode = alc883_3ST_2ch_modes,
10315 .input_mux = &alc883_capture_source,
10316 },
Tobin Davis2880a862007-08-07 11:50:26 +020010317 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010318 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010319 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010320 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10321 .dac_nids = alc883_dac_nids,
10322 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010323 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10324 .channel_mode = alc883_3ST_2ch_modes,
10325 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010326 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010327 .setup = alc883_acer_aspire_setup,
10328 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010329 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010330 [ALC888_ACER_ASPIRE_4930G] = {
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +010010331 .mixers = { alc888_acer_aspire_4930g_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010332 alc883_chmode_mixer },
10333 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10334 alc888_acer_aspire_4930g_verbs },
10335 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10336 .dac_nids = alc883_dac_nids,
10337 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10338 .adc_nids = alc883_adc_nids_rev,
10339 .capsrc_nids = alc883_capsrc_nids_rev,
10340 .dig_out_nid = ALC883_DIGOUT_NID,
10341 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10342 .channel_mode = alc883_3ST_6ch_modes,
10343 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010344 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010345 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010346 ARRAY_SIZE(alc888_2_capture_sources),
10347 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010348 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010349 .setup = alc888_acer_aspire_4930g_setup,
10350 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010351 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010352 [ALC888_ACER_ASPIRE_6530G] = {
10353 .mixers = { alc888_acer_aspire_6530_mixer },
10354 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10355 alc888_acer_aspire_6530g_verbs },
10356 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10357 .dac_nids = alc883_dac_nids,
10358 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10359 .adc_nids = alc883_adc_nids_rev,
10360 .capsrc_nids = alc883_capsrc_nids_rev,
10361 .dig_out_nid = ALC883_DIGOUT_NID,
10362 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10363 .channel_mode = alc883_3ST_2ch_modes,
10364 .num_mux_defs =
10365 ARRAY_SIZE(alc888_2_capture_sources),
10366 .input_mux = alc888_acer_aspire_6530_sources,
10367 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010368 .setup = alc888_acer_aspire_6530g_setup,
10369 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010370 },
Hector Martin3b315d72009-06-02 10:54:19 +020010371 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010372 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010373 alc883_chmode_mixer },
10374 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010375 alc889_acer_aspire_8930g_verbs,
10376 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010377 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10378 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010379 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10380 .adc_nids = alc889_adc_nids,
10381 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010382 .dig_out_nid = ALC883_DIGOUT_NID,
10383 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10384 .channel_mode = alc883_3ST_6ch_modes,
10385 .need_dac_fix = 1,
10386 .const_channel_count = 6,
10387 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010388 ARRAY_SIZE(alc889_capture_sources),
10389 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +020010390 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010391 .setup = alc889_acer_aspire_8930g_setup,
10392 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +010010393#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010394 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010395#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010396 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010397 [ALC888_ACER_ASPIRE_7730G] = {
10398 .mixers = { alc883_3ST_6ch_mixer,
10399 alc883_chmode_mixer },
10400 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10401 alc888_acer_aspire_7730G_verbs },
10402 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10403 .dac_nids = alc883_dac_nids,
10404 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10405 .adc_nids = alc883_adc_nids_rev,
10406 .capsrc_nids = alc883_capsrc_nids_rev,
10407 .dig_out_nid = ALC883_DIGOUT_NID,
10408 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10409 .channel_mode = alc883_3ST_6ch_modes,
10410 .need_dac_fix = 1,
10411 .const_channel_count = 6,
10412 .input_mux = &alc883_capture_source,
10413 .unsol_event = alc_automute_amp_unsol_event,
Denis Kuplyakovd9477202010-11-24 06:01:09 +010010414 .setup = alc888_acer_aspire_7730g_setup,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010415 .init_hook = alc_automute_amp,
10416 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010417 [ALC883_MEDION] = {
10418 .mixers = { alc883_fivestack_mixer,
10419 alc883_chmode_mixer },
10420 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010421 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010422 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10423 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010424 .adc_nids = alc883_adc_nids_alt,
10425 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010426 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010427 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10428 .channel_mode = alc883_sixstack_modes,
10429 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010430 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010431 [ALC883_MEDION_WIM2160] = {
10432 .mixers = { alc883_medion_wim2160_mixer },
10433 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10434 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10435 .dac_nids = alc883_dac_nids,
10436 .dig_out_nid = ALC883_DIGOUT_NID,
10437 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10438 .adc_nids = alc883_adc_nids,
10439 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10440 .channel_mode = alc883_3ST_2ch_modes,
10441 .input_mux = &alc883_capture_source,
10442 .unsol_event = alc_automute_amp_unsol_event,
10443 .setup = alc883_medion_wim2160_setup,
10444 .init_hook = alc_automute_amp,
10445 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010446 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010447 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010448 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10449 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10450 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010451 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10452 .channel_mode = alc883_3ST_2ch_modes,
10453 .input_mux = &alc883_capture_source,
10454 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010455 [ALC883_CLEVO_M540R] = {
10456 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10457 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10458 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10459 .dac_nids = alc883_dac_nids,
10460 .dig_out_nid = ALC883_DIGOUT_NID,
10461 .dig_in_nid = ALC883_DIGIN_NID,
10462 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10463 .channel_mode = alc883_3ST_6ch_clevo_modes,
10464 .need_dac_fix = 1,
10465 .input_mux = &alc883_capture_source,
10466 /* This machine has the hardware HP auto-muting, thus
10467 * we need no software mute via unsol event
10468 */
10469 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010470 [ALC883_CLEVO_M720] = {
10471 .mixers = { alc883_clevo_m720_mixer },
10472 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010473 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10474 .dac_nids = alc883_dac_nids,
10475 .dig_out_nid = ALC883_DIGOUT_NID,
10476 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10477 .channel_mode = alc883_3ST_2ch_modes,
10478 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010479 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010480 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010481 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010482 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010483 [ALC883_LENOVO_101E_2ch] = {
10484 .mixers = { alc883_lenovo_101e_2ch_mixer},
10485 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10486 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10487 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010488 .adc_nids = alc883_adc_nids_alt,
10489 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010490 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010491 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10492 .channel_mode = alc883_3ST_2ch_modes,
10493 .input_mux = &alc883_lenovo_101e_capture_source,
10494 .unsol_event = alc883_lenovo_101e_unsol_event,
10495 .init_hook = alc883_lenovo_101e_all_automute,
10496 },
Kailang Yang272a5272007-05-14 11:00:38 +020010497 [ALC883_LENOVO_NB0763] = {
10498 .mixers = { alc883_lenovo_nb0763_mixer },
10499 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10500 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10501 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010502 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10503 .channel_mode = alc883_3ST_2ch_modes,
10504 .need_dac_fix = 1,
10505 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010506 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwaidc4271702010-11-29 07:42:59 +010010507 .setup = alc883_lenovo_nb0763_setup,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010508 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010509 },
10510 [ALC888_LENOVO_MS7195_DIG] = {
10511 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10512 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10513 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10514 .dac_nids = alc883_dac_nids,
10515 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010516 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10517 .channel_mode = alc883_3ST_6ch_modes,
10518 .need_dac_fix = 1,
10519 .input_mux = &alc883_capture_source,
10520 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10521 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010522 },
10523 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010524 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010525 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10526 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10527 .dac_nids = alc883_dac_nids,
10528 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010529 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10530 .channel_mode = alc883_3ST_2ch_modes,
10531 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010532 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010533 .setup = alc883_haier_w66_setup,
10534 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010535 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010536 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010537 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010538 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010539 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10540 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010541 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10542 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010543 .need_dac_fix = 1,
10544 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010545 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010546 .setup = alc888_3st_hp_setup,
10547 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010548 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010549 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010550 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010551 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10552 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10553 .dac_nids = alc883_dac_nids,
10554 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010555 .dig_in_nid = ALC883_DIGIN_NID,
10556 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10557 .channel_mode = alc883_sixstack_modes,
10558 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010559 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010560 .setup = alc888_6st_dell_setup,
10561 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010562 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010563 [ALC883_MITAC] = {
10564 .mixers = { alc883_mitac_mixer },
10565 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10566 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10567 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010568 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10569 .channel_mode = alc883_3ST_2ch_modes,
10570 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010571 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010572 .setup = alc883_mitac_setup,
10573 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010574 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010575 [ALC883_FUJITSU_PI2515] = {
10576 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10577 .init_verbs = { alc883_init_verbs,
10578 alc883_2ch_fujitsu_pi2515_verbs},
10579 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10580 .dac_nids = alc883_dac_nids,
10581 .dig_out_nid = ALC883_DIGOUT_NID,
10582 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10583 .channel_mode = alc883_3ST_2ch_modes,
10584 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010585 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010586 .setup = alc883_2ch_fujitsu_pi2515_setup,
10587 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010588 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010589 [ALC888_FUJITSU_XA3530] = {
10590 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10591 .init_verbs = { alc883_init_verbs,
10592 alc888_fujitsu_xa3530_verbs },
10593 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10594 .dac_nids = alc883_dac_nids,
10595 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10596 .adc_nids = alc883_adc_nids_rev,
10597 .capsrc_nids = alc883_capsrc_nids_rev,
10598 .dig_out_nid = ALC883_DIGOUT_NID,
10599 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10600 .channel_mode = alc888_4ST_8ch_intel_modes,
10601 .num_mux_defs =
10602 ARRAY_SIZE(alc888_2_capture_sources),
10603 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010604 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010605 .setup = alc888_fujitsu_xa3530_setup,
10606 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010607 },
Kailang Yange2757d52008-08-26 13:17:46 +020010608 [ALC888_LENOVO_SKY] = {
10609 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10610 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10611 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10612 .dac_nids = alc883_dac_nids,
10613 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010614 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10615 .channel_mode = alc883_sixstack_modes,
10616 .need_dac_fix = 1,
10617 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010618 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010619 .setup = alc888_lenovo_sky_setup,
10620 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010621 },
10622 [ALC888_ASUS_M90V] = {
10623 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10624 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10625 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10626 .dac_nids = alc883_dac_nids,
10627 .dig_out_nid = ALC883_DIGOUT_NID,
10628 .dig_in_nid = ALC883_DIGIN_NID,
10629 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10630 .channel_mode = alc883_3ST_6ch_modes,
10631 .need_dac_fix = 1,
10632 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010633 .unsol_event = alc_sku_unsol_event,
10634 .setup = alc883_mode2_setup,
10635 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010636 },
10637 [ALC888_ASUS_EEE1601] = {
10638 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010639 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010640 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10641 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10642 .dac_nids = alc883_dac_nids,
10643 .dig_out_nid = ALC883_DIGOUT_NID,
10644 .dig_in_nid = ALC883_DIGIN_NID,
10645 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10646 .channel_mode = alc883_3ST_2ch_modes,
10647 .need_dac_fix = 1,
10648 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010649 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010650 .init_hook = alc883_eee1601_inithook,
10651 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010652 [ALC1200_ASUS_P5Q] = {
10653 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10654 .init_verbs = { alc883_init_verbs },
10655 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10656 .dac_nids = alc883_dac_nids,
10657 .dig_out_nid = ALC1200_DIGOUT_NID,
10658 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010659 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010660 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10661 .channel_mode = alc883_sixstack_modes,
10662 .input_mux = &alc883_capture_source,
10663 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010664 [ALC889A_MB31] = {
10665 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10666 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10667 alc880_gpio1_init_verbs },
10668 .adc_nids = alc883_adc_nids,
10669 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010670 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010671 .dac_nids = alc883_dac_nids,
10672 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10673 .channel_mode = alc889A_mb31_6ch_modes,
10674 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10675 .input_mux = &alc889A_mb31_capture_source,
10676 .dig_out_nid = ALC883_DIGOUT_NID,
10677 .unsol_event = alc889A_mb31_unsol_event,
10678 .init_hook = alc889A_mb31_automute,
10679 },
Guido Günther3e1647c52009-06-05 00:47:26 +020010680 [ALC883_SONY_VAIO_TT] = {
10681 .mixers = { alc883_vaiott_mixer },
10682 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10683 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10684 .dac_nids = alc883_dac_nids,
10685 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10686 .channel_mode = alc883_3ST_2ch_modes,
10687 .input_mux = &alc883_capture_source,
10688 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010689 .setup = alc883_vaiott_setup,
10690 .init_hook = alc_automute_amp,
Guido Günther3e1647c52009-06-05 00:47:26 +020010691 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010692};
10693
10694
10695/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010696 * Pin config fixes
10697 */
10698enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010699 PINFIX_ABIT_AW9D_MAX,
David Henningsson32eea382011-03-04 13:37:50 +010010700 PINFIX_LENOVO_Y530,
Takashi Iwai954a29c2010-07-30 10:55:44 +020010701 PINFIX_PB_M5210,
David Henningssonc3d226a2010-10-14 15:42:08 +020010702 PINFIX_ACER_ASPIRE_7736,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010703};
10704
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010705static const struct alc_fixup alc882_fixups[] = {
10706 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010707 .type = ALC_FIXUP_PINS,
10708 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020010709 { 0x15, 0x01080104 }, /* side */
10710 { 0x16, 0x01011012 }, /* rear */
10711 { 0x17, 0x01016011 }, /* clfe */
10712 { }
10713 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010714 },
David Henningsson32eea382011-03-04 13:37:50 +010010715 [PINFIX_LENOVO_Y530] = {
10716 .type = ALC_FIXUP_PINS,
10717 .v.pins = (const struct alc_pincfg[]) {
10718 { 0x15, 0x99130112 }, /* rear int speakers */
10719 { 0x16, 0x99130111 }, /* subwoofer */
10720 { }
10721 }
10722 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010723 [PINFIX_PB_M5210] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010724 .type = ALC_FIXUP_VERBS,
10725 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020010726 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10727 {}
10728 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020010729 },
David Henningssonc3d226a2010-10-14 15:42:08 +020010730 [PINFIX_ACER_ASPIRE_7736] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010731 .type = ALC_FIXUP_SKU,
10732 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonc3d226a2010-10-14 15:42:08 +020010733 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010734};
10735
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010736static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010737 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
David Henningsson32eea382011-03-04 13:37:50 +010010738 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", PINFIX_LENOVO_Y530),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010739 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
David Henningssonc3d226a2010-10-14 15:42:08 +020010740 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010741 {}
10742};
10743
10744/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010745 * BIOS auto configuration
10746 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010747static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10748 const struct auto_pin_cfg *cfg)
10749{
10750 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10751}
10752
Takashi Iwai4953550a2009-06-30 15:28:30 +020010753static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010754 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010755 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010756{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010757 int idx;
10758
Takashi Iwai489008c2010-04-07 09:06:00 +020010759 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010760 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010761
Takashi Iwai489008c2010-04-07 09:06:00 +020010762 if (dac == 0x25)
10763 idx = 4;
10764 else if (dac >= 0x02 && dac <= 0x05)
10765 idx = dac - 2;
10766 else
10767 return;
10768 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010769}
10770
Takashi Iwai4953550a2009-06-30 15:28:30 +020010771static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010772{
10773 struct alc_spec *spec = codec->spec;
10774 int i;
10775
10776 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010777 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010778 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010779 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010780 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010781 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010782 }
10783}
10784
Takashi Iwai4953550a2009-06-30 15:28:30 +020010785static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010786{
10787 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010788 hda_nid_t pin, dac;
Takashi Iwai5855fb82010-09-16 18:24:02 +020010789 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010790
David Henningsson0a3fabe2011-03-04 16:54:52 +010010791 if (spec->autocfg.line_out_type != AUTO_PIN_HP_OUT) {
10792 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
10793 pin = spec->autocfg.hp_pins[i];
10794 if (!pin)
10795 break;
10796 dac = spec->multiout.hp_nid;
10797 if (!dac)
10798 dac = spec->multiout.dac_nids[0]; /* to front */
10799 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10800 }
Takashi Iwai489008c2010-04-07 09:06:00 +020010801 }
David Henningsson0a3fabe2011-03-04 16:54:52 +010010802
10803 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT) {
10804 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
10805 pin = spec->autocfg.speaker_pins[i];
10806 if (!pin)
10807 break;
10808 dac = spec->multiout.extra_out_nid[0];
10809 if (!dac)
10810 dac = spec->multiout.dac_nids[0]; /* to front */
10811 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10812 }
Takashi Iwai489008c2010-04-07 09:06:00 +020010813 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010814}
10815
Takashi Iwai4953550a2009-06-30 15:28:30 +020010816static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010817{
10818 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010819 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010820 int i;
10821
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010822 for (i = 0; i < cfg->num_inputs; i++) {
10823 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai30ea0982010-09-16 18:47:56 +020010824 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010825 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10826 snd_hda_codec_write(codec, nid, 0,
10827 AC_VERB_SET_AMP_GAIN_MUTE,
10828 AMP_OUT_MUTE);
10829 }
10830}
10831
10832static void alc882_auto_init_input_src(struct hda_codec *codec)
10833{
10834 struct alc_spec *spec = codec->spec;
10835 int c;
10836
10837 for (c = 0; c < spec->num_adc_nids; c++) {
10838 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10839 hda_nid_t nid = spec->capsrc_nids[c];
10840 unsigned int mux_idx;
10841 const struct hda_input_mux *imux;
10842 int conns, mute, idx, item;
10843
10844 conns = snd_hda_get_connections(codec, nid, conn_list,
10845 ARRAY_SIZE(conn_list));
10846 if (conns < 0)
10847 continue;
10848 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10849 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010850 if (!imux->num_items && mux_idx > 0)
10851 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010852 for (idx = 0; idx < conns; idx++) {
10853 /* if the current connection is the selected one,
10854 * unmute it as default - otherwise mute it
10855 */
10856 mute = AMP_IN_MUTE(idx);
10857 for (item = 0; item < imux->num_items; item++) {
10858 if (imux->items[item].index == idx) {
10859 if (spec->cur_mux[c] == item)
10860 mute = AMP_IN_UNMUTE(idx);
10861 break;
10862 }
10863 }
10864 /* check if we have a selector or mixer
10865 * we could check for the widget type instead, but
10866 * just check for Amp-In presence (in case of mixer
10867 * without amp-in there is something wrong, this
10868 * function shouldn't be used or capsrc nid is wrong)
10869 */
10870 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010871 snd_hda_codec_write(codec, nid, 0,
10872 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010873 mute);
10874 else if (mute != AMP_IN_MUTE(idx))
10875 snd_hda_codec_write(codec, nid, 0,
10876 AC_VERB_SET_CONNECT_SEL,
10877 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010878 }
10879 }
10880}
10881
Takashi Iwai4953550a2009-06-30 15:28:30 +020010882/* add mic boosts if needed */
10883static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010884{
10885 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010886 struct auto_pin_cfg *cfg = &spec->autocfg;
David Henningsson5322bf22011-01-05 11:03:56 +010010887 int i, err;
Takashi Iwai53e8c322010-12-17 15:23:41 +010010888 int type_idx = 0;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010889 hda_nid_t nid;
David Henningsson5322bf22011-01-05 11:03:56 +010010890 const char *prev_label = NULL;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010891
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010892 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020010893 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010894 break;
10895 nid = cfg->inputs[i].pin;
10896 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
David Henningsson5322bf22011-01-05 11:03:56 +010010897 const char *label;
10898 char boost_label[32];
10899
10900 label = hda_get_autocfg_input_label(codec, cfg, i);
10901 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai53e8c322010-12-17 15:23:41 +010010902 type_idx++;
10903 else
10904 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +010010905 prev_label = label;
10906
10907 snprintf(boost_label, sizeof(boost_label),
10908 "%s Boost Volume", label);
10909 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10910 boost_label, type_idx,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010911 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010912 if (err < 0)
10913 return err;
10914 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010915 }
10916 return 0;
10917}
10918
10919/* almost identical with ALC880 parser... */
10920static int alc882_parse_auto_config(struct hda_codec *codec)
10921{
10922 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010923 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020010924 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010925
Takashi Iwai05f5f472009-08-25 13:10:18 +020010926 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10927 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010928 if (err < 0)
10929 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010930 if (!spec->autocfg.line_outs)
10931 return 0; /* can't find valid BIOS pin config */
10932
10933 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10934 if (err < 0)
10935 return err;
Takashi Iwai569ed342011-01-19 10:14:46 +010010936 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010937 if (err < 0)
10938 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010939 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10940 "Headphone");
10941 if (err < 0)
10942 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010943 err = alc880_auto_create_extra_out(spec,
10944 spec->autocfg.speaker_pins[0],
10945 "Speaker");
10946 if (err < 0)
10947 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010948 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10949 if (err < 0)
10950 return err;
10951
10952 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10953
Takashi Iwai757899a2010-07-30 10:48:14 +020010954 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010955
10956 if (spec->kctls.list)
10957 add_mixer(spec, spec->kctls.list);
10958
10959 add_verb(spec, alc883_auto_init_verbs);
10960 /* if ADC 0x07 is available, initialize it, too */
10961 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10962 add_verb(spec, alc882_adc1_init_verbs);
10963
10964 spec->num_mux_defs = 1;
10965 spec->input_mux = &spec->private_imux[0];
10966
Kailang Yang6227cdc2010-02-25 08:36:52 +010010967 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010968
10969 err = alc_auto_add_mic_boost(codec);
10970 if (err < 0)
10971 return err;
10972
Takashi Iwai776e1842007-08-29 15:07:11 +020010973 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010974}
10975
10976/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010977static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010978{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010979 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010980 alc882_auto_init_multi_out(codec);
10981 alc882_auto_init_hp_out(codec);
10982 alc882_auto_init_analog_input(codec);
10983 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020010984 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010985 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010986 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010987}
10988
Takashi Iwai4953550a2009-06-30 15:28:30 +020010989static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010990{
10991 struct alc_spec *spec;
10992 int err, board_config;
10993
10994 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10995 if (spec == NULL)
10996 return -ENOMEM;
10997
10998 codec->spec = spec;
10999
Takashi Iwai4953550a2009-06-30 15:28:30 +020011000 switch (codec->vendor_id) {
11001 case 0x10ec0882:
11002 case 0x10ec0885:
11003 break;
11004 default:
11005 /* ALC883 and variants */
11006 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11007 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011008 }
11009
Takashi Iwai4953550a2009-06-30 15:28:30 +020011010 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
11011 alc882_models,
11012 alc882_cfg_tbl);
11013
11014 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
11015 board_config = snd_hda_check_board_codec_sid_config(codec,
11016 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
11017
11018 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011019 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020011020 codec->chip_name);
11021 board_config = ALC882_AUTO;
11022 }
11023
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011024 if (board_config == ALC882_AUTO) {
11025 alc_pick_fixup(codec, NULL, alc882_fixup_tbl, alc882_fixups);
11026 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
11027 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011028
David Henningsson90622912010-10-14 14:50:18 +020011029 alc_auto_parse_customize_define(codec);
11030
Takashi Iwai4953550a2009-06-30 15:28:30 +020011031 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011032 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020011033 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011034 if (err < 0) {
11035 alc_free(codec);
11036 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011037 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011038 printk(KERN_INFO
11039 "hda_codec: Cannot set up configuration "
11040 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020011041 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011042 }
11043 }
11044
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011045 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020011046 err = snd_hda_attach_beep_device(codec, 0x1);
11047 if (err < 0) {
11048 alc_free(codec);
11049 return err;
11050 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011051 }
11052
Takashi Iwai4953550a2009-06-30 15:28:30 +020011053 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011054 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011055
Takashi Iwai4953550a2009-06-30 15:28:30 +020011056 spec->stream_analog_playback = &alc882_pcm_analog_playback;
11057 spec->stream_analog_capture = &alc882_pcm_analog_capture;
11058 /* FIXME: setup DAC5 */
11059 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
11060 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
11061
11062 spec->stream_digital_playback = &alc882_pcm_digital_playback;
11063 spec->stream_digital_capture = &alc882_pcm_digital_capture;
11064
Takashi Iwai4953550a2009-06-30 15:28:30 +020011065 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011066 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011067 spec->num_adc_nids = 0;
11068 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011069 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011070 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011071 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020011072 hda_nid_t nid = alc882_adc_nids[i];
11073 unsigned int wcap = get_wcaps(codec, nid);
11074 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011075 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020011076 if (wcap != AC_WID_AUD_IN)
11077 continue;
11078 spec->private_adc_nids[spec->num_adc_nids] = nid;
11079 err = snd_hda_get_connections(codec, nid, &cap, 1);
11080 if (err < 0)
11081 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011082 err = snd_hda_get_connections(codec, cap, items,
11083 ARRAY_SIZE(items));
11084 if (err < 0)
11085 continue;
11086 for (j = 0; j < imux->num_items; j++)
11087 if (imux->items[j].index >= err)
11088 break;
11089 if (j < imux->num_items)
11090 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011091 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
11092 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011093 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011094 spec->adc_nids = spec->private_adc_nids;
11095 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020011096 }
11097
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011098 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010011099
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011100 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010011101 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011102
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011103 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020011104
Takashi Iwai2134ea42008-01-10 16:53:55 +010011105 spec->vmaster_nid = 0x0c;
11106
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011107 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011108 if (board_config == ALC882_AUTO)
11109 spec->init_hook = alc882_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020011110
11111 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020011112#ifdef CONFIG_SND_HDA_POWER_SAVE
11113 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020011114 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011115#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011116
11117 return 0;
11118}
11119
Takashi Iwai4953550a2009-06-30 15:28:30 +020011120
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011121/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011122 * ALC262 support
11123 */
11124
11125#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
11126#define ALC262_DIGIN_NID ALC880_DIGIN_NID
11127
11128#define alc262_dac_nids alc260_dac_nids
11129#define alc262_adc_nids alc882_adc_nids
11130#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010011131#define alc262_capsrc_nids alc882_capsrc_nids
11132#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010011133
11134#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010011135#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010011136
Kailang Yang4e555fe2008-08-26 13:05:55 +020011137static hda_nid_t alc262_dmic_adc_nids[1] = {
11138 /* ADC0 */
11139 0x09
11140};
11141
11142static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
11143
Kailang Yangdf694da2005-12-05 19:42:22 +010011144static struct snd_kcontrol_new alc262_base_mixer[] = {
11145 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11146 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11147 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11148 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11149 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11150 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11151 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11152 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011153 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011154 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11155 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011156 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011157 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
11158 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11159 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
11160 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011161 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010011162};
11163
Takashi Iwaice875f02008-01-28 18:17:43 +010011164/* update HP, line and mono-out pins according to the master switch */
11165static void alc262_hp_master_update(struct hda_codec *codec)
11166{
11167 struct alc_spec *spec = codec->spec;
11168 int val = spec->master_sw;
11169
11170 /* HP & line-out */
11171 snd_hda_codec_write_cache(codec, 0x1b, 0,
11172 AC_VERB_SET_PIN_WIDGET_CONTROL,
11173 val ? PIN_HP : 0);
11174 snd_hda_codec_write_cache(codec, 0x15, 0,
11175 AC_VERB_SET_PIN_WIDGET_CONTROL,
11176 val ? PIN_HP : 0);
11177 /* mono (speaker) depending on the HP jack sense */
11178 val = val && !spec->jack_present;
11179 snd_hda_codec_write_cache(codec, 0x16, 0,
11180 AC_VERB_SET_PIN_WIDGET_CONTROL,
11181 val ? PIN_OUT : 0);
11182}
11183
11184static void alc262_hp_bpc_automute(struct hda_codec *codec)
11185{
11186 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011187
11188 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010011189 alc262_hp_master_update(codec);
11190}
11191
11192static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
11193{
11194 if ((res >> 26) != ALC880_HP_EVENT)
11195 return;
11196 alc262_hp_bpc_automute(codec);
11197}
11198
11199static void alc262_hp_wildwest_automute(struct hda_codec *codec)
11200{
11201 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011202
11203 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010011204 alc262_hp_master_update(codec);
11205}
11206
11207static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
11208 unsigned int res)
11209{
11210 if ((res >> 26) != ALC880_HP_EVENT)
11211 return;
11212 alc262_hp_wildwest_automute(codec);
11213}
11214
Takashi Iwaib72519b2009-05-08 14:31:55 +020011215#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010011216
11217static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
11218 struct snd_ctl_elem_value *ucontrol)
11219{
11220 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11221 struct alc_spec *spec = codec->spec;
11222 int val = !!*ucontrol->value.integer.value;
11223
11224 if (val == spec->master_sw)
11225 return 0;
11226 spec->master_sw = val;
11227 alc262_hp_master_update(codec);
11228 return 1;
11229}
11230
Takashi Iwaib72519b2009-05-08 14:31:55 +020011231#define ALC262_HP_MASTER_SWITCH \
11232 { \
11233 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11234 .name = "Master Playback Switch", \
11235 .info = snd_ctl_boolean_mono_info, \
11236 .get = alc262_hp_master_sw_get, \
11237 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011238 }, \
11239 { \
11240 .iface = NID_MAPPING, \
11241 .name = "Master Playback Switch", \
11242 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020011243 }
11244
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011245
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011246static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011247 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011248 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11249 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11250 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 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),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011255 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11256 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011257 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011258 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11259 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011260 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011261 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11262 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11263 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11264 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011265 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
11266 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
11267 { } /* end */
11268};
11269
Kailang Yangcd7509a2007-01-26 18:33:17 +010011270static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011271 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010011272 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11273 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11274 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11275 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011276 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11277 HDA_OUTPUT),
11278 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11279 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011280 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11281 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011282 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011283 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11284 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11285 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11286 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011287 { } /* end */
11288};
11289
11290static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11291 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11292 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011293 HDA_CODEC_VOLUME("Rear Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011294 { } /* end */
11295};
11296
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011297/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011298static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011299{
11300 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011301
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011302 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011303 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011304}
11305
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011306static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011307 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11308 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011309 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11310 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11311 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11312 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011313 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011314 { } /* end */
11315};
11316
11317static struct hda_verb alc262_hp_t5735_verbs[] = {
11318 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11319 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11320
11321 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11322 { }
11323};
11324
Kailang Yang8c427222008-01-10 13:03:59 +010011325static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011326 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11327 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011328 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11329 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011330 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11331 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11332 { } /* end */
11333};
11334
11335static struct hda_verb alc262_hp_rp5700_verbs[] = {
11336 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11337 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11338 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11339 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11340 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11341 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11342 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11343 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11344 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11345 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11346 {}
11347};
11348
11349static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11350 .num_items = 1,
11351 .items = {
11352 { "Line", 0x1 },
11353 },
11354};
11355
Takashi Iwai42171c12009-05-08 14:11:43 +020011356/* bind hp and internal speaker mute (with plug check) as master switch */
11357static void alc262_hippo_master_update(struct hda_codec *codec)
11358{
11359 struct alc_spec *spec = codec->spec;
11360 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11361 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11362 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11363 unsigned int mute;
11364
11365 /* HP */
11366 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11367 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11368 HDA_AMP_MUTE, mute);
11369 /* mute internal speaker per jack sense */
11370 if (spec->jack_present)
11371 mute = HDA_AMP_MUTE;
11372 if (line_nid)
11373 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11374 HDA_AMP_MUTE, mute);
11375 if (speaker_nid && speaker_nid != line_nid)
11376 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11377 HDA_AMP_MUTE, mute);
11378}
11379
11380#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
11381
11382static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11383 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020011384{
11385 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020011386 struct alc_spec *spec = codec->spec;
11387 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011388
Takashi Iwai42171c12009-05-08 14:11:43 +020011389 if (val == spec->master_sw)
11390 return 0;
11391 spec->master_sw = val;
11392 alc262_hippo_master_update(codec);
11393 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011394}
Takashi Iwai5b319542007-07-26 11:49:22 +020011395
Takashi Iwai42171c12009-05-08 14:11:43 +020011396#define ALC262_HIPPO_MASTER_SWITCH \
11397 { \
11398 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11399 .name = "Master Playback Switch", \
11400 .info = snd_ctl_boolean_mono_info, \
11401 .get = alc262_hippo_master_sw_get, \
11402 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011403 }, \
11404 { \
11405 .iface = NID_MAPPING, \
11406 .name = "Master Playback Switch", \
11407 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11408 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011409 }
11410
11411static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11412 ALC262_HIPPO_MASTER_SWITCH,
11413 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11414 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11415 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11416 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11417 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11418 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11419 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011420 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011421 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11422 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011423 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011424 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11425 { } /* end */
11426};
11427
11428static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11429 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11430 ALC262_HIPPO_MASTER_SWITCH,
11431 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11432 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11433 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11434 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11435 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11436 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011437 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011438 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11439 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011440 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011441 { } /* end */
11442};
11443
11444/* mute/unmute internal speaker according to the hp jack and mute state */
11445static void alc262_hippo_automute(struct hda_codec *codec)
11446{
11447 struct alc_spec *spec = codec->spec;
11448 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020011449
Wu Fengguang864f92b2009-11-18 12:38:02 +080011450 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020011451 alc262_hippo_master_update(codec);
11452}
11453
11454static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11455{
11456 if ((res >> 26) != ALC880_HP_EVENT)
11457 return;
11458 alc262_hippo_automute(codec);
11459}
11460
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011461static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011462{
11463 struct alc_spec *spec = codec->spec;
11464
11465 spec->autocfg.hp_pins[0] = 0x15;
11466 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011467}
11468
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011469static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011470{
11471 struct alc_spec *spec = codec->spec;
11472
11473 spec->autocfg.hp_pins[0] = 0x1b;
11474 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011475}
11476
11477
Kailang Yang272a5272007-05-14 11:00:38 +020011478static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011479 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011480 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011481 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11482 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11483 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11484 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11485 { } /* end */
11486};
11487
Kailang Yang83c34212007-07-05 11:43:05 +020011488static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011489 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11490 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011491 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11492 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11493 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11494 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11495 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11496 { } /* end */
11497};
Kailang Yang272a5272007-05-14 11:00:38 +020011498
Tony Vroonba340e82009-02-02 19:01:30 +000011499static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11500 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11501 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11502 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11503 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11504 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11505 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11506 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11507 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011508 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011509 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11510 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011511 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011512 { } /* end */
11513};
11514
11515static struct hda_verb alc262_tyan_verbs[] = {
11516 /* Headphone automute */
11517 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11518 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11519 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11520
11521 /* P11 AUX_IN, white 4-pin connector */
11522 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11523 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11524 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11525 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11526
11527 {}
11528};
11529
11530/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011531static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011532{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011533 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011534
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011535 spec->autocfg.hp_pins[0] = 0x1b;
11536 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011537}
11538
Tony Vroonba340e82009-02-02 19:01:30 +000011539
Kailang Yangdf694da2005-12-05 19:42:22 +010011540#define alc262_capture_mixer alc882_capture_mixer
11541#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11542
11543/*
11544 * generic initialization of ADC, input mixers and output mixers
11545 */
11546static struct hda_verb alc262_init_verbs[] = {
11547 /*
11548 * Unmute ADC0-2 and set the default input to mic-in
11549 */
11550 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11551 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11552 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11553 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11554 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11555 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11556
Takashi Iwaicb53c622007-08-10 17:21:45 +020011557 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011558 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011559 * Note: PASD motherboards uses the Line In 2 as the input for
11560 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011561 */
11562 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011563 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11564 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11565 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11566 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11567 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011568
11569 /*
11570 * Set up output mixers (0x0c - 0x0e)
11571 */
11572 /* set vol=0 to output mixers */
11573 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11574 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11575 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11576 /* set up input amps for analog loopback */
11577 /* Amp Indices: DAC = 0, mixer = 1 */
11578 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11579 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11580 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11581 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11582 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11583 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11584
11585 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11586 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11587 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11588 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11589 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11590 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11591
11592 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11593 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11594 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11595 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11596 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011597
Kailang Yangdf694da2005-12-05 19:42:22 +010011598 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11599 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011600
Kailang Yangdf694da2005-12-05 19:42:22 +010011601 /* FIXME: use matrix-type input source selection */
11602 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11603 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11604 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11605 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11606 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11607 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11608 /* Input mixer2 */
11609 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11610 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11611 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11612 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11613 /* Input mixer3 */
11614 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11615 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11616 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011617 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011618
11619 { }
11620};
11621
Kailang Yang4e555fe2008-08-26 13:05:55 +020011622static struct hda_verb alc262_eapd_verbs[] = {
11623 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11624 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11625 { }
11626};
11627
Kailang Yangccc656c2006-10-17 12:32:26 +020011628static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11629 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11630 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11631 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11632
11633 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11634 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11635 {}
11636};
11637
Kailang Yang272a5272007-05-14 11:00:38 +020011638static struct hda_verb alc262_sony_unsol_verbs[] = {
11639 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11640 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11641 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11642
11643 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11644 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011645 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011646};
11647
Kailang Yang4e555fe2008-08-26 13:05:55 +020011648static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11649 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11650 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11651 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11652 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11653 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011654 { } /* end */
11655};
11656
11657static struct hda_verb alc262_toshiba_s06_verbs[] = {
11658 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11659 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11660 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11661 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11662 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11663 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11664 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11665 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11666 {}
11667};
11668
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011669static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011670{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011671 struct alc_spec *spec = codec->spec;
11672
11673 spec->autocfg.hp_pins[0] = 0x15;
11674 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011675 spec->ext_mic.pin = 0x18;
11676 spec->ext_mic.mux_idx = 0;
11677 spec->int_mic.pin = 0x12;
11678 spec->int_mic.mux_idx = 9;
11679 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011680}
11681
Takashi Iwai834be882006-03-01 14:16:17 +010011682/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011683 * nec model
11684 * 0x15 = headphone
11685 * 0x16 = internal speaker
11686 * 0x18 = external mic
11687 */
11688
11689static struct snd_kcontrol_new alc262_nec_mixer[] = {
11690 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11691 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11692
11693 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11694 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011695 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011696
11697 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11698 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11699 { } /* end */
11700};
11701
11702static struct hda_verb alc262_nec_verbs[] = {
11703 /* Unmute Speaker */
11704 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11705
11706 /* Headphone */
11707 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11708 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11709
11710 /* External mic to headphone */
11711 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11712 /* External mic to speaker */
11713 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11714 {}
11715};
11716
11717/*
Takashi Iwai834be882006-03-01 14:16:17 +010011718 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011719 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11720 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011721 */
11722
11723#define ALC_HP_EVENT 0x37
11724
11725static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11726 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11727 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011728 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11729 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011730 {}
11731};
11732
Jiang zhe0e31daf2008-03-20 12:12:39 +010011733static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11734 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11735 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11736 {}
11737};
11738
Daniel T Chene2595322009-12-19 18:19:02 -050011739static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11740 /* Front Mic pin: input vref at 50% */
11741 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11742 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11743 {}
11744};
11745
Takashi Iwai834be882006-03-01 14:16:17 +010011746static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011747 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011748 .items = {
11749 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010011750 { "Internal Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011751 { "CD", 0x4 },
11752 },
11753};
11754
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011755static struct hda_input_mux alc262_HP_capture_source = {
11756 .num_items = 5,
11757 .items = {
11758 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011759 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011760 { "Line", 0x2 },
11761 { "CD", 0x4 },
11762 { "AUX IN", 0x6 },
11763 },
11764};
11765
zhejiangaccbe492007-08-31 12:36:05 +020011766static struct hda_input_mux alc262_HP_D7000_capture_source = {
11767 .num_items = 4,
11768 .items = {
11769 { "Mic", 0x0 },
11770 { "Front Mic", 0x2 },
11771 { "Line", 0x1 },
11772 { "CD", 0x4 },
11773 },
11774};
11775
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011776/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011777static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11778{
11779 struct alc_spec *spec = codec->spec;
11780 unsigned int mute;
11781
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011782 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011783 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11784 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011785 spec->sense_updated = 1;
11786 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011787 /* unmute internal speaker only if both HPs are unplugged and
11788 * master switch is on
11789 */
11790 if (spec->jack_present)
11791 mute = HDA_AMP_MUTE;
11792 else
Takashi Iwai834be882006-03-01 14:16:17 +010011793 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011794 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11795 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011796}
11797
11798/* unsolicited event for HP jack sensing */
11799static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11800 unsigned int res)
11801{
11802 if ((res >> 26) != ALC_HP_EVENT)
11803 return;
11804 alc262_fujitsu_automute(codec, 1);
11805}
11806
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011807static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11808{
11809 alc262_fujitsu_automute(codec, 1);
11810}
11811
Takashi Iwai834be882006-03-01 14:16:17 +010011812/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011813static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11814 .ops = &snd_hda_bind_vol,
11815 .values = {
11816 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11817 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11818 0
11819 },
11820};
Takashi Iwai834be882006-03-01 14:16:17 +010011821
Jiang zhe0e31daf2008-03-20 12:12:39 +010011822/* mute/unmute internal speaker according to the hp jack and mute state */
11823static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11824{
11825 struct alc_spec *spec = codec->spec;
11826 unsigned int mute;
11827
11828 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011829 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011830 spec->sense_updated = 1;
11831 }
11832 if (spec->jack_present) {
11833 /* mute internal speaker */
11834 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11835 HDA_AMP_MUTE, HDA_AMP_MUTE);
11836 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11837 HDA_AMP_MUTE, HDA_AMP_MUTE);
11838 } else {
11839 /* unmute internal speaker if necessary */
11840 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11841 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11842 HDA_AMP_MUTE, mute);
11843 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11844 HDA_AMP_MUTE, mute);
11845 }
11846}
11847
11848/* unsolicited event for HP jack sensing */
11849static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11850 unsigned int res)
11851{
11852 if ((res >> 26) != ALC_HP_EVENT)
11853 return;
11854 alc262_lenovo_3000_automute(codec, 1);
11855}
11856
Takashi Iwai8de56b72009-07-24 16:51:47 +020011857static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11858 int dir, int idx, long *valp)
11859{
11860 int i, change = 0;
11861
11862 for (i = 0; i < 2; i++, valp++)
11863 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11864 HDA_AMP_MUTE,
11865 *valp ? 0 : HDA_AMP_MUTE);
11866 return change;
11867}
11868
Takashi Iwai834be882006-03-01 14:16:17 +010011869/* bind hp and internal speaker mute (with plug check) */
11870static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11871 struct snd_ctl_elem_value *ucontrol)
11872{
11873 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11874 long *valp = ucontrol->value.integer.value;
11875 int change;
11876
Takashi Iwai8de56b72009-07-24 16:51:47 +020011877 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11878 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011879 if (change)
11880 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011881 return change;
11882}
11883
11884static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011885 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011886 {
11887 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11888 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011889 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011890 .info = snd_hda_mixer_amp_switch_info,
11891 .get = snd_hda_mixer_amp_switch_get,
11892 .put = alc262_fujitsu_master_sw_put,
11893 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11894 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011895 {
11896 .iface = NID_MAPPING,
11897 .name = "Master Playback Switch",
11898 .private_value = 0x1b,
11899 },
Takashi Iwai834be882006-03-01 14:16:17 +010011900 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11901 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011902 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011903 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11904 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011905 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010011906 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11907 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011908 { } /* end */
11909};
11910
Jiang zhe0e31daf2008-03-20 12:12:39 +010011911/* bind hp and internal speaker mute (with plug check) */
11912static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11913 struct snd_ctl_elem_value *ucontrol)
11914{
11915 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11916 long *valp = ucontrol->value.integer.value;
11917 int change;
11918
Takashi Iwai8de56b72009-07-24 16:51:47 +020011919 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011920 if (change)
11921 alc262_lenovo_3000_automute(codec, 0);
11922 return change;
11923}
11924
11925static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11926 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11927 {
11928 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11929 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011930 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011931 .info = snd_hda_mixer_amp_switch_info,
11932 .get = snd_hda_mixer_amp_switch_get,
11933 .put = alc262_lenovo_3000_master_sw_put,
11934 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11935 },
11936 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11937 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011938 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011939 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11940 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011941 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010011942 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11943 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011944 { } /* end */
11945};
11946
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011947static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11948 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011949 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011950 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11951 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011952 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011953 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11954 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011955 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011956 { } /* end */
11957};
11958
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011959/* additional init verbs for Benq laptops */
11960static struct hda_verb alc262_EAPD_verbs[] = {
11961 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11962 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11963 {}
11964};
11965
Kailang Yang83c34212007-07-05 11:43:05 +020011966static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11967 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11968 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11969
11970 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11971 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11972 {}
11973};
11974
Tobin Davisf651b502007-10-26 12:40:47 +020011975/* Samsung Q1 Ultra Vista model setup */
11976static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011977 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11978 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011979 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11980 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011981 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
11982 HDA_CODEC_VOLUME("Headphone Mic Boost Volume", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011983 { } /* end */
11984};
11985
11986static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011987 /* output mixer */
11988 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11989 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11990 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11991 /* speaker */
11992 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11993 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11994 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11995 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11996 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011997 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011998 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11999 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12000 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12001 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12002 /* internal mic */
12003 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12004 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12005 /* ADC, choose mic */
12006 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12007 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12008 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12009 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12010 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12011 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12012 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12013 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12014 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
12015 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020012016 {}
12017};
12018
Tobin Davisf651b502007-10-26 12:40:47 +020012019/* mute/unmute internal speaker according to the hp jack and mute state */
12020static void alc262_ultra_automute(struct hda_codec *codec)
12021{
12022 struct alc_spec *spec = codec->spec;
12023 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020012024
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012025 mute = 0;
12026 /* auto-mute only when HP is used as HP */
12027 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012028 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012029 if (spec->jack_present)
12030 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020012031 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012032 /* mute/unmute internal speaker */
12033 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12034 HDA_AMP_MUTE, mute);
12035 /* mute/unmute HP */
12036 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12037 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020012038}
12039
12040/* unsolicited event for HP jack sensing */
12041static void alc262_ultra_unsol_event(struct hda_codec *codec,
12042 unsigned int res)
12043{
12044 if ((res >> 26) != ALC880_HP_EVENT)
12045 return;
12046 alc262_ultra_automute(codec);
12047}
12048
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012049static struct hda_input_mux alc262_ultra_capture_source = {
12050 .num_items = 2,
12051 .items = {
12052 { "Mic", 0x1 },
12053 { "Headphone", 0x7 },
12054 },
12055};
12056
12057static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
12058 struct snd_ctl_elem_value *ucontrol)
12059{
12060 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12061 struct alc_spec *spec = codec->spec;
12062 int ret;
12063
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012064 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012065 if (!ret)
12066 return 0;
12067 /* reprogram the HP pin as mic or HP according to the input source */
12068 snd_hda_codec_write_cache(codec, 0x15, 0,
12069 AC_VERB_SET_PIN_WIDGET_CONTROL,
12070 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
12071 alc262_ultra_automute(codec); /* mute/unmute HP */
12072 return ret;
12073}
12074
12075static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
12076 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
12077 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
12078 {
12079 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12080 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012081 .info = alc_mux_enum_info,
12082 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012083 .put = alc262_ultra_mux_enum_put,
12084 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010012085 {
12086 .iface = NID_MAPPING,
12087 .name = "Capture Source",
12088 .private_value = 0x15,
12089 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012090 { } /* end */
12091};
12092
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012093/* We use two mixers depending on the output pin; 0x16 is a mono output
12094 * and thus it's bound with a different mixer.
12095 * This function returns which mixer amp should be used.
12096 */
12097static int alc262_check_volbit(hda_nid_t nid)
12098{
12099 if (!nid)
12100 return 0;
12101 else if (nid == 0x16)
12102 return 2;
12103 else
12104 return 1;
12105}
12106
12107static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012108 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012109{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012110 unsigned long val;
12111 int vbit;
12112
12113 vbit = alc262_check_volbit(nid);
12114 if (!vbit)
12115 return 0;
12116 if (*vbits & vbit) /* a volume control for this mixer already there */
12117 return 0;
12118 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012119 if (vbit == 2)
12120 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
12121 else
12122 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012123 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012124}
12125
12126static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012127 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012128{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012129 unsigned long val;
12130
12131 if (!nid)
12132 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012133 if (nid == 0x16)
12134 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
12135 else
12136 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012137 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012138}
12139
Kailang Yangdf694da2005-12-05 19:42:22 +010012140/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012141static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
12142 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012143{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012144 const char *pfx;
12145 int vbits;
Takashi Iwai033688a2010-09-08 15:47:09 +020012146 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010012147
12148 spec->multiout.num_dacs = 1; /* only use one dac */
12149 spec->multiout.dac_nids = spec->private_dac_nids;
12150 spec->multiout.dac_nids[0] = 2;
12151
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010012152 pfx = alc_get_line_out_pfx(cfg, true);
12153 if (!pfx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012154 pfx = "Front";
Takashi Iwai033688a2010-09-08 15:47:09 +020012155 for (i = 0; i < 2; i++) {
12156 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
12157 if (err < 0)
12158 return err;
12159 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12160 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
12161 "Speaker", i);
12162 if (err < 0)
12163 return err;
12164 }
12165 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12166 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
12167 "Headphone", i);
12168 if (err < 0)
12169 return err;
12170 }
12171 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012172
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012173 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
12174 alc262_check_volbit(cfg->speaker_pins[0]) |
12175 alc262_check_volbit(cfg->hp_pins[0]);
12176 if (vbits == 1 || vbits == 2)
12177 pfx = "Master"; /* only one mixer is used */
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012178 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020012179 for (i = 0; i < 2; i++) {
12180 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
12181 &vbits, i);
12182 if (err < 0)
12183 return err;
12184 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12185 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
12186 "Speaker", &vbits, i);
12187 if (err < 0)
12188 return err;
12189 }
12190 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12191 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
12192 "Headphone", &vbits, i);
12193 if (err < 0)
12194 return err;
12195 }
12196 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012197 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010012198}
12199
Takashi Iwai05f5f472009-08-25 13:10:18 +020012200#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010012201 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010012202
12203/*
12204 * generic initialization of ADC, input mixers and output mixers
12205 */
12206static struct hda_verb alc262_volume_init_verbs[] = {
12207 /*
12208 * Unmute ADC0-2 and set the default input to mic-in
12209 */
12210 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12211 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12212 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12213 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12214 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12215 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12216
Takashi Iwaicb53c622007-08-10 17:21:45 +020012217 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010012218 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012219 * Note: PASD motherboards uses the Line In 2 as the input for
12220 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010012221 */
12222 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012223 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12224 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12225 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12226 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12227 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012228
12229 /*
12230 * Set up output mixers (0x0c - 0x0f)
12231 */
12232 /* set vol=0 to output mixers */
12233 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12234 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12235 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020012236
Kailang Yangdf694da2005-12-05 19:42:22 +010012237 /* set up input amps for analog loopback */
12238 /* Amp Indices: DAC = 0, mixer = 1 */
12239 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12240 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12241 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12242 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12243 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12244 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12245
12246 /* FIXME: use matrix-type input source selection */
12247 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12248 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12249 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12250 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12251 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12252 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12253 /* Input mixer2 */
12254 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12255 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12256 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12257 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12258 /* Input mixer3 */
12259 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12260 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12261 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12262 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12263
12264 { }
12265};
12266
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012267static struct hda_verb alc262_HP_BPC_init_verbs[] = {
12268 /*
12269 * Unmute ADC0-2 and set the default input to mic-in
12270 */
12271 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12272 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12273 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12274 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12275 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12276 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12277
Takashi Iwaicb53c622007-08-10 17:21:45 +020012278 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012279 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012280 * Note: PASD motherboards uses the Line In 2 as the input for
12281 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012282 */
12283 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012284 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12285 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12286 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12287 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12288 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12289 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12290 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012291
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012292 /*
12293 * Set up output mixers (0x0c - 0x0e)
12294 */
12295 /* set vol=0 to output mixers */
12296 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12297 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12298 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12299
12300 /* set up input amps for analog loopback */
12301 /* Amp Indices: DAC = 0, mixer = 1 */
12302 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12303 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12304 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12305 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12306 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12307 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12308
Takashi Iwaice875f02008-01-28 18:17:43 +010012309 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012310 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12311 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12312
12313 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12314 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12315
12316 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12317 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12318
12319 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12320 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12321 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12322 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12323 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12324
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012325 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012326 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12327 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012328 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012329 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12330 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12331
12332
12333 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012334 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12335 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012336 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012337 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12338 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12339 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12340 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12341 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12342 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12343 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12344 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012345 /* Input mixer2 */
12346 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012347 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12348 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12349 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12350 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12351 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12352 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12353 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12354 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012355 /* Input mixer3 */
12356 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012357 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12358 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12359 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12360 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12361 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12362 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12363 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12364 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012365
Takashi Iwaice875f02008-01-28 18:17:43 +010012366 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12367
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012368 { }
12369};
12370
Kailang Yangcd7509a2007-01-26 18:33:17 +010012371static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12372 /*
12373 * Unmute ADC0-2 and set the default input to mic-in
12374 */
12375 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12376 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12377 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12378 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12379 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12380 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12381
Takashi Iwaicb53c622007-08-10 17:21:45 +020012382 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012383 * mixer widget
12384 * Note: PASD motherboards uses the Line In 2 as the input for front
12385 * panel mic (mic 2)
12386 */
12387 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012388 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12389 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12390 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12391 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12392 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12393 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12394 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12395 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012396 /*
12397 * Set up output mixers (0x0c - 0x0e)
12398 */
12399 /* set vol=0 to output mixers */
12400 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12401 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12402 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12403
12404 /* set up input amps for analog loopback */
12405 /* Amp Indices: DAC = 0, mixer = 1 */
12406 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12407 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12408 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12409 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12410 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12411 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12412
12413
12414 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12415 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12416 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12417 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12418 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12419 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12420 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12421
12422 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12423 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12424
12425 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12426 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12427
12428 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12429 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12430 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12431 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12432 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12433 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12434
12435 /* FIXME: use matrix-type input source selection */
12436 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12437 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12438 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12439 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12440 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12441 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12442 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12443 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12444 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12445 /* Input mixer2 */
12446 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12447 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12448 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12449 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12450 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12451 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12452 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12453 /* Input mixer3 */
12454 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12455 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12456 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12457 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12459 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12460 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12461
Takashi Iwaice875f02008-01-28 18:17:43 +010012462 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12463
Kailang Yangcd7509a2007-01-26 18:33:17 +010012464 { }
12465};
12466
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012467static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12468
12469 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12470 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12471 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12472
12473 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12474 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12475 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12476 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12477
12478 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12479 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12480 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12481 {}
12482};
12483
Takashi Iwai18675e42010-09-08 15:55:44 +020012484/*
12485 * Pin config fixes
12486 */
12487enum {
12488 PINFIX_FSC_H270,
12489};
12490
12491static const struct alc_fixup alc262_fixups[] = {
12492 [PINFIX_FSC_H270] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012493 .type = ALC_FIXUP_PINS,
12494 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai18675e42010-09-08 15:55:44 +020012495 { 0x14, 0x99130110 }, /* speaker */
12496 { 0x15, 0x0221142f }, /* front HP */
12497 { 0x1b, 0x0121141f }, /* rear HP */
12498 { }
12499 }
12500 },
Takashi Iwai18675e42010-09-08 15:55:44 +020012501};
12502
12503static struct snd_pci_quirk alc262_fixup_tbl[] = {
12504 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12505 {}
12506};
12507
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012508
Takashi Iwaicb53c622007-08-10 17:21:45 +020012509#ifdef CONFIG_SND_HDA_POWER_SAVE
12510#define alc262_loopbacks alc880_loopbacks
12511#endif
12512
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012513/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012514#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12515#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12516#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12517#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12518
12519/*
12520 * BIOS auto configuration
12521 */
12522static int alc262_parse_auto_config(struct hda_codec *codec)
12523{
12524 struct alc_spec *spec = codec->spec;
12525 int err;
12526 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12527
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012528 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12529 alc262_ignore);
12530 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012531 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012532 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012533 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012534 spec->multiout.max_channels = 2;
12535 spec->no_analog = 1;
12536 goto dig_only;
12537 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012538 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012539 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012540 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12541 if (err < 0)
12542 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012543 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012544 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012545 return err;
12546
12547 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12548
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012549 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012550 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012551
Takashi Iwai603c4012008-07-30 15:01:44 +020012552 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012553 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012554
Takashi Iwaid88897e2008-10-31 15:01:37 +010012555 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012556 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012557 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012558
Takashi Iwai776e1842007-08-29 15:07:11 +020012559 err = alc_auto_add_mic_boost(codec);
12560 if (err < 0)
12561 return err;
12562
Kailang Yang6227cdc2010-02-25 08:36:52 +010012563 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012564
Kailang Yangdf694da2005-12-05 19:42:22 +010012565 return 1;
12566}
12567
12568#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12569#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12570#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012571#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012572
12573
12574/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012575static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012576{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012577 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012578 alc262_auto_init_multi_out(codec);
12579 alc262_auto_init_hp_out(codec);
12580 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012581 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012582 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012583 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012584 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012585}
12586
12587/*
12588 * configuration and preset
12589 */
Takashi Iwaiea734962011-01-17 11:29:34 +010012590static const char * const alc262_models[ALC262_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012591 [ALC262_BASIC] = "basic",
12592 [ALC262_HIPPO] = "hippo",
12593 [ALC262_HIPPO_1] = "hippo_1",
12594 [ALC262_FUJITSU] = "fujitsu",
12595 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012596 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012597 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012598 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012599 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012600 [ALC262_BENQ_T31] = "benq-t31",
12601 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012602 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012603 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012604 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012605 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012606 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012607 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012608 [ALC262_AUTO] = "auto",
12609};
12610
12611static struct snd_pci_quirk alc262_cfg_tbl[] = {
12612 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012613 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012614 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12615 ALC262_HP_BPC),
12616 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12617 ALC262_HP_BPC),
Takashi Iwai5734a072011-01-19 17:07:12 +010012618 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1500, "HP z series",
12619 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012620 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12621 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012622 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012623 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012624 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012625 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012626 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012627 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012628 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012629 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012630 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12631 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12632 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012633 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12634 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012635 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012636 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012637 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012638 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012639 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012640 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012641 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012642 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012643#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012644 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12645 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012646#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012647 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012648 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012649 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012650 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012651 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012652 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012653 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12654 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012655 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012656 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012657 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012658 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012659 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012660 {}
12661};
12662
12663static struct alc_config_preset alc262_presets[] = {
12664 [ALC262_BASIC] = {
12665 .mixers = { alc262_base_mixer },
12666 .init_verbs = { alc262_init_verbs },
12667 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12668 .dac_nids = alc262_dac_nids,
12669 .hp_nid = 0x03,
12670 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12671 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012672 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012673 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012674 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012675 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012676 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012677 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12678 .dac_nids = alc262_dac_nids,
12679 .hp_nid = 0x03,
12680 .dig_out_nid = ALC262_DIGOUT_NID,
12681 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12682 .channel_mode = alc262_modes,
12683 .input_mux = &alc262_capture_source,
12684 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012685 .setup = alc262_hippo_setup,
12686 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012687 },
12688 [ALC262_HIPPO_1] = {
12689 .mixers = { alc262_hippo1_mixer },
12690 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12691 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12692 .dac_nids = alc262_dac_nids,
12693 .hp_nid = 0x02,
12694 .dig_out_nid = ALC262_DIGOUT_NID,
12695 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12696 .channel_mode = alc262_modes,
12697 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012698 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012699 .setup = alc262_hippo1_setup,
12700 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012701 },
Takashi Iwai834be882006-03-01 14:16:17 +010012702 [ALC262_FUJITSU] = {
12703 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012704 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12705 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012706 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12707 .dac_nids = alc262_dac_nids,
12708 .hp_nid = 0x03,
12709 .dig_out_nid = ALC262_DIGOUT_NID,
12710 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12711 .channel_mode = alc262_modes,
12712 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012713 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012714 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012715 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012716 [ALC262_HP_BPC] = {
12717 .mixers = { alc262_HP_BPC_mixer },
12718 .init_verbs = { alc262_HP_BPC_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,
12724 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012725 .unsol_event = alc262_hp_bpc_unsol_event,
12726 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012727 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012728 [ALC262_HP_BPC_D7000_WF] = {
12729 .mixers = { alc262_HP_BPC_WildWest_mixer },
12730 .init_verbs = { alc262_HP_BPC_WildWest_init_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,
zhejiangaccbe492007-08-31 12:36:05 +020012736 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012737 .unsol_event = alc262_hp_wildwest_unsol_event,
12738 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012739 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012740 [ALC262_HP_BPC_D7000_WL] = {
12741 .mixers = { alc262_HP_BPC_WildWest_mixer,
12742 alc262_HP_BPC_WildWest_option_mixer },
12743 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12744 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12745 .dac_nids = alc262_dac_nids,
12746 .hp_nid = 0x03,
12747 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12748 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012749 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012750 .unsol_event = alc262_hp_wildwest_unsol_event,
12751 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012752 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012753 [ALC262_HP_TC_T5735] = {
12754 .mixers = { alc262_hp_t5735_mixer },
12755 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12756 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12757 .dac_nids = alc262_dac_nids,
12758 .hp_nid = 0x03,
12759 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12760 .channel_mode = alc262_modes,
12761 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012762 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012763 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012764 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012765 },
12766 [ALC262_HP_RP5700] = {
12767 .mixers = { alc262_hp_rp5700_mixer },
12768 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12769 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12770 .dac_nids = alc262_dac_nids,
12771 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12772 .channel_mode = alc262_modes,
12773 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012774 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012775 [ALC262_BENQ_ED8] = {
12776 .mixers = { alc262_base_mixer },
12777 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12778 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12779 .dac_nids = alc262_dac_nids,
12780 .hp_nid = 0x03,
12781 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12782 .channel_mode = alc262_modes,
12783 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012784 },
Kailang Yang272a5272007-05-14 11:00:38 +020012785 [ALC262_SONY_ASSAMD] = {
12786 .mixers = { alc262_sony_mixer },
12787 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12788 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12789 .dac_nids = alc262_dac_nids,
12790 .hp_nid = 0x02,
12791 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12792 .channel_mode = alc262_modes,
12793 .input_mux = &alc262_capture_source,
12794 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012795 .setup = alc262_hippo_setup,
12796 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012797 },
12798 [ALC262_BENQ_T31] = {
12799 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012800 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12801 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012802 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12803 .dac_nids = alc262_dac_nids,
12804 .hp_nid = 0x03,
12805 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12806 .channel_mode = alc262_modes,
12807 .input_mux = &alc262_capture_source,
12808 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012809 .setup = alc262_hippo_setup,
12810 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012811 },
Tobin Davisf651b502007-10-26 12:40:47 +020012812 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012813 .mixers = { alc262_ultra_mixer },
12814 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012815 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012816 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12817 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012818 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12819 .channel_mode = alc262_modes,
12820 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012821 .adc_nids = alc262_adc_nids, /* ADC0 */
12822 .capsrc_nids = alc262_capsrc_nids,
12823 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012824 .unsol_event = alc262_ultra_unsol_event,
12825 .init_hook = alc262_ultra_automute,
12826 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012827 [ALC262_LENOVO_3000] = {
12828 .mixers = { alc262_lenovo_3000_mixer },
12829 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012830 alc262_lenovo_3000_unsol_verbs,
12831 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012832 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12833 .dac_nids = alc262_dac_nids,
12834 .hp_nid = 0x03,
12835 .dig_out_nid = ALC262_DIGOUT_NID,
12836 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12837 .channel_mode = alc262_modes,
12838 .input_mux = &alc262_fujitsu_capture_source,
12839 .unsol_event = alc262_lenovo_3000_unsol_event,
12840 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012841 [ALC262_NEC] = {
12842 .mixers = { alc262_nec_mixer },
12843 .init_verbs = { alc262_nec_verbs },
12844 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12845 .dac_nids = alc262_dac_nids,
12846 .hp_nid = 0x03,
12847 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12848 .channel_mode = alc262_modes,
12849 .input_mux = &alc262_capture_source,
12850 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012851 [ALC262_TOSHIBA_S06] = {
12852 .mixers = { alc262_toshiba_s06_mixer },
12853 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12854 alc262_eapd_verbs },
12855 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12856 .capsrc_nids = alc262_dmic_capsrc_nids,
12857 .dac_nids = alc262_dac_nids,
12858 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012859 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012860 .dig_out_nid = ALC262_DIGOUT_NID,
12861 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12862 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012863 .unsol_event = alc_sku_unsol_event,
12864 .setup = alc262_toshiba_s06_setup,
12865 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012866 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012867 [ALC262_TOSHIBA_RX1] = {
12868 .mixers = { alc262_toshiba_rx1_mixer },
12869 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12870 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12871 .dac_nids = alc262_dac_nids,
12872 .hp_nid = 0x03,
12873 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12874 .channel_mode = alc262_modes,
12875 .input_mux = &alc262_capture_source,
12876 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012877 .setup = alc262_hippo_setup,
12878 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012879 },
Tony Vroonba340e82009-02-02 19:01:30 +000012880 [ALC262_TYAN] = {
12881 .mixers = { alc262_tyan_mixer },
12882 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12883 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12884 .dac_nids = alc262_dac_nids,
12885 .hp_nid = 0x02,
12886 .dig_out_nid = ALC262_DIGOUT_NID,
12887 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12888 .channel_mode = alc262_modes,
12889 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012890 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012891 .setup = alc262_tyan_setup,
12892 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012893 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012894};
12895
12896static int patch_alc262(struct hda_codec *codec)
12897{
12898 struct alc_spec *spec;
12899 int board_config;
12900 int err;
12901
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012902 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012903 if (spec == NULL)
12904 return -ENOMEM;
12905
12906 codec->spec = spec;
12907#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012908 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12909 * under-run
12910 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012911 {
12912 int tmp;
12913 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12914 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12915 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12916 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12917 }
12918#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012919 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012920
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012921 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12922
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012923 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12924 alc262_models,
12925 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012926
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012927 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012928 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12929 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012930 board_config = ALC262_AUTO;
12931 }
12932
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012933 if (board_config == ALC262_AUTO) {
12934 alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups);
12935 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
12936 }
Takashi Iwai18675e42010-09-08 15:55:44 +020012937
Kailang Yangdf694da2005-12-05 19:42:22 +010012938 if (board_config == ALC262_AUTO) {
12939 /* automatic parse from the BIOS config */
12940 err = alc262_parse_auto_config(codec);
12941 if (err < 0) {
12942 alc_free(codec);
12943 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012944 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012945 printk(KERN_INFO
12946 "hda_codec: Cannot set up configuration "
12947 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012948 board_config = ALC262_BASIC;
12949 }
12950 }
12951
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012952 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012953 err = snd_hda_attach_beep_device(codec, 0x1);
12954 if (err < 0) {
12955 alc_free(codec);
12956 return err;
12957 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012958 }
12959
Kailang Yangdf694da2005-12-05 19:42:22 +010012960 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012961 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012962
Kailang Yangdf694da2005-12-05 19:42:22 +010012963 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12964 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012965
Kailang Yangdf694da2005-12-05 19:42:22 +010012966 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12967 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12968
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012969 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012970 int i;
12971 /* check whether the digital-mic has to be supported */
12972 for (i = 0; i < spec->input_mux->num_items; i++) {
12973 if (spec->input_mux->items[i].index >= 9)
12974 break;
12975 }
12976 if (i < spec->input_mux->num_items) {
12977 /* use only ADC0 */
12978 spec->adc_nids = alc262_dmic_adc_nids;
12979 spec->num_adc_nids = 1;
12980 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012981 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012982 /* all analog inputs */
12983 /* check whether NID 0x07 is valid */
12984 unsigned int wcap = get_wcaps(codec, 0x07);
12985
12986 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012987 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012988 if (wcap != AC_WID_AUD_IN) {
12989 spec->adc_nids = alc262_adc_nids_alt;
12990 spec->num_adc_nids =
12991 ARRAY_SIZE(alc262_adc_nids_alt);
12992 spec->capsrc_nids = alc262_capsrc_nids_alt;
12993 } else {
12994 spec->adc_nids = alc262_adc_nids;
12995 spec->num_adc_nids =
12996 ARRAY_SIZE(alc262_adc_nids);
12997 spec->capsrc_nids = alc262_capsrc_nids;
12998 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012999 }
13000 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010013001 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013002 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020013003 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010013004 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010013005
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010013006 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai18675e42010-09-08 15:55:44 +020013007
Takashi Iwai2134ea42008-01-10 16:53:55 +010013008 spec->vmaster_nid = 0x0c;
13009
Kailang Yangdf694da2005-12-05 19:42:22 +010013010 codec->patch_ops = alc_patch_ops;
13011 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013012 spec->init_hook = alc262_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020013013
13014 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020013015#ifdef CONFIG_SND_HDA_POWER_SAVE
13016 if (!spec->loopback.amplist)
13017 spec->loopback.amplist = alc262_loopbacks;
13018#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020013019
Kailang Yangdf694da2005-12-05 19:42:22 +010013020 return 0;
13021}
13022
Kailang Yangdf694da2005-12-05 19:42:22 +010013023/*
Kailang Yanga361d842007-06-05 12:30:55 +020013024 * ALC268 channel source setting (2 channel)
13025 */
13026#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
13027#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020013028
Kailang Yanga361d842007-06-05 12:30:55 +020013029static hda_nid_t alc268_dac_nids[2] = {
13030 /* front, hp */
13031 0x02, 0x03
13032};
13033
13034static hda_nid_t alc268_adc_nids[2] = {
13035 /* ADC0-1 */
13036 0x08, 0x07
13037};
13038
13039static hda_nid_t alc268_adc_nids_alt[1] = {
13040 /* ADC0 */
13041 0x08
13042};
13043
Takashi Iwaie1406342008-02-11 18:32:32 +010013044static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
13045
Kailang Yanga361d842007-06-05 12:30:55 +020013046static struct snd_kcontrol_new alc268_base_mixer[] = {
13047 /* output mixer control */
13048 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13049 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13050 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13051 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013052 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13053 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13054 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020013055 { }
13056};
13057
Takashi Iwai42171c12009-05-08 14:11:43 +020013058static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
13059 /* output mixer control */
13060 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13061 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13062 ALC262_HIPPO_MASTER_SWITCH,
David Henningsson5f99f862011-01-04 15:24:24 +010013063 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13064 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13065 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020013066 { }
13067};
13068
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013069/* bind Beep switches of both NID 0x0f and 0x10 */
13070static struct hda_bind_ctls alc268_bind_beep_sw = {
13071 .ops = &snd_hda_bind_sw,
13072 .values = {
13073 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
13074 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
13075 0
13076 },
13077};
13078
13079static struct snd_kcontrol_new alc268_beep_mixer[] = {
13080 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
13081 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
13082 { }
13083};
13084
Kailang Yangd1a991a2007-08-15 16:21:59 +020013085static struct hda_verb alc268_eapd_verbs[] = {
13086 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13087 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13088 { }
13089};
13090
Takashi Iwaid2738092007-08-16 14:59:45 +020013091/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020013092static struct hda_verb alc268_toshiba_verbs[] = {
13093 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13094 { } /* end */
13095};
13096
13097/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020013098/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020013099static struct hda_bind_ctls alc268_acer_bind_master_vol = {
13100 .ops = &snd_hda_bind_vol,
13101 .values = {
13102 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
13103 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
13104 0
13105 },
13106};
13107
Takashi Iwai889c4392007-08-23 18:56:52 +020013108/* mute/unmute internal speaker according to the hp jack and mute state */
13109static void alc268_acer_automute(struct hda_codec *codec, int force)
13110{
13111 struct alc_spec *spec = codec->spec;
13112 unsigned int mute;
13113
13114 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080013115 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020013116 spec->sense_updated = 1;
13117 }
13118 if (spec->jack_present)
13119 mute = HDA_AMP_MUTE; /* mute internal speaker */
13120 else /* unmute internal speaker if necessary */
13121 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13122 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13123 HDA_AMP_MUTE, mute);
13124}
13125
13126
13127/* bind hp and internal speaker mute (with plug check) */
13128static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
13129 struct snd_ctl_elem_value *ucontrol)
13130{
13131 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
13132 long *valp = ucontrol->value.integer.value;
13133 int change;
13134
Takashi Iwai8de56b72009-07-24 16:51:47 +020013135 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020013136 if (change)
13137 alc268_acer_automute(codec, 0);
13138 return change;
13139}
Takashi Iwaid2738092007-08-16 14:59:45 +020013140
Kailang Yang8ef355d2008-08-26 13:10:22 +020013141static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
13142 /* output mixer control */
13143 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13144 {
13145 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13146 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013147 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013148 .info = snd_hda_mixer_amp_switch_info,
13149 .get = snd_hda_mixer_amp_switch_get,
13150 .put = alc268_acer_master_sw_put,
13151 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13152 },
13153 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
13154 { }
13155};
13156
Takashi Iwaid2738092007-08-16 14:59:45 +020013157static struct snd_kcontrol_new alc268_acer_mixer[] = {
13158 /* output mixer control */
13159 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13160 {
13161 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13162 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013163 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020013164 .info = snd_hda_mixer_amp_switch_info,
13165 .get = snd_hda_mixer_amp_switch_get,
13166 .put = alc268_acer_master_sw_put,
13167 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13168 },
David Henningsson5f99f862011-01-04 15:24:24 +010013169 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13170 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
13171 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020013172 { }
13173};
13174
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013175static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
13176 /* output mixer control */
13177 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13178 {
13179 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13180 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013181 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013182 .info = snd_hda_mixer_amp_switch_info,
13183 .get = snd_hda_mixer_amp_switch_get,
13184 .put = alc268_acer_master_sw_put,
13185 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13186 },
David Henningsson5f99f862011-01-04 15:24:24 +010013187 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13188 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013189 { }
13190};
13191
Kailang Yang8ef355d2008-08-26 13:10:22 +020013192static struct hda_verb alc268_acer_aspire_one_verbs[] = {
13193 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13194 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13195 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13196 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13197 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
13198 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
13199 { }
13200};
13201
Takashi Iwaid2738092007-08-16 14:59:45 +020013202static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013203 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
13204 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020013205 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13206 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013207 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13208 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020013209 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13210 { }
13211};
13212
13213/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020013214#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013215#define alc268_toshiba_setup alc262_hippo_setup
13216#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020013217
13218static void alc268_acer_unsol_event(struct hda_codec *codec,
13219 unsigned int res)
13220{
Takashi Iwai889c4392007-08-23 18:56:52 +020013221 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020013222 return;
13223 alc268_acer_automute(codec, 1);
13224}
13225
Takashi Iwai889c4392007-08-23 18:56:52 +020013226static void alc268_acer_init_hook(struct hda_codec *codec)
13227{
13228 alc268_acer_automute(codec, 1);
13229}
13230
Kailang Yang8ef355d2008-08-26 13:10:22 +020013231/* toggle speaker-output according to the hp-jack state */
13232static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
13233{
13234 unsigned int present;
13235 unsigned char bits;
13236
Wu Fengguang864f92b2009-11-18 12:38:02 +080013237 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013238 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013239 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013240 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013241 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013242 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013243}
13244
Kailang Yang8ef355d2008-08-26 13:10:22 +020013245static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
13246 unsigned int res)
13247{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013248 switch (res >> 26) {
13249 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020013250 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013251 break;
13252 case ALC880_MIC_EVENT:
13253 alc_mic_automute(codec);
13254 break;
13255 }
13256}
13257
13258static void alc268_acer_lc_setup(struct hda_codec *codec)
13259{
13260 struct alc_spec *spec = codec->spec;
13261 spec->ext_mic.pin = 0x18;
13262 spec->ext_mic.mux_idx = 0;
13263 spec->int_mic.pin = 0x12;
13264 spec->int_mic.mux_idx = 6;
13265 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013266}
13267
13268static void alc268_acer_lc_init_hook(struct hda_codec *codec)
13269{
13270 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013271 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013272}
13273
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013274static struct snd_kcontrol_new alc268_dell_mixer[] = {
13275 /* output mixer control */
13276 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13277 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13278 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13279 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013280 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13281 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013282 { }
13283};
13284
13285static struct hda_verb alc268_dell_verbs[] = {
13286 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13287 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13288 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013289 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013290 { }
13291};
13292
13293/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013294static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013295{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013296 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013297
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013298 spec->autocfg.hp_pins[0] = 0x15;
13299 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013300 spec->ext_mic.pin = 0x18;
13301 spec->ext_mic.mux_idx = 0;
13302 spec->int_mic.pin = 0x19;
13303 spec->int_mic.mux_idx = 1;
13304 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013305}
13306
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013307static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
13308 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13309 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13310 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13311 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13312 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13313 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013314 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13315 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013316 { }
13317};
13318
13319static struct hda_verb alc267_quanta_il1_verbs[] = {
13320 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13321 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13322 { }
13323};
13324
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013325static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013326{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013327 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013328 spec->autocfg.hp_pins[0] = 0x15;
13329 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013330 spec->ext_mic.pin = 0x18;
13331 spec->ext_mic.mux_idx = 0;
13332 spec->int_mic.pin = 0x19;
13333 spec->int_mic.mux_idx = 1;
13334 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013335}
13336
Kailang Yanga361d842007-06-05 12:30:55 +020013337/*
13338 * generic initialization of ADC, input mixers and output mixers
13339 */
13340static struct hda_verb alc268_base_init_verbs[] = {
13341 /* Unmute DAC0-1 and set vol = 0 */
13342 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013343 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013344
13345 /*
13346 * Set up output mixers (0x0c - 0x0e)
13347 */
13348 /* set vol=0 to output mixers */
13349 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013350 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13351
13352 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13353 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13354
13355 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13356 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13357 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13358 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13359 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13360 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13361 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13362 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13363
13364 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13365 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13366 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13367 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013368 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013369
13370 /* set PCBEEP vol = 0, mute connections */
13371 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13372 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13373 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013374
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013375 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013376
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013377 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13378 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13379 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13380 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013381
Kailang Yanga361d842007-06-05 12:30:55 +020013382 { }
13383};
13384
13385/*
13386 * generic initialization of ADC, input mixers and output mixers
13387 */
13388static struct hda_verb alc268_volume_init_verbs[] = {
13389 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013390 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13391 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013392
13393 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13394 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13395 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13396 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13397 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13398
Kailang Yanga361d842007-06-05 12:30:55 +020013399 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013400 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13401 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13402
13403 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013404 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013405
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013406 /* set PCBEEP vol = 0, mute connections */
13407 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13408 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13409 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013410
13411 { }
13412};
13413
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013414static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13415 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13416 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13417 { } /* end */
13418};
13419
Kailang Yanga361d842007-06-05 12:30:55 +020013420static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13421 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13422 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013423 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013424 { } /* end */
13425};
13426
13427static struct snd_kcontrol_new alc268_capture_mixer[] = {
13428 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13429 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13430 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13431 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013432 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013433 { } /* end */
13434};
13435
13436static struct hda_input_mux alc268_capture_source = {
13437 .num_items = 4,
13438 .items = {
13439 { "Mic", 0x0 },
13440 { "Front Mic", 0x1 },
13441 { "Line", 0x2 },
13442 { "CD", 0x3 },
13443 },
13444};
13445
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013446static struct hda_input_mux alc268_acer_capture_source = {
13447 .num_items = 3,
13448 .items = {
13449 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013450 { "Internal Mic", 0x1 },
13451 { "Line", 0x2 },
13452 },
13453};
13454
13455static struct hda_input_mux alc268_acer_dmic_capture_source = {
13456 .num_items = 3,
13457 .items = {
13458 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013459 { "Internal Mic", 0x6 },
13460 { "Line", 0x2 },
13461 },
13462};
13463
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013464#ifdef CONFIG_SND_DEBUG
13465static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013466 /* Volume widgets */
13467 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13468 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13469 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13470 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13471 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13472 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13473 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13474 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13475 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13476 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13477 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13478 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13479 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013480 /* The below appears problematic on some hardwares */
13481 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013482 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13483 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13484 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13485 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13486
13487 /* Modes for retasking pin widgets */
13488 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13489 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13490 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13491 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13492
13493 /* Controls for GPIO pins, assuming they are configured as outputs */
13494 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13495 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13496 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13497 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13498
13499 /* Switches to allow the digital SPDIF output pin to be enabled.
13500 * The ALC268 does not have an SPDIF input.
13501 */
13502 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13503
13504 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13505 * this output to turn on an external amplifier.
13506 */
13507 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13508 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13509
13510 { } /* end */
13511};
13512#endif
13513
Kailang Yanga361d842007-06-05 12:30:55 +020013514/* create input playback/capture controls for the given pin */
13515static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13516 const char *ctlname, int idx)
13517{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013518 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013519 int err;
13520
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013521 switch (nid) {
13522 case 0x14:
13523 case 0x16:
13524 dac = 0x02;
13525 break;
13526 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013527 case 0x1a: /* ALC259/269 only */
13528 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013529 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013530 dac = 0x03;
13531 break;
13532 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013533 snd_printd(KERN_WARNING "hda_codec: "
13534 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013535 return 0;
13536 }
13537 if (spec->multiout.dac_nids[0] != dac &&
13538 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013539 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013540 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013541 HDA_OUTPUT));
13542 if (err < 0)
13543 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013544 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13545 }
13546
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013547 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013548 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013549 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013550 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013551 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013552 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013553 if (err < 0)
13554 return err;
13555 return 0;
13556}
13557
13558/* add playback controls from the parsed DAC table */
13559static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13560 const struct auto_pin_cfg *cfg)
13561{
13562 hda_nid_t nid;
13563 int err;
13564
Kailang Yanga361d842007-06-05 12:30:55 +020013565 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013566
13567 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013568 if (nid) {
13569 const char *name;
13570 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13571 name = "Speaker";
13572 else
13573 name = "Front";
13574 err = alc268_new_analog_output(spec, nid, name, 0);
13575 if (err < 0)
13576 return err;
13577 }
Kailang Yanga361d842007-06-05 12:30:55 +020013578
13579 nid = cfg->speaker_pins[0];
13580 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013581 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013582 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13583 if (err < 0)
13584 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013585 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013586 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13587 if (err < 0)
13588 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013589 }
13590 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013591 if (nid) {
13592 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13593 if (err < 0)
13594 return err;
13595 }
Kailang Yanga361d842007-06-05 12:30:55 +020013596
13597 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13598 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013599 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013600 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013601 if (err < 0)
13602 return err;
13603 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013604 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013605}
13606
13607/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013608static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013609 const struct auto_pin_cfg *cfg)
13610{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013611 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013612}
13613
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013614static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13615 hda_nid_t nid, int pin_type)
13616{
13617 int idx;
13618
13619 alc_set_pin_output(codec, nid, pin_type);
13620 if (nid == 0x14 || nid == 0x16)
13621 idx = 0;
13622 else
13623 idx = 1;
13624 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13625}
13626
13627static void alc268_auto_init_multi_out(struct hda_codec *codec)
13628{
13629 struct alc_spec *spec = codec->spec;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013630 int i;
13631
13632 for (i = 0; i < spec->autocfg.line_outs; i++) {
13633 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013634 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13635 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13636 }
13637}
13638
13639static void alc268_auto_init_hp_out(struct hda_codec *codec)
13640{
13641 struct alc_spec *spec = codec->spec;
13642 hda_nid_t pin;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013643 int i;
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013644
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013645 for (i = 0; i < spec->autocfg.hp_outs; i++) {
13646 pin = spec->autocfg.hp_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013647 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013648 }
13649 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
13650 pin = spec->autocfg.speaker_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013651 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013652 }
13653 if (spec->autocfg.mono_out_pin)
13654 snd_hda_codec_write(codec, spec->autocfg.mono_out_pin, 0,
13655 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013656}
13657
Kailang Yanga361d842007-06-05 12:30:55 +020013658static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13659{
13660 struct alc_spec *spec = codec->spec;
13661 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13662 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13663 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13664 unsigned int dac_vol1, dac_vol2;
13665
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013666 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013667 snd_hda_codec_write(codec, speaker_nid, 0,
13668 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013669 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013670 snd_hda_codec_write(codec, 0x0f, 0,
13671 AC_VERB_SET_AMP_GAIN_MUTE,
13672 AMP_IN_UNMUTE(1));
13673 snd_hda_codec_write(codec, 0x10, 0,
13674 AC_VERB_SET_AMP_GAIN_MUTE,
13675 AMP_IN_UNMUTE(1));
13676 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013677 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013678 snd_hda_codec_write(codec, 0x0f, 0,
13679 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13680 snd_hda_codec_write(codec, 0x10, 0,
13681 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13682 }
13683
13684 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013685 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013686 dac_vol2 = AMP_OUT_ZERO;
13687 else if (line_nid == 0x15)
13688 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013689 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013690 dac_vol2 = AMP_OUT_ZERO;
13691 else if (hp_nid == 0x15)
13692 dac_vol1 = AMP_OUT_ZERO;
13693 if (line_nid != 0x16 || hp_nid != 0x16 ||
13694 spec->autocfg.line_out_pins[1] != 0x16 ||
13695 spec->autocfg.line_out_pins[2] != 0x16)
13696 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13697
13698 snd_hda_codec_write(codec, 0x02, 0,
13699 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13700 snd_hda_codec_write(codec, 0x03, 0,
13701 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13702}
13703
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013704/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013705#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13706#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013707#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013708#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13709
13710/*
13711 * BIOS auto configuration
13712 */
13713static int alc268_parse_auto_config(struct hda_codec *codec)
13714{
13715 struct alc_spec *spec = codec->spec;
13716 int err;
13717 static hda_nid_t alc268_ignore[] = { 0 };
13718
13719 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13720 alc268_ignore);
13721 if (err < 0)
13722 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013723 if (!spec->autocfg.line_outs) {
13724 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13725 spec->multiout.max_channels = 2;
13726 spec->no_analog = 1;
13727 goto dig_only;
13728 }
Kailang Yanga361d842007-06-05 12:30:55 +020013729 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013730 }
Kailang Yanga361d842007-06-05 12:30:55 +020013731 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13732 if (err < 0)
13733 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013734 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013735 if (err < 0)
13736 return err;
13737
13738 spec->multiout.max_channels = 2;
13739
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013740 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013741 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013742 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013743 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013744 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013745
Takashi Iwai892981f2009-03-02 08:04:35 +010013746 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013747 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013748
Takashi Iwaid88897e2008-10-31 15:01:37 +010013749 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013750 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013751 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013752
Takashi Iwai776e1842007-08-29 15:07:11 +020013753 err = alc_auto_add_mic_boost(codec);
13754 if (err < 0)
13755 return err;
13756
Kailang Yang6227cdc2010-02-25 08:36:52 +010013757 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013758
Kailang Yanga361d842007-06-05 12:30:55 +020013759 return 1;
13760}
13761
Kailang Yanga361d842007-06-05 12:30:55 +020013762#define alc268_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaiae0ebbf2011-03-10 14:11:59 +010013763#define alc268_auto_init_input_src alc882_auto_init_input_src
Kailang Yanga361d842007-06-05 12:30:55 +020013764
13765/* init callback for auto-configuration model -- overriding the default init */
13766static void alc268_auto_init(struct hda_codec *codec)
13767{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013768 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013769 alc268_auto_init_multi_out(codec);
13770 alc268_auto_init_hp_out(codec);
13771 alc268_auto_init_mono_speaker_out(codec);
13772 alc268_auto_init_analog_input(codec);
Takashi Iwaiae0ebbf2011-03-10 14:11:59 +010013773 alc268_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013774 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013775 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013776 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013777}
13778
13779/*
13780 * configuration and preset
13781 */
Takashi Iwaiea734962011-01-17 11:29:34 +010013782static const char * const alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013783 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013784 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013785 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013786 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013787 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013788 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013789 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013790 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013791#ifdef CONFIG_SND_DEBUG
13792 [ALC268_TEST] = "test",
13793#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013794 [ALC268_AUTO] = "auto",
13795};
13796
13797static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013798 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013799 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013800 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013801 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013802 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013803 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13804 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013805 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013806 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13807 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013808 /* almost compatible with toshiba but with optional digital outs;
13809 * auto-probing seems working fine
13810 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013811 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013812 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013813 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013814 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013815 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013816 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013817 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013818 {}
13819};
13820
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013821/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13822static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13823 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13824 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13825 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13826 ALC268_TOSHIBA),
13827 {}
13828};
13829
Kailang Yanga361d842007-06-05 12:30:55 +020013830static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013831 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013832 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13833 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013834 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13835 alc267_quanta_il1_verbs },
13836 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13837 .dac_nids = alc268_dac_nids,
13838 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13839 .adc_nids = alc268_adc_nids_alt,
13840 .hp_nid = 0x03,
13841 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13842 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013843 .unsol_event = alc_sku_unsol_event,
13844 .setup = alc267_quanta_il1_setup,
13845 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013846 },
Kailang Yanga361d842007-06-05 12:30:55 +020013847 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013848 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13849 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013850 .init_verbs = { alc268_base_init_verbs },
13851 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13852 .dac_nids = alc268_dac_nids,
13853 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13854 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013855 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013856 .hp_nid = 0x03,
13857 .dig_out_nid = ALC268_DIGOUT_NID,
13858 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13859 .channel_mode = alc268_modes,
13860 .input_mux = &alc268_capture_source,
13861 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013862 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013863 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013864 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013865 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13866 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013867 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13868 .dac_nids = alc268_dac_nids,
13869 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13870 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013871 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013872 .hp_nid = 0x03,
13873 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13874 .channel_mode = alc268_modes,
13875 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013876 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013877 .setup = alc268_toshiba_setup,
13878 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013879 },
13880 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013881 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013882 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013883 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13884 alc268_acer_verbs },
13885 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13886 .dac_nids = alc268_dac_nids,
13887 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13888 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013889 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013890 .hp_nid = 0x02,
13891 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13892 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013893 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013894 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013895 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013896 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013897 [ALC268_ACER_DMIC] = {
13898 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13899 alc268_beep_mixer },
13900 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13901 alc268_acer_verbs },
13902 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13903 .dac_nids = alc268_dac_nids,
13904 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13905 .adc_nids = alc268_adc_nids_alt,
13906 .capsrc_nids = alc268_capsrc_nids,
13907 .hp_nid = 0x02,
13908 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13909 .channel_mode = alc268_modes,
13910 .input_mux = &alc268_acer_dmic_capture_source,
13911 .unsol_event = alc268_acer_unsol_event,
13912 .init_hook = alc268_acer_init_hook,
13913 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013914 [ALC268_ACER_ASPIRE_ONE] = {
13915 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013916 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013917 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013918 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13919 alc268_acer_aspire_one_verbs },
13920 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13921 .dac_nids = alc268_dac_nids,
13922 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13923 .adc_nids = alc268_adc_nids_alt,
13924 .capsrc_nids = alc268_capsrc_nids,
13925 .hp_nid = 0x03,
13926 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13927 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013928 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013929 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013930 .init_hook = alc268_acer_lc_init_hook,
13931 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013932 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013933 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13934 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013935 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13936 alc268_dell_verbs },
13937 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13938 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013939 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13940 .adc_nids = alc268_adc_nids_alt,
13941 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013942 .hp_nid = 0x02,
13943 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13944 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013945 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013946 .setup = alc268_dell_setup,
13947 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013948 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013949 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013950 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13951 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013952 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13953 alc268_toshiba_verbs },
13954 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13955 .dac_nids = alc268_dac_nids,
13956 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13957 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013958 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013959 .hp_nid = 0x03,
13960 .dig_out_nid = ALC268_DIGOUT_NID,
13961 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13962 .channel_mode = alc268_modes,
13963 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013964 .setup = alc268_toshiba_setup,
13965 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013966 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013967#ifdef CONFIG_SND_DEBUG
13968 [ALC268_TEST] = {
13969 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13970 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13971 alc268_volume_init_verbs },
13972 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13973 .dac_nids = alc268_dac_nids,
13974 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13975 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013976 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013977 .hp_nid = 0x03,
13978 .dig_out_nid = ALC268_DIGOUT_NID,
13979 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13980 .channel_mode = alc268_modes,
13981 .input_mux = &alc268_capture_source,
13982 },
13983#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013984};
13985
13986static int patch_alc268(struct hda_codec *codec)
13987{
13988 struct alc_spec *spec;
13989 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013990 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013991
Julia Lawallef86f582009-12-19 08:18:03 +010013992 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013993 if (spec == NULL)
13994 return -ENOMEM;
13995
13996 codec->spec = spec;
13997
13998 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13999 alc268_models,
14000 alc268_cfg_tbl);
14001
Takashi Iwai3abf2f32009-08-19 20:05:02 +020014002 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
14003 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010014004 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020014005
Kailang Yanga361d842007-06-05 12:30:55 +020014006 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014007 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14008 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020014009 board_config = ALC268_AUTO;
14010 }
14011
14012 if (board_config == ALC268_AUTO) {
14013 /* automatic parse from the BIOS config */
14014 err = alc268_parse_auto_config(codec);
14015 if (err < 0) {
14016 alc_free(codec);
14017 return err;
14018 } else if (!err) {
14019 printk(KERN_INFO
14020 "hda_codec: Cannot set up configuration "
14021 "from BIOS. Using base mode...\n");
14022 board_config = ALC268_3ST;
14023 }
14024 }
14025
14026 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014027 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020014028
Kailang Yanga361d842007-06-05 12:30:55 +020014029 spec->stream_analog_playback = &alc268_pcm_analog_playback;
14030 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010014031 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020014032
Kailang Yanga361d842007-06-05 12:30:55 +020014033 spec->stream_digital_playback = &alc268_pcm_digital_playback;
14034
Takashi Iwai22971e32009-02-10 11:56:44 +010014035 has_beep = 0;
14036 for (i = 0; i < spec->num_mixers; i++) {
14037 if (spec->mixers[i] == alc268_beep_mixer) {
14038 has_beep = 1;
14039 break;
14040 }
14041 }
14042
14043 if (has_beep) {
14044 err = snd_hda_attach_beep_device(codec, 0x1);
14045 if (err < 0) {
14046 alc_free(codec);
14047 return err;
14048 }
14049 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
14050 /* override the amp caps for beep generator */
14051 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014052 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
14053 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
14054 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
14055 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010014056 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014057
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014058 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014059 /* check whether NID 0x07 is valid */
14060 unsigned int wcap = get_wcaps(codec, 0x07);
Kailang Yanga361d842007-06-05 12:30:55 +020014061
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014062 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014063 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020014064 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014065 if (spec->auto_mic ||
14066 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014067 spec->adc_nids = alc268_adc_nids_alt;
14068 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014069 if (spec->auto_mic)
14070 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014071 if (spec->auto_mic || spec->input_mux->num_items == 1)
14072 add_mixer(spec, alc268_capture_nosrc_mixer);
14073 else
14074 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014075 } else {
14076 spec->adc_nids = alc268_adc_nids;
14077 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010014078 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020014079 }
14080 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010014081
14082 spec->vmaster_nid = 0x02;
14083
Kailang Yanga361d842007-06-05 12:30:55 +020014084 codec->patch_ops = alc_patch_ops;
14085 if (board_config == ALC268_AUTO)
14086 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020014087
Kailang Yangbf1b0222010-10-21 08:49:56 +020014088 alc_init_jacks(codec);
14089
Kailang Yanga361d842007-06-05 12:30:55 +020014090 return 0;
14091}
14092
14093/*
Kailang Yangf6a92242007-12-13 16:52:54 +010014094 * ALC269 channel source setting (2 channel)
14095 */
14096#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
14097
14098#define alc269_dac_nids alc260_dac_nids
14099
14100static hda_nid_t alc269_adc_nids[1] = {
14101 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020014102 0x08,
14103};
14104
Takashi Iwaie01bf502008-08-21 16:25:07 +020014105static hda_nid_t alc269_capsrc_nids[1] = {
14106 0x23,
14107};
14108
Kailang Yang84898e82010-02-04 14:16:14 +010014109static hda_nid_t alc269vb_adc_nids[1] = {
14110 /* ADC1 */
14111 0x09,
14112};
14113
14114static hda_nid_t alc269vb_capsrc_nids[1] = {
14115 0x22,
14116};
14117
Takashi Iwai66946352010-03-29 17:21:45 +020014118static hda_nid_t alc269_adc_candidates[] = {
14119 0x08, 0x09, 0x07,
14120};
Takashi Iwaie01bf502008-08-21 16:25:07 +020014121
Kailang Yangf6a92242007-12-13 16:52:54 +010014122#define alc269_modes alc260_modes
14123#define alc269_capture_source alc880_lg_lw_capture_source
14124
14125static struct snd_kcontrol_new alc269_base_mixer[] = {
14126 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14127 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14128 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14129 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14130 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14131 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014132 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014133 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14134 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014135 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014136 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14137 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
14138 { } /* end */
14139};
14140
Kailang Yang60db6b52008-08-26 13:13:00 +020014141static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
14142 /* output mixer control */
14143 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14144 {
14145 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14146 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014147 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020014148 .info = snd_hda_mixer_amp_switch_info,
14149 .get = snd_hda_mixer_amp_switch_get,
14150 .put = alc268_acer_master_sw_put,
14151 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14152 },
14153 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14154 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014155 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014156 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14157 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014158 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014159 { }
14160};
14161
Tony Vroon64154832008-11-06 15:08:49 +000014162static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
14163 /* output mixer control */
14164 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14165 {
14166 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14167 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014168 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000014169 .info = snd_hda_mixer_amp_switch_info,
14170 .get = snd_hda_mixer_amp_switch_get,
14171 .put = alc268_acer_master_sw_put,
14172 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14173 },
14174 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14175 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014176 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014177 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14178 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014179 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014180 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
14181 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014182 HDA_CODEC_VOLUME("Dock Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014183 { }
14184};
14185
Kailang Yang84898e82010-02-04 14:16:14 +010014186static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020014187 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014188 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020014189 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014190 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020014191 { } /* end */
14192};
14193
Kailang Yang84898e82010-02-04 14:16:14 +010014194static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
14195 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14196 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14197 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14198 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14199 { } /* end */
14200};
14201
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014202static struct snd_kcontrol_new alc269_asus_mixer[] = {
14203 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14204 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
14205 { } /* end */
14206};
14207
Kailang Yangf6a92242007-12-13 16:52:54 +010014208/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010014209static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
14210 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14211 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014212 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14213 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014214 { } /* end */
14215};
14216
14217static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020014218 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14219 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014220 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010014221 { } /* end */
14222};
14223
Kailang Yang84898e82010-02-04 14:16:14 +010014224static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
14225 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14226 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014227 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14228 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014229 { } /* end */
14230};
14231
14232static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
14233 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14234 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014235 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014236 { } /* end */
14237};
14238
Takashi Iwai26f5df22008-11-03 17:39:46 +010014239/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010014240#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020014241
Kailang Yang60db6b52008-08-26 13:13:00 +020014242static struct hda_verb alc269_quanta_fl1_verbs[] = {
14243 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14244 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14245 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14246 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14247 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14248 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14249 { }
14250};
14251
Tony Vroon64154832008-11-06 15:08:49 +000014252static struct hda_verb alc269_lifebook_verbs[] = {
14253 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14254 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
14255 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14256 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14257 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14258 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14259 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14260 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14261 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14262 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14263 { }
14264};
14265
Kailang Yang60db6b52008-08-26 13:13:00 +020014266/* toggle speaker-output according to the hp-jack state */
14267static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
14268{
14269 unsigned int present;
14270 unsigned char bits;
14271
Wu Fengguang864f92b2009-11-18 12:38:02 +080014272 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014273 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014274 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014275 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014276 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014277 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014278
14279 snd_hda_codec_write(codec, 0x20, 0,
14280 AC_VERB_SET_COEF_INDEX, 0x0c);
14281 snd_hda_codec_write(codec, 0x20, 0,
14282 AC_VERB_SET_PROC_COEF, 0x680);
14283
14284 snd_hda_codec_write(codec, 0x20, 0,
14285 AC_VERB_SET_COEF_INDEX, 0x0c);
14286 snd_hda_codec_write(codec, 0x20, 0,
14287 AC_VERB_SET_PROC_COEF, 0x480);
14288}
14289
Tony Vroon64154832008-11-06 15:08:49 +000014290/* toggle speaker-output according to the hp-jacks state */
14291static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
14292{
14293 unsigned int present;
14294 unsigned char bits;
14295
14296 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014297 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000014298
14299 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014300 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000014301
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014302 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000014303 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014304 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014305 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014306 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014307
14308 snd_hda_codec_write(codec, 0x20, 0,
14309 AC_VERB_SET_COEF_INDEX, 0x0c);
14310 snd_hda_codec_write(codec, 0x20, 0,
14311 AC_VERB_SET_PROC_COEF, 0x680);
14312
14313 snd_hda_codec_write(codec, 0x20, 0,
14314 AC_VERB_SET_COEF_INDEX, 0x0c);
14315 snd_hda_codec_write(codec, 0x20, 0,
14316 AC_VERB_SET_PROC_COEF, 0x480);
14317}
14318
Tony Vroon64154832008-11-06 15:08:49 +000014319static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14320{
14321 unsigned int present_laptop;
14322 unsigned int present_dock;
14323
Wu Fengguang864f92b2009-11-18 12:38:02 +080014324 present_laptop = snd_hda_jack_detect(codec, 0x18);
14325 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014326
14327 /* Laptop mic port overrides dock mic port, design decision */
14328 if (present_dock)
14329 snd_hda_codec_write(codec, 0x23, 0,
14330 AC_VERB_SET_CONNECT_SEL, 0x3);
14331 if (present_laptop)
14332 snd_hda_codec_write(codec, 0x23, 0,
14333 AC_VERB_SET_CONNECT_SEL, 0x0);
14334 if (!present_dock && !present_laptop)
14335 snd_hda_codec_write(codec, 0x23, 0,
14336 AC_VERB_SET_CONNECT_SEL, 0x1);
14337}
14338
Kailang Yang60db6b52008-08-26 13:13:00 +020014339static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14340 unsigned int res)
14341{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014342 switch (res >> 26) {
14343 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014344 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014345 break;
14346 case ALC880_MIC_EVENT:
14347 alc_mic_automute(codec);
14348 break;
14349 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014350}
14351
Tony Vroon64154832008-11-06 15:08:49 +000014352static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14353 unsigned int res)
14354{
14355 if ((res >> 26) == ALC880_HP_EVENT)
14356 alc269_lifebook_speaker_automute(codec);
14357 if ((res >> 26) == ALC880_MIC_EVENT)
14358 alc269_lifebook_mic_autoswitch(codec);
14359}
14360
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014361static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14362{
14363 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014364 spec->autocfg.hp_pins[0] = 0x15;
14365 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014366 spec->ext_mic.pin = 0x18;
14367 spec->ext_mic.mux_idx = 0;
14368 spec->int_mic.pin = 0x19;
14369 spec->int_mic.mux_idx = 1;
14370 spec->auto_mic = 1;
14371}
14372
Kailang Yang60db6b52008-08-26 13:13:00 +020014373static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14374{
14375 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014376 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014377}
14378
Tony Vroon64154832008-11-06 15:08:49 +000014379static void alc269_lifebook_init_hook(struct hda_codec *codec)
14380{
14381 alc269_lifebook_speaker_automute(codec);
14382 alc269_lifebook_mic_autoswitch(codec);
14383}
14384
Kailang Yang84898e82010-02-04 14:16:14 +010014385static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014386 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14387 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14388 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14389 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14390 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14391 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14392 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14393 {}
14394};
14395
Kailang Yang84898e82010-02-04 14:16:14 +010014396static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014397 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14398 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14399 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14400 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14401 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14402 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14403 {}
14404};
14405
Kailang Yang84898e82010-02-04 14:16:14 +010014406static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14407 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14408 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14409 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14410 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14411 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14412 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14413 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14414 {}
14415};
14416
14417static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14418 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14419 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14420 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14421 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14422 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14423 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14424 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14425 {}
14426};
14427
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014428static struct hda_verb alc271_acer_dmic_verbs[] = {
14429 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14430 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14431 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14432 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14433 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14434 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14435 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14436 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14437 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14438 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14439 { }
14440};
14441
Kailang Yang60db6b52008-08-26 13:13:00 +020014442/* toggle speaker-output according to the hp-jack state */
14443static void alc269_speaker_automute(struct hda_codec *codec)
14444{
Kailang Yangebb83ee2009-12-17 12:23:00 +010014445 struct alc_spec *spec = codec->spec;
14446 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020014447 unsigned int present;
14448 unsigned char bits;
14449
Kailang Yangebb83ee2009-12-17 12:23:00 +010014450 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014451 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014452 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014453 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014454 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014455 HDA_AMP_MUTE, bits);
Takashi Iwaicd372fb2011-03-03 14:40:14 +010014456 snd_hda_input_jack_report(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020014457}
14458
Kailang Yang60db6b52008-08-26 13:13:00 +020014459/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010014460static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020014461 unsigned int res)
14462{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014463 switch (res >> 26) {
14464 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014465 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014466 break;
14467 case ALC880_MIC_EVENT:
14468 alc_mic_automute(codec);
14469 break;
14470 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014471}
14472
Kailang Yang226b1ec2010-04-09 11:01:20 +020014473static void alc269_laptop_amic_setup(struct hda_codec *codec)
14474{
14475 struct alc_spec *spec = codec->spec;
14476 spec->autocfg.hp_pins[0] = 0x15;
14477 spec->autocfg.speaker_pins[0] = 0x14;
14478 spec->ext_mic.pin = 0x18;
14479 spec->ext_mic.mux_idx = 0;
14480 spec->int_mic.pin = 0x19;
14481 spec->int_mic.mux_idx = 1;
14482 spec->auto_mic = 1;
14483}
14484
Kailang Yang84898e82010-02-04 14:16:14 +010014485static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014486{
14487 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014488 spec->autocfg.hp_pins[0] = 0x15;
14489 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014490 spec->ext_mic.pin = 0x18;
14491 spec->ext_mic.mux_idx = 0;
14492 spec->int_mic.pin = 0x12;
14493 spec->int_mic.mux_idx = 5;
14494 spec->auto_mic = 1;
14495}
14496
Kailang Yang226b1ec2010-04-09 11:01:20 +020014497static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014498{
14499 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014500 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014501 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014502 spec->ext_mic.pin = 0x18;
14503 spec->ext_mic.mux_idx = 0;
14504 spec->int_mic.pin = 0x19;
14505 spec->int_mic.mux_idx = 1;
14506 spec->auto_mic = 1;
14507}
14508
Kailang Yang226b1ec2010-04-09 11:01:20 +020014509static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14510{
14511 struct alc_spec *spec = codec->spec;
14512 spec->autocfg.hp_pins[0] = 0x21;
14513 spec->autocfg.speaker_pins[0] = 0x14;
14514 spec->ext_mic.pin = 0x18;
14515 spec->ext_mic.mux_idx = 0;
14516 spec->int_mic.pin = 0x12;
14517 spec->int_mic.mux_idx = 6;
14518 spec->auto_mic = 1;
14519}
14520
Kailang Yang84898e82010-02-04 14:16:14 +010014521static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020014522{
14523 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014524 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014525}
14526
Kailang Yangf6a92242007-12-13 16:52:54 +010014527/*
14528 * generic initialization of ADC, input mixers and output mixers
14529 */
14530static struct hda_verb alc269_init_verbs[] = {
14531 /*
14532 * Unmute ADC0 and set the default input to mic-in
14533 */
Kailang Yang84898e82010-02-04 14:16:14 +010014534 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014535
14536 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014537 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014538 */
14539 /* set vol=0 to output mixers */
14540 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14541 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14542
14543 /* set up input amps for analog loopback */
14544 /* Amp Indices: DAC = 0, mixer = 1 */
14545 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14546 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14547 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14548 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14549 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14550 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14551
14552 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14553 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14554 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14555 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14556 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14557 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14558 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14559
14560 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14561 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014562
Kailang Yang84898e82010-02-04 14:16:14 +010014563 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014564 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14565 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014566 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014567
14568 /* set EAPD */
14569 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014570 { }
14571};
14572
14573static struct hda_verb alc269vb_init_verbs[] = {
14574 /*
14575 * Unmute ADC0 and set the default input to mic-in
14576 */
14577 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14578
14579 /*
14580 * Set up output mixers (0x02 - 0x03)
14581 */
14582 /* set vol=0 to output mixers */
14583 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14584 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14585
14586 /* set up input amps for analog loopback */
14587 /* Amp Indices: DAC = 0, mixer = 1 */
14588 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14589 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14590 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14591 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14592 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14593 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14594
14595 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14596 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14597 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14598 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14599 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14600 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14601 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14602
14603 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14604 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14605
14606 /* FIXME: use Mux-type input source selection */
14607 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14608 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14609 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14610
14611 /* set EAPD */
14612 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014613 { }
14614};
14615
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014616#define alc269_auto_create_multi_out_ctls \
14617 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014618#define alc269_auto_create_input_ctls \
14619 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014620
14621#ifdef CONFIG_SND_HDA_POWER_SAVE
14622#define alc269_loopbacks alc880_loopbacks
14623#endif
14624
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014625/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014626#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14627#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14628#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14629#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14630
Takashi Iwaif03d3112009-03-05 14:18:16 +010014631static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14632 .substreams = 1,
14633 .channels_min = 2,
14634 .channels_max = 8,
14635 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14636 /* NID is set in alc_build_pcms */
14637 .ops = {
14638 .open = alc880_playback_pcm_open,
14639 .prepare = alc880_playback_pcm_prepare,
14640 .cleanup = alc880_playback_pcm_cleanup
14641 },
14642};
14643
14644static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14645 .substreams = 1,
14646 .channels_min = 2,
14647 .channels_max = 2,
14648 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14649 /* NID is set in alc_build_pcms */
14650};
14651
Takashi Iwaiad358792010-03-30 18:00:59 +020014652#ifdef CONFIG_SND_HDA_POWER_SAVE
14653static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14654{
14655 switch (codec->subsystem_id) {
14656 case 0x103c1586:
14657 return 1;
14658 }
14659 return 0;
14660}
14661
14662static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14663{
14664 /* update mute-LED according to the speaker mute state */
14665 if (nid == 0x01 || nid == 0x14) {
14666 int pinval;
14667 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14668 HDA_AMP_MUTE)
14669 pinval = 0x24;
14670 else
14671 pinval = 0x20;
14672 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a542010-03-30 18:03:44 +020014673 snd_hda_codec_update_cache(codec, 0x19, 0,
14674 AC_VERB_SET_PIN_WIDGET_CONTROL,
14675 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014676 }
14677 return alc_check_power_status(codec, nid);
14678}
14679#endif /* CONFIG_SND_HDA_POWER_SAVE */
14680
Takashi Iwai840b64c2010-07-13 22:49:01 +020014681static int alc275_setup_dual_adc(struct hda_codec *codec)
14682{
14683 struct alc_spec *spec = codec->spec;
14684
14685 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14686 return 0;
14687 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14688 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14689 if (spec->ext_mic.pin <= 0x12) {
14690 spec->private_adc_nids[0] = 0x08;
14691 spec->private_adc_nids[1] = 0x11;
14692 spec->private_capsrc_nids[0] = 0x23;
14693 spec->private_capsrc_nids[1] = 0x22;
14694 } else {
14695 spec->private_adc_nids[0] = 0x11;
14696 spec->private_adc_nids[1] = 0x08;
14697 spec->private_capsrc_nids[0] = 0x22;
14698 spec->private_capsrc_nids[1] = 0x23;
14699 }
14700 spec->adc_nids = spec->private_adc_nids;
14701 spec->capsrc_nids = spec->private_capsrc_nids;
14702 spec->num_adc_nids = 2;
14703 spec->dual_adc_switch = 1;
14704 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14705 spec->adc_nids[0], spec->adc_nids[1]);
14706 return 1;
14707 }
14708 return 0;
14709}
14710
Takashi Iwaid433a672010-09-20 15:11:54 +020014711/* different alc269-variants */
14712enum {
14713 ALC269_TYPE_NORMAL,
Kailang Yang48c88e82010-11-23 08:56:16 +010014714 ALC269_TYPE_ALC258,
Takashi Iwaid433a672010-09-20 15:11:54 +020014715 ALC269_TYPE_ALC259,
Kailang Yang48c88e82010-11-23 08:56:16 +010014716 ALC269_TYPE_ALC269VB,
14717 ALC269_TYPE_ALC270,
Takashi Iwaid433a672010-09-20 15:11:54 +020014718 ALC269_TYPE_ALC271X,
14719};
14720
Kailang Yangf6a92242007-12-13 16:52:54 +010014721/*
14722 * BIOS auto configuration
14723 */
14724static int alc269_parse_auto_config(struct hda_codec *codec)
14725{
14726 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014727 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014728 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14729
14730 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14731 alc269_ignore);
14732 if (err < 0)
14733 return err;
14734
14735 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14736 if (err < 0)
14737 return err;
Takashi Iwaif3550d12010-09-20 15:09:03 +020014738 if (spec->codec_variant == ALC269_TYPE_NORMAL)
14739 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
14740 else
14741 err = alc_auto_create_input_ctls(codec, &spec->autocfg, 0,
14742 0x22, 0);
Kailang Yangf6a92242007-12-13 16:52:54 +010014743 if (err < 0)
14744 return err;
14745
14746 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14747
Takashi Iwai757899a2010-07-30 10:48:14 +020014748 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014749
Takashi Iwai603c4012008-07-30 15:01:44 +020014750 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014751 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014752
Takashi Iwaid433a672010-09-20 15:11:54 +020014753 if (spec->codec_variant != ALC269_TYPE_NORMAL) {
Kailang Yang84898e82010-02-04 14:16:14 +010014754 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014755 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014756 } else {
14757 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014758 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014759 }
14760
Kailang Yangf6a92242007-12-13 16:52:54 +010014761 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014762 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014763
14764 if (!alc275_setup_dual_adc(codec))
14765 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14766 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014767
Kailang Yangf6a92242007-12-13 16:52:54 +010014768 err = alc_auto_add_mic_boost(codec);
14769 if (err < 0)
14770 return err;
14771
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014772 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014773 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014774
Kailang Yangf6a92242007-12-13 16:52:54 +010014775 return 1;
14776}
14777
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014778#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14779#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014780#define alc269_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaiae0ebbf2011-03-10 14:11:59 +010014781#define alc269_auto_init_input_src alc882_auto_init_input_src
Kailang Yangf6a92242007-12-13 16:52:54 +010014782
14783
14784/* init callback for auto-configuration model -- overriding the default init */
14785static void alc269_auto_init(struct hda_codec *codec)
14786{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014787 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014788 alc269_auto_init_multi_out(codec);
14789 alc269_auto_init_hp_out(codec);
14790 alc269_auto_init_analog_input(codec);
Takashi Iwaiae0ebbf2011-03-10 14:11:59 +010014791 if (!spec->dual_adc_switch)
14792 alc269_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014793 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014794 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014795 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014796}
14797
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014798#ifdef SND_HDA_NEEDS_RESUME
14799static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
14800{
14801 int val = alc_read_coef_idx(codec, 0x04);
14802 if (power_up)
14803 val |= 1 << 11;
14804 else
14805 val &= ~(1 << 11);
14806 alc_write_coef_idx(codec, 0x04, val);
14807}
14808
Kailang Yang977ddd62010-09-15 10:02:29 +020014809#ifdef CONFIG_SND_HDA_POWER_SAVE
14810static int alc269_suspend(struct hda_codec *codec, pm_message_t state)
14811{
14812 struct alc_spec *spec = codec->spec;
Kailang Yang977ddd62010-09-15 10:02:29 +020014813
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014814 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017)
14815 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014816 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014817 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014818 msleep(150);
14819 }
14820
14821 alc_shutup(codec);
14822 if (spec && spec->power_hook)
14823 spec->power_hook(codec);
14824 return 0;
14825}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014826#endif /* CONFIG_SND_HDA_POWER_SAVE */
14827
Kailang Yang977ddd62010-09-15 10:02:29 +020014828static int alc269_resume(struct hda_codec *codec)
14829{
Kailang Yang977ddd62010-09-15 10:02:29 +020014830 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014831 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014832 msleep(150);
14833 }
14834
14835 codec->patch_ops.init(codec);
14836
14837 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014838 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014839 msleep(200);
14840 }
14841
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014842 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018)
14843 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014844
14845 snd_hda_codec_resume_amp(codec);
14846 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +020014847 hda_call_check_power_status(codec, 0x01);
Kailang Yang977ddd62010-09-15 10:02:29 +020014848 return 0;
14849}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014850#endif /* SND_HDA_NEEDS_RESUME */
Kailang Yang977ddd62010-09-15 10:02:29 +020014851
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014852static void alc269_fixup_hweq(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014853 const struct alc_fixup *fix, int action)
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014854{
14855 int coef;
14856
Takashi Iwai58701122011-01-13 15:41:45 +010014857 if (action != ALC_FIXUP_ACT_INIT)
Takashi Iwai9fb1ef22011-01-13 14:40:43 +010014858 return;
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014859 coef = alc_read_coef_idx(codec, 0x1e);
14860 alc_write_coef_idx(codec, 0x1e, coef | 0x80);
14861}
14862
Takashi Iwaiff818c22010-04-12 08:59:25 +020014863enum {
14864 ALC269_FIXUP_SONY_VAIO,
Takashi Iwai74dc8902011-01-13 14:14:41 +010014865 ALC275_FIXUP_SONY_VAIO_GPIO2,
David Henningsson145a9022010-09-16 10:07:53 +020014866 ALC269_FIXUP_DELL_M101Z,
David Henningsson022c92b2010-12-17 20:43:04 +010014867 ALC269_FIXUP_SKU_IGNORE,
David Henningssonac612402010-12-15 09:18:18 +010014868 ALC269_FIXUP_ASUS_G73JW,
Kailang Yang357f9152011-01-12 08:12:52 +010014869 ALC269_FIXUP_LENOVO_EAPD,
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014870 ALC275_FIXUP_SONY_HWEQ,
Takashi Iwaiff818c22010-04-12 08:59:25 +020014871};
14872
Takashi Iwaiff818c22010-04-12 08:59:25 +020014873static const struct alc_fixup alc269_fixups[] = {
14874 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014875 .type = ALC_FIXUP_VERBS,
14876 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020014877 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14878 {}
14879 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014880 },
Takashi Iwai74dc8902011-01-13 14:14:41 +010014881 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014882 .type = ALC_FIXUP_VERBS,
14883 .v.verbs = (const struct hda_verb[]) {
Kailang Yang27855912010-12-21 09:09:53 +010014884 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
14885 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
14886 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
14887 { }
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014888 },
14889 .chained = true,
14890 .chain_id = ALC269_FIXUP_SONY_VAIO
Kailang Yang27855912010-12-21 09:09:53 +010014891 },
David Henningsson145a9022010-09-16 10:07:53 +020014892 [ALC269_FIXUP_DELL_M101Z] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014893 .type = ALC_FIXUP_VERBS,
14894 .v.verbs = (const struct hda_verb[]) {
David Henningsson145a9022010-09-16 10:07:53 +020014895 /* Enables internal speaker */
14896 {0x20, AC_VERB_SET_COEF_INDEX, 13},
14897 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
14898 {}
14899 }
14900 },
David Henningsson022c92b2010-12-17 20:43:04 +010014901 [ALC269_FIXUP_SKU_IGNORE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014902 .type = ALC_FIXUP_SKU,
14903 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonfe67b242010-12-15 08:01:46 +010014904 },
David Henningssonac612402010-12-15 09:18:18 +010014905 [ALC269_FIXUP_ASUS_G73JW] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014906 .type = ALC_FIXUP_PINS,
14907 .v.pins = (const struct alc_pincfg[]) {
David Henningssonac612402010-12-15 09:18:18 +010014908 { 0x17, 0x99130111 }, /* subwoofer */
14909 { }
14910 }
14911 },
Kailang Yang357f9152011-01-12 08:12:52 +010014912 [ALC269_FIXUP_LENOVO_EAPD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014913 .type = ALC_FIXUP_VERBS,
14914 .v.verbs = (const struct hda_verb[]) {
Kailang Yang357f9152011-01-12 08:12:52 +010014915 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
14916 {}
14917 }
14918 },
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014919 [ALC275_FIXUP_SONY_HWEQ] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014920 .type = ALC_FIXUP_FUNC,
14921 .v.func = alc269_fixup_hweq,
14922 .chained = true,
14923 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014924 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014925};
14926
14927static struct snd_pci_quirk alc269_fixup_tbl[] = {
Takashi Iwai74dc8902011-01-13 14:14:41 +010014928 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014929 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
14930 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
Takashi Iwai7039c742010-12-23 16:35:34 +010014931 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningsson145a9022010-09-16 10:07:53 +020014932 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
David Henningsson022c92b2010-12-17 20:43:04 +010014933 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
David Henningssonded9f522011-01-26 11:46:12 +010014934 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
14935 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
14936 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
14937 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
David Henningssonac612402010-12-15 09:18:18 +010014938 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
Kailang Yang357f9152011-01-12 08:12:52 +010014939 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014940 {}
14941};
14942
14943
Kailang Yangf6a92242007-12-13 16:52:54 +010014944/*
14945 * configuration and preset
14946 */
Takashi Iwaiea734962011-01-17 11:29:34 +010014947static const char * const alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014948 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014949 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014950 [ALC269_AMIC] = "laptop-amic",
14951 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014952 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014953 [ALC269_LIFEBOOK] = "lifebook",
14954 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014955};
14956
14957static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014958 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014959 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014960 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014961 ALC269_AMIC),
14962 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14963 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14964 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14965 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14966 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14967 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14968 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14969 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14970 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
Chih-Wei Huangc790ad32011-02-25 11:14:31 +080014971 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269VB_AMIC),
Kailang Yang84898e82010-02-04 14:16:14 +010014972 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14973 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14974 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14975 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14976 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14977 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14978 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14979 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14980 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14981 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14982 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14983 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14984 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14985 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14986 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14987 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14988 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14989 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14990 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14991 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14992 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14993 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14994 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14995 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14996 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14997 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014998 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014999 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020015000 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010015001 ALC269_DMIC),
15002 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
15003 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020015004 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000015005 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010015006 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
15007 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
15008 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
15009 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
15010 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
15011 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010015012 {}
15013};
15014
15015static struct alc_config_preset alc269_presets[] = {
15016 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015017 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010015018 .init_verbs = { alc269_init_verbs },
15019 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15020 .dac_nids = alc269_dac_nids,
15021 .hp_nid = 0x03,
15022 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15023 .channel_mode = alc269_modes,
15024 .input_mux = &alc269_capture_source,
15025 },
Kailang Yang60db6b52008-08-26 13:13:00 +020015026 [ALC269_QUANTA_FL1] = {
15027 .mixers = { alc269_quanta_fl1_mixer },
15028 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
15029 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15030 .dac_nids = alc269_dac_nids,
15031 .hp_nid = 0x03,
15032 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15033 .channel_mode = alc269_modes,
15034 .input_mux = &alc269_capture_source,
15035 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015036 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020015037 .init_hook = alc269_quanta_fl1_init_hook,
15038 },
Kailang Yang84898e82010-02-04 14:16:14 +010015039 [ALC269_AMIC] = {
15040 .mixers = { alc269_laptop_mixer },
15041 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020015042 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015043 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015044 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15045 .dac_nids = alc269_dac_nids,
15046 .hp_nid = 0x03,
15047 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15048 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015049 .unsol_event = alc269_laptop_unsol_event,
15050 .setup = alc269_laptop_amic_setup,
15051 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015052 },
Kailang Yang84898e82010-02-04 14:16:14 +010015053 [ALC269_DMIC] = {
15054 .mixers = { alc269_laptop_mixer },
15055 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020015056 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015057 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015058 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15059 .dac_nids = alc269_dac_nids,
15060 .hp_nid = 0x03,
15061 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15062 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015063 .unsol_event = alc269_laptop_unsol_event,
15064 .setup = alc269_laptop_dmic_setup,
15065 .init_hook = alc269_laptop_inithook,
15066 },
15067 [ALC269VB_AMIC] = {
15068 .mixers = { alc269vb_laptop_mixer },
15069 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
15070 .init_verbs = { alc269vb_init_verbs,
15071 alc269vb_laptop_amic_init_verbs },
15072 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15073 .dac_nids = alc269_dac_nids,
15074 .hp_nid = 0x03,
15075 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15076 .channel_mode = alc269_modes,
15077 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020015078 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010015079 .init_hook = alc269_laptop_inithook,
15080 },
15081 [ALC269VB_DMIC] = {
15082 .mixers = { alc269vb_laptop_mixer },
15083 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15084 .init_verbs = { alc269vb_init_verbs,
15085 alc269vb_laptop_dmic_init_verbs },
15086 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15087 .dac_nids = alc269_dac_nids,
15088 .hp_nid = 0x03,
15089 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15090 .channel_mode = alc269_modes,
15091 .unsol_event = alc269_laptop_unsol_event,
15092 .setup = alc269vb_laptop_dmic_setup,
15093 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015094 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015095 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015096 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010015097 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015098 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015099 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015100 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15101 .dac_nids = alc269_dac_nids,
15102 .hp_nid = 0x03,
15103 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15104 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015105 .unsol_event = alc269_laptop_unsol_event,
15106 .setup = alc269_laptop_dmic_setup,
15107 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015108 },
Tony Vroon64154832008-11-06 15:08:49 +000015109 [ALC269_LIFEBOOK] = {
15110 .mixers = { alc269_lifebook_mixer },
15111 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
15112 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15113 .dac_nids = alc269_dac_nids,
15114 .hp_nid = 0x03,
15115 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15116 .channel_mode = alc269_modes,
15117 .input_mux = &alc269_capture_source,
15118 .unsol_event = alc269_lifebook_unsol_event,
15119 .init_hook = alc269_lifebook_init_hook,
15120 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020015121 [ALC271_ACER] = {
15122 .mixers = { alc269_asus_mixer },
15123 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15124 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
15125 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15126 .dac_nids = alc269_dac_nids,
15127 .adc_nids = alc262_dmic_adc_nids,
15128 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
15129 .capsrc_nids = alc262_dmic_capsrc_nids,
15130 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15131 .channel_mode = alc269_modes,
15132 .input_mux = &alc269_capture_source,
15133 .dig_out_nid = ALC880_DIGOUT_NID,
15134 .unsol_event = alc_sku_unsol_event,
15135 .setup = alc269vb_laptop_dmic_setup,
15136 .init_hook = alc_inithook,
15137 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015138};
15139
Kailang Yang977ddd62010-09-15 10:02:29 +020015140static int alc269_fill_coef(struct hda_codec *codec)
15141{
15142 int val;
15143
15144 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
15145 alc_write_coef_idx(codec, 0xf, 0x960b);
15146 alc_write_coef_idx(codec, 0xe, 0x8817);
15147 }
15148
15149 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
15150 alc_write_coef_idx(codec, 0xf, 0x960b);
15151 alc_write_coef_idx(codec, 0xe, 0x8814);
15152 }
15153
15154 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
15155 val = alc_read_coef_idx(codec, 0x04);
15156 /* Power up output pin */
15157 alc_write_coef_idx(codec, 0x04, val | (1<<11));
15158 }
15159
15160 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
15161 val = alc_read_coef_idx(codec, 0xd);
15162 if ((val & 0x0c00) >> 10 != 0x1) {
15163 /* Capless ramp up clock control */
15164 alc_write_coef_idx(codec, 0xd, val | 1<<10);
15165 }
15166 val = alc_read_coef_idx(codec, 0x17);
15167 if ((val & 0x01c0) >> 6 != 0x4) {
15168 /* Class D power on reset */
15169 alc_write_coef_idx(codec, 0x17, val | 1<<7);
15170 }
15171 }
15172 return 0;
15173}
15174
Kailang Yangf6a92242007-12-13 16:52:54 +010015175static int patch_alc269(struct hda_codec *codec)
15176{
15177 struct alc_spec *spec;
Kailang Yang48c88e82010-11-23 08:56:16 +010015178 int board_config, coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010015179 int err;
15180
15181 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15182 if (spec == NULL)
15183 return -ENOMEM;
15184
15185 codec->spec = spec;
15186
Kailang Yangda00c242010-03-19 11:23:45 +010015187 alc_auto_parse_customize_define(codec);
15188
Kailang Yangc793bec2010-12-21 09:14:13 +010015189 if (codec->vendor_id == 0x10ec0269) {
15190 coef = alc_read_coef_idx(codec, 0);
15191 if ((coef & 0x00f0) == 0x0010) {
15192 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
15193 spec->cdefine.platform_type == 1) {
15194 alc_codec_rename(codec, "ALC271X");
15195 spec->codec_variant = ALC269_TYPE_ALC271X;
15196 } else if ((coef & 0xf000) == 0x1000) {
15197 spec->codec_variant = ALC269_TYPE_ALC270;
15198 } else if ((coef & 0xf000) == 0x2000) {
15199 alc_codec_rename(codec, "ALC259");
15200 spec->codec_variant = ALC269_TYPE_ALC259;
15201 } else if ((coef & 0xf000) == 0x3000) {
15202 alc_codec_rename(codec, "ALC258");
15203 spec->codec_variant = ALC269_TYPE_ALC258;
15204 } else {
15205 alc_codec_rename(codec, "ALC269VB");
15206 spec->codec_variant = ALC269_TYPE_ALC269VB;
15207 }
15208 } else
15209 alc_fix_pll_init(codec, 0x20, 0x04, 15);
15210 alc269_fill_coef(codec);
15211 }
Kailang Yang977ddd62010-09-15 10:02:29 +020015212
Kailang Yangf6a92242007-12-13 16:52:54 +010015213 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
15214 alc269_models,
15215 alc269_cfg_tbl);
15216
15217 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015218 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15219 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010015220 board_config = ALC269_AUTO;
15221 }
15222
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015223 if (board_config == ALC269_AUTO) {
15224 alc_pick_fixup(codec, NULL, alc269_fixup_tbl, alc269_fixups);
15225 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
15226 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020015227
Kailang Yangf6a92242007-12-13 16:52:54 +010015228 if (board_config == ALC269_AUTO) {
15229 /* automatic parse from the BIOS config */
15230 err = alc269_parse_auto_config(codec);
15231 if (err < 0) {
15232 alc_free(codec);
15233 return err;
15234 } else if (!err) {
15235 printk(KERN_INFO
15236 "hda_codec: Cannot set up configuration "
15237 "from BIOS. Using base mode...\n");
15238 board_config = ALC269_BASIC;
15239 }
15240 }
15241
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015242 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020015243 err = snd_hda_attach_beep_device(codec, 0x1);
15244 if (err < 0) {
15245 alc_free(codec);
15246 return err;
15247 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015248 }
15249
Kailang Yangf6a92242007-12-13 16:52:54 +010015250 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015251 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010015252
Kailang Yang84898e82010-02-04 14:16:14 +010015253 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010015254 /* Due to a hardware problem on Lenovo Ideadpad, we need to
15255 * fix the sample rate of analog I/O to 44.1kHz
15256 */
15257 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
15258 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020015259 } else if (spec->dual_adc_switch) {
15260 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15261 /* switch ADC dynamically */
15262 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010015263 } else {
15264 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15265 spec->stream_analog_capture = &alc269_pcm_analog_capture;
15266 }
Kailang Yangf6a92242007-12-13 16:52:54 +010015267 spec->stream_digital_playback = &alc269_pcm_digital_playback;
15268 spec->stream_digital_capture = &alc269_pcm_digital_capture;
15269
Takashi Iwai66946352010-03-29 17:21:45 +020015270 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
Kailang Yang1657cbd2010-11-23 08:53:32 +010015271 if (spec->codec_variant == ALC269_TYPE_NORMAL) {
Takashi Iwai66946352010-03-29 17:21:45 +020015272 spec->adc_nids = alc269_adc_nids;
15273 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
15274 spec->capsrc_nids = alc269_capsrc_nids;
15275 } else {
15276 spec->adc_nids = alc269vb_adc_nids;
15277 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
15278 spec->capsrc_nids = alc269vb_capsrc_nids;
15279 }
Kailang Yang84898e82010-02-04 14:16:14 +010015280 }
15281
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015282 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015283 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015284 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010015285 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010015286
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015287 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaiff818c22010-04-12 08:59:25 +020015288
Takashi Iwai100d5eb2009-08-10 11:55:51 +020015289 spec->vmaster_nid = 0x02;
15290
Kailang Yangf6a92242007-12-13 16:52:54 +010015291 codec->patch_ops = alc_patch_ops;
Kailang Yang977ddd62010-09-15 10:02:29 +020015292#ifdef CONFIG_SND_HDA_POWER_SAVE
15293 codec->patch_ops.suspend = alc269_suspend;
15294#endif
15295#ifdef SND_HDA_NEEDS_RESUME
15296 codec->patch_ops.resume = alc269_resume;
15297#endif
Kailang Yangf6a92242007-12-13 16:52:54 +010015298 if (board_config == ALC269_AUTO)
15299 spec->init_hook = alc269_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020015300
15301 alc_init_jacks(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010015302#ifdef CONFIG_SND_HDA_POWER_SAVE
15303 if (!spec->loopback.amplist)
15304 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020015305 if (alc269_mic2_for_mute_led(codec))
15306 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010015307#endif
15308
15309 return 0;
15310}
15311
15312/*
Kailang Yangdf694da2005-12-05 19:42:22 +010015313 * ALC861 channel source setting (2/6 channel selection for 3-stack)
15314 */
15315
15316/*
15317 * set the path ways for 2 channel output
15318 * need to set the codec line out and mic 1 pin widgets to inputs
15319 */
15320static struct hda_verb alc861_threestack_ch2_init[] = {
15321 /* set pin widget 1Ah (line in) for input */
15322 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015323 /* set pin widget 18h (mic1/2) for input, for mic also enable
15324 * the vref
15325 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015326 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15327
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015328 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15329#if 0
15330 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15331 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15332#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015333 { } /* end */
15334};
15335/*
15336 * 6ch mode
15337 * need to set the codec line out and mic 1 pin widgets to outputs
15338 */
15339static struct hda_verb alc861_threestack_ch6_init[] = {
15340 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15341 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15342 /* set pin widget 18h (mic1) for output (CLFE)*/
15343 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15344
15345 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015346 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015347
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015348 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15349#if 0
15350 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15351 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15352#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015353 { } /* end */
15354};
15355
15356static struct hda_channel_mode alc861_threestack_modes[2] = {
15357 { 2, alc861_threestack_ch2_init },
15358 { 6, alc861_threestack_ch6_init },
15359};
Takashi Iwai22309c32006-08-09 16:57:28 +020015360/* Set mic1 as input and unmute the mixer */
15361static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
15362 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15363 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15364 { } /* end */
15365};
15366/* Set mic1 as output and mute mixer */
15367static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
15368 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15369 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15370 { } /* end */
15371};
15372
15373static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
15374 { 2, alc861_uniwill_m31_ch2_init },
15375 { 4, alc861_uniwill_m31_ch4_init },
15376};
Kailang Yangdf694da2005-12-05 19:42:22 +010015377
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015378/* Set mic1 and line-in as input and unmute the mixer */
15379static struct hda_verb alc861_asus_ch2_init[] = {
15380 /* set pin widget 1Ah (line in) for input */
15381 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015382 /* set pin widget 18h (mic1/2) for input, for mic also enable
15383 * the vref
15384 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015385 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15386
15387 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15388#if 0
15389 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15390 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15391#endif
15392 { } /* end */
15393};
15394/* Set mic1 nad line-in as output and mute mixer */
15395static struct hda_verb alc861_asus_ch6_init[] = {
15396 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15397 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15398 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15399 /* set pin widget 18h (mic1) for output (CLFE)*/
15400 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15401 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15402 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
15403 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
15404
15405 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15406#if 0
15407 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15408 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15409#endif
15410 { } /* end */
15411};
15412
15413static struct hda_channel_mode alc861_asus_modes[2] = {
15414 { 2, alc861_asus_ch2_init },
15415 { 6, alc861_asus_ch6_init },
15416};
15417
Kailang Yangdf694da2005-12-05 19:42:22 +010015418/* patch-ALC861 */
15419
15420static struct snd_kcontrol_new alc861_base_mixer[] = {
15421 /* output mixer control */
15422 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15423 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15424 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15425 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15426 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15427
15428 /*Input mixer control */
15429 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15430 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15431 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15432 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15433 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15434 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15435 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15436 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15437 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15438 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015439
Kailang Yangdf694da2005-12-05 19:42:22 +010015440 { } /* end */
15441};
15442
15443static struct snd_kcontrol_new alc861_3ST_mixer[] = {
15444 /* output mixer control */
15445 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15446 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15447 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15448 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15449 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15450
15451 /* Input mixer control */
15452 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15453 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15454 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15455 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15456 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15457 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15458 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15459 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15460 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15461 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015462
Kailang Yangdf694da2005-12-05 19:42:22 +010015463 {
15464 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15465 .name = "Channel Mode",
15466 .info = alc_ch_mode_info,
15467 .get = alc_ch_mode_get,
15468 .put = alc_ch_mode_put,
15469 .private_value = ARRAY_SIZE(alc861_threestack_modes),
15470 },
15471 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015472};
15473
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015474static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015475 /* output mixer control */
15476 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15477 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15478 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015479
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015480 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015481};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015482
Takashi Iwai22309c32006-08-09 16:57:28 +020015483static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
15484 /* output mixer control */
15485 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15486 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15487 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15488 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15489 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15490
15491 /* Input mixer control */
15492 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15493 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15494 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15495 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15496 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15497 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15498 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15499 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15500 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15501 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015502
Takashi Iwai22309c32006-08-09 16:57:28 +020015503 {
15504 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15505 .name = "Channel Mode",
15506 .info = alc_ch_mode_info,
15507 .get = alc_ch_mode_get,
15508 .put = alc_ch_mode_put,
15509 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15510 },
15511 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015512};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015513
15514static struct snd_kcontrol_new alc861_asus_mixer[] = {
15515 /* output mixer control */
15516 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15517 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15518 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15519 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15520 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15521
15522 /* Input mixer control */
15523 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15524 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15525 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15526 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15527 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15528 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15529 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15530 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15531 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015532 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15533
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015534 {
15535 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15536 .name = "Channel Mode",
15537 .info = alc_ch_mode_info,
15538 .get = alc_ch_mode_get,
15539 .put = alc_ch_mode_put,
15540 .private_value = ARRAY_SIZE(alc861_asus_modes),
15541 },
15542 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015543};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015544
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015545/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015546static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015547 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15548 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015549 { }
15550};
15551
Kailang Yangdf694da2005-12-05 19:42:22 +010015552/*
15553 * generic initialization of ADC, input mixers and output mixers
15554 */
15555static struct hda_verb alc861_base_init_verbs[] = {
15556 /*
15557 * Unmute ADC0 and set the default input to mic-in
15558 */
15559 /* port-A for surround (rear panel) */
15560 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15561 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15562 /* port-B for mic-in (rear panel) with vref */
15563 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15564 /* port-C for line-in (rear panel) */
15565 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15566 /* port-D for Front */
15567 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15568 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15569 /* port-E for HP out (front panel) */
15570 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15571 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015572 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015573 /* port-F for mic-in (front panel) with vref */
15574 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15575 /* port-G for CLFE (rear panel) */
15576 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15577 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15578 /* port-H for side (rear panel) */
15579 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15580 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15581 /* CD-in */
15582 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15583 /* route front mic to ADC1*/
15584 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15585 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015586
Kailang Yangdf694da2005-12-05 19:42:22 +010015587 /* Unmute DAC0~3 & spdif out*/
15588 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15589 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15590 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15591 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15592 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015593
Kailang Yangdf694da2005-12-05 19:42:22 +010015594 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15595 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15596 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15597 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15598 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015599
Kailang Yangdf694da2005-12-05 19:42:22 +010015600 /* Unmute Stereo Mixer 15 */
15601 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15602 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15603 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015604 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015605
15606 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15607 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15608 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15609 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15610 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15611 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15612 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15613 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015614 /* hp used DAC 3 (Front) */
15615 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015616 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15617
15618 { }
15619};
15620
15621static struct hda_verb alc861_threestack_init_verbs[] = {
15622 /*
15623 * Unmute ADC0 and set the default input to mic-in
15624 */
15625 /* port-A for surround (rear panel) */
15626 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15627 /* port-B for mic-in (rear panel) with vref */
15628 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15629 /* port-C for line-in (rear panel) */
15630 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15631 /* port-D for Front */
15632 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15633 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15634 /* port-E for HP out (front panel) */
15635 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15636 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015637 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015638 /* port-F for mic-in (front panel) with vref */
15639 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15640 /* port-G for CLFE (rear panel) */
15641 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15642 /* port-H for side (rear panel) */
15643 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15644 /* CD-in */
15645 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15646 /* route front mic to ADC1*/
15647 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15648 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15649 /* Unmute DAC0~3 & spdif out*/
15650 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15651 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15652 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15653 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15654 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015655
Kailang Yangdf694da2005-12-05 19:42:22 +010015656 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15657 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15658 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15659 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15660 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015661
Kailang Yangdf694da2005-12-05 19:42:22 +010015662 /* Unmute Stereo Mixer 15 */
15663 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15664 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15665 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015666 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015667
15668 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15669 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15670 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15671 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15672 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15673 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15674 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15675 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015676 /* hp used DAC 3 (Front) */
15677 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015678 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15679 { }
15680};
Takashi Iwai22309c32006-08-09 16:57:28 +020015681
15682static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15683 /*
15684 * Unmute ADC0 and set the default input to mic-in
15685 */
15686 /* port-A for surround (rear panel) */
15687 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15688 /* port-B for mic-in (rear panel) with vref */
15689 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15690 /* port-C for line-in (rear panel) */
15691 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15692 /* port-D for Front */
15693 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15694 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15695 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015696 /* this has to be set to VREF80 */
15697 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015698 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015699 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015700 /* port-F for mic-in (front panel) with vref */
15701 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15702 /* port-G for CLFE (rear panel) */
15703 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15704 /* port-H for side (rear panel) */
15705 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15706 /* CD-in */
15707 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15708 /* route front mic to ADC1*/
15709 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15710 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15711 /* Unmute DAC0~3 & spdif out*/
15712 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15713 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15714 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15715 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15716 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015717
Takashi Iwai22309c32006-08-09 16:57:28 +020015718 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15719 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15720 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15721 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15722 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015723
Takashi Iwai22309c32006-08-09 16:57:28 +020015724 /* Unmute Stereo Mixer 15 */
15725 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15726 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15727 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015728 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015729
15730 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15731 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15732 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15733 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15734 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15735 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15736 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15737 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015738 /* hp used DAC 3 (Front) */
15739 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015740 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15741 { }
15742};
15743
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015744static struct hda_verb alc861_asus_init_verbs[] = {
15745 /*
15746 * Unmute ADC0 and set the default input to mic-in
15747 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015748 /* port-A for surround (rear panel)
15749 * according to codec#0 this is the HP jack
15750 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015751 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15752 /* route front PCM to HP */
15753 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15754 /* port-B for mic-in (rear panel) with vref */
15755 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15756 /* port-C for line-in (rear panel) */
15757 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15758 /* port-D for Front */
15759 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15760 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15761 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015762 /* this has to be set to VREF80 */
15763 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015764 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015765 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015766 /* port-F for mic-in (front panel) with vref */
15767 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15768 /* port-G for CLFE (rear panel) */
15769 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15770 /* port-H for side (rear panel) */
15771 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15772 /* CD-in */
15773 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15774 /* route front mic to ADC1*/
15775 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15776 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15777 /* Unmute DAC0~3 & spdif out*/
15778 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15779 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15780 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15781 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15782 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15783 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15784 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15785 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15786 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15787 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015788
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015789 /* Unmute Stereo Mixer 15 */
15790 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15791 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15792 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015793 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015794
15795 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15796 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15797 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15798 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15799 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15800 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15801 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15802 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015803 /* hp used DAC 3 (Front) */
15804 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015805 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15806 { }
15807};
15808
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015809/* additional init verbs for ASUS laptops */
15810static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15811 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15812 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15813 { }
15814};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015815
Kailang Yangdf694da2005-12-05 19:42:22 +010015816/*
15817 * generic initialization of ADC, input mixers and output mixers
15818 */
15819static struct hda_verb alc861_auto_init_verbs[] = {
15820 /*
15821 * Unmute ADC0 and set the default input to mic-in
15822 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015823 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015824 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015825
Kailang Yangdf694da2005-12-05 19:42:22 +010015826 /* Unmute DAC0~3 & spdif out*/
15827 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15828 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15829 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15830 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15831 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015832
Kailang Yangdf694da2005-12-05 19:42:22 +010015833 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15834 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15835 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15836 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15837 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015838
Kailang Yangdf694da2005-12-05 19:42:22 +010015839 /* Unmute Stereo Mixer 15 */
15840 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15841 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15842 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15843 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15844
Takashi Iwai1c209302009-07-22 15:17:45 +020015845 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15846 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15847 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15848 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15849 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15850 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15851 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15852 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015853
15854 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15855 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015856 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15857 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015858 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15859 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015860 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15861 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015862
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015863 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015864
15865 { }
15866};
15867
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015868static struct hda_verb alc861_toshiba_init_verbs[] = {
15869 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015870
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015871 { }
15872};
15873
15874/* toggle speaker-output according to the hp-jack state */
15875static void alc861_toshiba_automute(struct hda_codec *codec)
15876{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015877 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015878
Takashi Iwai47fd8302007-08-10 17:11:07 +020015879 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15880 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15881 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15882 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015883}
15884
15885static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15886 unsigned int res)
15887{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015888 if ((res >> 26) == ALC880_HP_EVENT)
15889 alc861_toshiba_automute(codec);
15890}
15891
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015892/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015893#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15894#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15895#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15896#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15897
15898
15899#define ALC861_DIGOUT_NID 0x07
15900
15901static struct hda_channel_mode alc861_8ch_modes[1] = {
15902 { 8, NULL }
15903};
15904
15905static hda_nid_t alc861_dac_nids[4] = {
15906 /* front, surround, clfe, side */
15907 0x03, 0x06, 0x05, 0x04
15908};
15909
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015910static hda_nid_t alc660_dac_nids[3] = {
15911 /* front, clfe, surround */
15912 0x03, 0x05, 0x06
15913};
15914
Kailang Yangdf694da2005-12-05 19:42:22 +010015915static hda_nid_t alc861_adc_nids[1] = {
15916 /* ADC0-2 */
15917 0x08,
15918};
15919
15920static struct hda_input_mux alc861_capture_source = {
15921 .num_items = 5,
15922 .items = {
15923 { "Mic", 0x0 },
15924 { "Front Mic", 0x3 },
15925 { "Line", 0x1 },
15926 { "CD", 0x4 },
15927 { "Mixer", 0x5 },
15928 },
15929};
15930
Takashi Iwai1c209302009-07-22 15:17:45 +020015931static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15932{
15933 struct alc_spec *spec = codec->spec;
15934 hda_nid_t mix, srcs[5];
15935 int i, j, num;
15936
15937 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15938 return 0;
15939 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15940 if (num < 0)
15941 return 0;
15942 for (i = 0; i < num; i++) {
15943 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015944 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015945 if (type != AC_WID_AUD_OUT)
15946 continue;
15947 for (j = 0; j < spec->multiout.num_dacs; j++)
15948 if (spec->multiout.dac_nids[j] == srcs[i])
15949 break;
15950 if (j >= spec->multiout.num_dacs)
15951 return srcs[i];
15952 }
15953 return 0;
15954}
15955
Kailang Yangdf694da2005-12-05 19:42:22 +010015956/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015957static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015958 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015959{
Takashi Iwai1c209302009-07-22 15:17:45 +020015960 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015961 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015962 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015963
15964 spec->multiout.dac_nids = spec->private_dac_nids;
15965 for (i = 0; i < cfg->line_outs; i++) {
15966 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015967 dac = alc861_look_for_dac(codec, nid);
15968 if (!dac)
15969 continue;
15970 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015971 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015972 return 0;
15973}
15974
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015975static int __alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15976 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015977{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015978 return __add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015979 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15980}
15981
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015982#define alc861_create_out_sw(codec, pfx, nid, chs) \
15983 __alc861_create_out_sw(codec, pfx, nid, 0, chs)
15984
Takashi Iwai1c209302009-07-22 15:17:45 +020015985/* add playback controls from the parsed DAC table */
15986static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15987 const struct auto_pin_cfg *cfg)
15988{
15989 struct alc_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +010015990 static const char * const chname[4] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015991 "Front", "Surround", NULL /*CLFE*/, "Side"
15992 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015993 const char *pfx = alc_get_line_out_pfx(cfg, true);
Kailang Yangdf694da2005-12-05 19:42:22 +010015994 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015995 int i, err;
15996
Kailang Yangdf694da2005-12-05 19:42:22 +010015997 for (i = 0; i < cfg->line_outs; i++) {
15998 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015999 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010016000 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016001 if (!pfx && i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010016002 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020016003 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016004 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016005 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016006 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016007 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016008 return err;
16009 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016010 const char *name = pfx;
David Henningsson5a882642011-03-23 08:35:07 +010016011 int index = i;
16012 if (!name) {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010016013 name = chname[i];
David Henningsson5a882642011-03-23 08:35:07 +010016014 index = 0;
16015 }
16016 err = __alc861_create_out_sw(codec, name, nid, index, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016017 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016018 return err;
16019 }
16020 }
16021 return 0;
16022}
16023
Takashi Iwai1c209302009-07-22 15:17:45 +020016024static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010016025{
Takashi Iwai1c209302009-07-22 15:17:45 +020016026 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016027 int err;
16028 hda_nid_t nid;
16029
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016030 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010016031 return 0;
16032
16033 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020016034 nid = alc861_look_for_dac(codec, pin);
16035 if (nid) {
16036 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
16037 if (err < 0)
16038 return err;
16039 spec->multiout.hp_nid = nid;
16040 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016041 }
16042 return 0;
16043}
16044
16045/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016046static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016047 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010016048{
Takashi Iwai05f5f472009-08-25 13:10:18 +020016049 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010016050}
16051
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016052static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
16053 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020016054 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010016055{
Takashi Iwai1c209302009-07-22 15:17:45 +020016056 hda_nid_t mix, srcs[5];
16057 int i, num;
16058
Jacek Luczak564c5be2008-05-03 18:41:23 +020016059 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
16060 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020016061 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020016062 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020016063 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
16064 return;
16065 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
16066 if (num < 0)
16067 return;
16068 for (i = 0; i < num; i++) {
16069 unsigned int mute;
16070 if (srcs[i] == dac || srcs[i] == 0x15)
16071 mute = AMP_IN_UNMUTE(i);
16072 else
16073 mute = AMP_IN_MUTE(i);
16074 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16075 mute);
16076 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016077}
16078
16079static void alc861_auto_init_multi_out(struct hda_codec *codec)
16080{
16081 struct alc_spec *spec = codec->spec;
16082 int i;
16083
16084 for (i = 0; i < spec->autocfg.line_outs; i++) {
16085 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016086 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016087 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016088 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016089 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016090 }
16091}
16092
16093static void alc861_auto_init_hp_out(struct hda_codec *codec)
16094{
16095 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016096
Takashi Iwai15870f02009-10-05 08:25:13 +020016097 if (spec->autocfg.hp_outs)
16098 alc861_auto_set_output_and_unmute(codec,
16099 spec->autocfg.hp_pins[0],
16100 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020016101 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020016102 if (spec->autocfg.speaker_outs)
16103 alc861_auto_set_output_and_unmute(codec,
16104 spec->autocfg.speaker_pins[0],
16105 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020016106 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016107}
16108
16109static void alc861_auto_init_analog_input(struct hda_codec *codec)
16110{
16111 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016112 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010016113 int i;
16114
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016115 for (i = 0; i < cfg->num_inputs; i++) {
16116 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010016117 if (nid >= 0x0c && nid <= 0x11)
Takashi Iwai30ea0982010-09-16 18:47:56 +020016118 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016119 }
16120}
16121
16122/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016123/* return 1 if successful, 0 if the proper config is not found,
16124 * or a negative error code
16125 */
Kailang Yangdf694da2005-12-05 19:42:22 +010016126static int alc861_parse_auto_config(struct hda_codec *codec)
16127{
16128 struct alc_spec *spec = codec->spec;
16129 int err;
16130 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
16131
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016132 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16133 alc861_ignore);
16134 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016135 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016136 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010016137 return 0; /* can't find valid BIOS pin config */
16138
Takashi Iwai1c209302009-07-22 15:17:45 +020016139 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016140 if (err < 0)
16141 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016142 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016143 if (err < 0)
16144 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016145 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016146 if (err < 0)
16147 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016148 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016149 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016150 return err;
16151
16152 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16153
Takashi Iwai757899a2010-07-30 10:48:14 +020016154 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016155
Takashi Iwai603c4012008-07-30 15:01:44 +020016156 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016157 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010016158
Takashi Iwaid88897e2008-10-31 15:01:37 +010016159 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010016160
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020016161 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016162 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010016163
16164 spec->adc_nids = alc861_adc_nids;
16165 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016166 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016167
Kailang Yang6227cdc2010-02-25 08:36:52 +010016168 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016169
Kailang Yangdf694da2005-12-05 19:42:22 +010016170 return 1;
16171}
16172
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016173/* additional initialization for auto-configuration model */
16174static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010016175{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016176 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016177 alc861_auto_init_multi_out(codec);
16178 alc861_auto_init_hp_out(codec);
16179 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020016180 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016181 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016182 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016183}
16184
Takashi Iwaicb53c622007-08-10 17:21:45 +020016185#ifdef CONFIG_SND_HDA_POWER_SAVE
16186static struct hda_amp_list alc861_loopbacks[] = {
16187 { 0x15, HDA_INPUT, 0 },
16188 { 0x15, HDA_INPUT, 1 },
16189 { 0x15, HDA_INPUT, 2 },
16190 { 0x15, HDA_INPUT, 3 },
16191 { } /* end */
16192};
16193#endif
16194
Kailang Yangdf694da2005-12-05 19:42:22 +010016195
16196/*
16197 * configuration and preset
16198 */
Takashi Iwaiea734962011-01-17 11:29:34 +010016199static const char * const alc861_models[ALC861_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016200 [ALC861_3ST] = "3stack",
16201 [ALC660_3ST] = "3stack-660",
16202 [ALC861_3ST_DIG] = "3stack-dig",
16203 [ALC861_6ST_DIG] = "6stack-dig",
16204 [ALC861_UNIWILL_M31] = "uniwill-m31",
16205 [ALC861_TOSHIBA] = "toshiba",
16206 [ALC861_ASUS] = "asus",
16207 [ALC861_ASUS_LAPTOP] = "asus-laptop",
16208 [ALC861_AUTO] = "auto",
16209};
16210
16211static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010016212 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016213 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16214 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16215 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016216 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020016217 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010016218 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020016219 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
16220 * Any other models that need this preset?
16221 */
16222 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020016223 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
16224 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016225 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
16226 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
16227 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
16228 /* FIXME: the below seems conflict */
16229 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
16230 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
16231 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010016232 {}
16233};
16234
16235static struct alc_config_preset alc861_presets[] = {
16236 [ALC861_3ST] = {
16237 .mixers = { alc861_3ST_mixer },
16238 .init_verbs = { alc861_threestack_init_verbs },
16239 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16240 .dac_nids = alc861_dac_nids,
16241 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16242 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016243 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016244 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16245 .adc_nids = alc861_adc_nids,
16246 .input_mux = &alc861_capture_source,
16247 },
16248 [ALC861_3ST_DIG] = {
16249 .mixers = { alc861_base_mixer },
16250 .init_verbs = { alc861_threestack_init_verbs },
16251 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16252 .dac_nids = alc861_dac_nids,
16253 .dig_out_nid = ALC861_DIGOUT_NID,
16254 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16255 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016256 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016257 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16258 .adc_nids = alc861_adc_nids,
16259 .input_mux = &alc861_capture_source,
16260 },
16261 [ALC861_6ST_DIG] = {
16262 .mixers = { alc861_base_mixer },
16263 .init_verbs = { alc861_base_init_verbs },
16264 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16265 .dac_nids = alc861_dac_nids,
16266 .dig_out_nid = ALC861_DIGOUT_NID,
16267 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
16268 .channel_mode = alc861_8ch_modes,
16269 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16270 .adc_nids = alc861_adc_nids,
16271 .input_mux = &alc861_capture_source,
16272 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016273 [ALC660_3ST] = {
16274 .mixers = { alc861_3ST_mixer },
16275 .init_verbs = { alc861_threestack_init_verbs },
16276 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
16277 .dac_nids = alc660_dac_nids,
16278 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16279 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016280 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016281 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16282 .adc_nids = alc861_adc_nids,
16283 .input_mux = &alc861_capture_source,
16284 },
Takashi Iwai22309c32006-08-09 16:57:28 +020016285 [ALC861_UNIWILL_M31] = {
16286 .mixers = { alc861_uniwill_m31_mixer },
16287 .init_verbs = { alc861_uniwill_m31_init_verbs },
16288 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16289 .dac_nids = alc861_dac_nids,
16290 .dig_out_nid = ALC861_DIGOUT_NID,
16291 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
16292 .channel_mode = alc861_uniwill_m31_modes,
16293 .need_dac_fix = 1,
16294 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16295 .adc_nids = alc861_adc_nids,
16296 .input_mux = &alc861_capture_source,
16297 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016298 [ALC861_TOSHIBA] = {
16299 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016300 .init_verbs = { alc861_base_init_verbs,
16301 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016302 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16303 .dac_nids = alc861_dac_nids,
16304 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16305 .channel_mode = alc883_3ST_2ch_modes,
16306 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16307 .adc_nids = alc861_adc_nids,
16308 .input_mux = &alc861_capture_source,
16309 .unsol_event = alc861_toshiba_unsol_event,
16310 .init_hook = alc861_toshiba_automute,
16311 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020016312 [ALC861_ASUS] = {
16313 .mixers = { alc861_asus_mixer },
16314 .init_verbs = { alc861_asus_init_verbs },
16315 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16316 .dac_nids = alc861_dac_nids,
16317 .dig_out_nid = ALC861_DIGOUT_NID,
16318 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
16319 .channel_mode = alc861_asus_modes,
16320 .need_dac_fix = 1,
16321 .hp_nid = 0x06,
16322 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16323 .adc_nids = alc861_adc_nids,
16324 .input_mux = &alc861_capture_source,
16325 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010016326 [ALC861_ASUS_LAPTOP] = {
16327 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
16328 .init_verbs = { alc861_asus_init_verbs,
16329 alc861_asus_laptop_init_verbs },
16330 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16331 .dac_nids = alc861_dac_nids,
16332 .dig_out_nid = ALC861_DIGOUT_NID,
16333 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16334 .channel_mode = alc883_3ST_2ch_modes,
16335 .need_dac_fix = 1,
16336 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16337 .adc_nids = alc861_adc_nids,
16338 .input_mux = &alc861_capture_source,
16339 },
16340};
Kailang Yangdf694da2005-12-05 19:42:22 +010016341
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016342/* Pin config fixes */
16343enum {
16344 PINFIX_FSC_AMILO_PI1505,
16345};
16346
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016347static const struct alc_fixup alc861_fixups[] = {
16348 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016349 .type = ALC_FIXUP_PINS,
16350 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020016351 { 0x0b, 0x0221101f }, /* HP */
16352 { 0x0f, 0x90170310 }, /* speaker */
16353 { }
16354 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016355 },
16356};
16357
16358static struct snd_pci_quirk alc861_fixup_tbl[] = {
16359 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
16360 {}
16361};
Kailang Yangdf694da2005-12-05 19:42:22 +010016362
16363static int patch_alc861(struct hda_codec *codec)
16364{
16365 struct alc_spec *spec;
16366 int board_config;
16367 int err;
16368
Robert P. J. Daydc041e02006-12-19 14:44:15 +010016369 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010016370 if (spec == NULL)
16371 return -ENOMEM;
16372
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016373 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016374
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016375 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
16376 alc861_models,
16377 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016378
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016379 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016380 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16381 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010016382 board_config = ALC861_AUTO;
16383 }
16384
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016385 if (board_config == ALC861_AUTO) {
16386 alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
16387 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
16388 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016389
Kailang Yangdf694da2005-12-05 19:42:22 +010016390 if (board_config == ALC861_AUTO) {
16391 /* automatic parse from the BIOS config */
16392 err = alc861_parse_auto_config(codec);
16393 if (err < 0) {
16394 alc_free(codec);
16395 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016396 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016397 printk(KERN_INFO
16398 "hda_codec: Cannot set up configuration "
16399 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010016400 board_config = ALC861_3ST_DIG;
16401 }
16402 }
16403
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016404 err = snd_hda_attach_beep_device(codec, 0x23);
16405 if (err < 0) {
16406 alc_free(codec);
16407 return err;
16408 }
16409
Kailang Yangdf694da2005-12-05 19:42:22 +010016410 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016411 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016412
Kailang Yangdf694da2005-12-05 19:42:22 +010016413 spec->stream_analog_playback = &alc861_pcm_analog_playback;
16414 spec->stream_analog_capture = &alc861_pcm_analog_capture;
16415
Kailang Yangdf694da2005-12-05 19:42:22 +010016416 spec->stream_digital_playback = &alc861_pcm_digital_playback;
16417 spec->stream_digital_capture = &alc861_pcm_digital_capture;
16418
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010016419 if (!spec->cap_mixer)
16420 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016421 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
16422
Takashi Iwai2134ea42008-01-10 16:53:55 +010016423 spec->vmaster_nid = 0x03;
16424
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016425 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016426
Kailang Yangdf694da2005-12-05 19:42:22 +010016427 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050016428 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016429 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016430#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050016431 spec->power_hook = alc_power_eapd;
16432#endif
16433 }
16434#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020016435 if (!spec->loopback.amplist)
16436 spec->loopback.amplist = alc861_loopbacks;
16437#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020016438
Kailang Yangdf694da2005-12-05 19:42:22 +010016439 return 0;
16440}
16441
16442/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016443 * ALC861-VD support
16444 *
16445 * Based on ALC882
16446 *
16447 * In addition, an independent DAC
16448 */
16449#define ALC861VD_DIGOUT_NID 0x06
16450
16451static hda_nid_t alc861vd_dac_nids[4] = {
16452 /* front, surr, clfe, side surr */
16453 0x02, 0x03, 0x04, 0x05
16454};
16455
16456/* dac_nids for ALC660vd are in a different order - according to
16457 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016458 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016459 * of ALC660vd codecs, but for now there is only 3stack mixer
16460 * - and it is the same as in 861vd.
16461 * adc_nids in ALC660vd are (is) the same as in 861vd
16462 */
16463static hda_nid_t alc660vd_dac_nids[3] = {
16464 /* front, rear, clfe, rear_surr */
16465 0x02, 0x04, 0x03
16466};
16467
16468static hda_nid_t alc861vd_adc_nids[1] = {
16469 /* ADC0 */
16470 0x09,
16471};
16472
Takashi Iwaie1406342008-02-11 18:32:32 +010016473static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
16474
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016475/* input MUX */
16476/* FIXME: should be a matrix-type input source selection */
16477static struct hda_input_mux alc861vd_capture_source = {
16478 .num_items = 4,
16479 .items = {
16480 { "Mic", 0x0 },
16481 { "Front Mic", 0x1 },
16482 { "Line", 0x2 },
16483 { "CD", 0x4 },
16484 },
16485};
16486
Kailang Yang272a5272007-05-14 11:00:38 +020016487static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016488 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016489 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +010016490 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010016491 { "Internal Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016492 },
16493};
16494
Kailang Yangd1a991a2007-08-15 16:21:59 +020016495static struct hda_input_mux alc861vd_hp_capture_source = {
16496 .num_items = 2,
16497 .items = {
16498 { "Front Mic", 0x0 },
16499 { "ATAPI Mic", 0x1 },
16500 },
16501};
16502
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016503/*
16504 * 2ch mode
16505 */
16506static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16507 { 2, NULL }
16508};
16509
16510/*
16511 * 6ch mode
16512 */
16513static struct hda_verb alc861vd_6stack_ch6_init[] = {
16514 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16515 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16516 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16517 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16518 { } /* end */
16519};
16520
16521/*
16522 * 8ch mode
16523 */
16524static struct hda_verb alc861vd_6stack_ch8_init[] = {
16525 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16526 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16527 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16528 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16529 { } /* end */
16530};
16531
16532static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16533 { 6, alc861vd_6stack_ch6_init },
16534 { 8, alc861vd_6stack_ch8_init },
16535};
16536
16537static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16538 {
16539 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16540 .name = "Channel Mode",
16541 .info = alc_ch_mode_info,
16542 .get = alc_ch_mode_get,
16543 .put = alc_ch_mode_put,
16544 },
16545 { } /* end */
16546};
16547
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016548/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16549 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16550 */
16551static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16552 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16553 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16554
16555 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16556 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16557
16558 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16559 HDA_OUTPUT),
16560 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16561 HDA_OUTPUT),
16562 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16563 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16564
16565 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16566 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16567
16568 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16569
David Henningsson5f99f862011-01-04 15:24:24 +010016570 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016571 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16572 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16573
David Henningsson5f99f862011-01-04 15:24:24 +010016574 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016575 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16576 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16577
16578 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16579 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16580
16581 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16582 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16583
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016584 { } /* end */
16585};
16586
16587static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16588 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16589 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16590
16591 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16592
David Henningsson5f99f862011-01-04 15:24:24 +010016593 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016594 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16595 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16596
David Henningsson5f99f862011-01-04 15:24:24 +010016597 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016598 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16599 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16600
16601 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16602 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16603
16604 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16605 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16606
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016607 { } /* end */
16608};
16609
Kailang Yangbdd148a2007-05-08 15:19:08 +020016610static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16611 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16612 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16613 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16614
16615 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16616
David Henningsson5f99f862011-01-04 15:24:24 +010016617 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016618 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16619 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16620
David Henningsson5f99f862011-01-04 15:24:24 +010016621 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016622 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16623 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16624
16625 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16626 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16627
16628 { } /* end */
16629};
16630
Tobin Davisb419f342008-03-07 11:57:51 +010016631/* Pin assignment: Speaker=0x14, HP = 0x15,
David Henningsson8607f7c2010-12-20 14:43:54 +010016632 * Mic=0x18, Internal Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016633 */
16634static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016635 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16636 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016637 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16638 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016639 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +010016640 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16641 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016642 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010016643 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16644 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016645 { } /* end */
16646};
16647
Kailang Yangd1a991a2007-08-15 16:21:59 +020016648/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16649 * Front Mic=0x18, ATAPI Mic = 0x19,
16650 */
16651static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16652 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16653 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16654 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16655 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16656 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16657 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16658 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16659 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016660
Kailang Yangd1a991a2007-08-15 16:21:59 +020016661 { } /* end */
16662};
16663
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016664/*
16665 * generic initialization of ADC, input mixers and output mixers
16666 */
16667static struct hda_verb alc861vd_volume_init_verbs[] = {
16668 /*
16669 * Unmute ADC0 and set the default input to mic-in
16670 */
16671 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16672 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16673
16674 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16675 * the analog-loopback mixer widget
16676 */
16677 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016678 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16679 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16680 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16681 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16682 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016683
16684 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016685 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16686 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16687 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016688 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016689
16690 /*
16691 * Set up output mixers (0x02 - 0x05)
16692 */
16693 /* set vol=0 to output mixers */
16694 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16695 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16696 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16697 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16698
16699 /* set up input amps for analog loopback */
16700 /* Amp Indices: DAC = 0, mixer = 1 */
16701 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16702 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16703 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16704 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16705 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16706 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16707 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16708 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16709
16710 { }
16711};
16712
16713/*
16714 * 3-stack pin configuration:
16715 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16716 */
16717static struct hda_verb alc861vd_3stack_init_verbs[] = {
16718 /*
16719 * Set pin mode and muting
16720 */
16721 /* set front pin widgets 0x14 for output */
16722 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16723 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16724 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16725
16726 /* Mic (rear) pin: input vref at 80% */
16727 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16728 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16729 /* Front Mic pin: input vref at 80% */
16730 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16731 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16732 /* Line In pin: input */
16733 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16734 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16735 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16736 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16737 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16738 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16739 /* CD pin widget for input */
16740 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16741
16742 { }
16743};
16744
16745/*
16746 * 6-stack pin configuration:
16747 */
16748static struct hda_verb alc861vd_6stack_init_verbs[] = {
16749 /*
16750 * Set pin mode and muting
16751 */
16752 /* set front pin widgets 0x14 for output */
16753 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16754 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16755 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16756
16757 /* Rear Pin: output 1 (0x0d) */
16758 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16759 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16760 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16761 /* CLFE Pin: output 2 (0x0e) */
16762 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16763 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16764 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16765 /* Side Pin: output 3 (0x0f) */
16766 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16767 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16768 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16769
16770 /* Mic (rear) pin: input vref at 80% */
16771 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16772 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16773 /* Front Mic pin: input vref at 80% */
16774 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16775 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16776 /* Line In pin: input */
16777 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16778 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16779 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16780 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16781 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16782 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16783 /* CD pin widget for input */
16784 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16785
16786 { }
16787};
16788
Kailang Yangbdd148a2007-05-08 15:19:08 +020016789static struct hda_verb alc861vd_eapd_verbs[] = {
16790 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16791 { }
16792};
16793
Kailang Yangf9423e72008-05-27 12:32:25 +020016794static struct hda_verb alc660vd_eapd_verbs[] = {
16795 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16796 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16797 { }
16798};
16799
Kailang Yangbdd148a2007-05-08 15:19:08 +020016800static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16801 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16802 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16803 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16804 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016805 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016806 {}
16807};
16808
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016809static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016810{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016811 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016812 spec->autocfg.hp_pins[0] = 0x1b;
16813 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016814}
16815
16816static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16817{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016818 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +010016819 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016820}
16821
16822static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16823 unsigned int res)
16824{
16825 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016826 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +010016827 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016828 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016829 default:
16830 alc_automute_amp_unsol_event(codec, res);
16831 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016832 }
16833}
16834
Kailang Yang272a5272007-05-14 11:00:38 +020016835static struct hda_verb alc861vd_dallas_verbs[] = {
16836 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16837 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16838 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16839 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16840
16841 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16842 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16843 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16844 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16845 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16846 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16847 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16848 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016849
Kailang Yang272a5272007-05-14 11:00:38 +020016850 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16851 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16852 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16853 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16854 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16855 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16856 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16857 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16858
16859 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16860 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16861 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16862 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16863 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16864 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16865 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16866 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16867
16868 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16869 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16870 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16871 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16872
16873 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016874 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016875 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16876
16877 { } /* end */
16878};
16879
16880/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016881static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016882{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016883 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016884
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016885 spec->autocfg.hp_pins[0] = 0x15;
16886 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016887}
16888
Takashi Iwaicb53c622007-08-10 17:21:45 +020016889#ifdef CONFIG_SND_HDA_POWER_SAVE
16890#define alc861vd_loopbacks alc880_loopbacks
16891#endif
16892
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016893/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016894#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16895#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16896#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16897#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16898
16899/*
16900 * configuration and preset
16901 */
Takashi Iwaiea734962011-01-17 11:29:34 +010016902static const char * const alc861vd_models[ALC861VD_MODEL_LAST] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016903 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016904 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016905 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016906 [ALC861VD_3ST] = "3stack",
16907 [ALC861VD_3ST_DIG] = "3stack-digout",
16908 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016909 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016910 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016911 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016912 [ALC861VD_AUTO] = "auto",
16913};
16914
16915static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016916 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16917 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016918 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016919 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016920 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016921 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016922 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016923 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016924 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016925 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016926 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016927 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016928 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016929 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016930 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016931 {}
16932};
16933
16934static struct alc_config_preset alc861vd_presets[] = {
16935 [ALC660VD_3ST] = {
16936 .mixers = { alc861vd_3st_mixer },
16937 .init_verbs = { alc861vd_volume_init_verbs,
16938 alc861vd_3stack_init_verbs },
16939 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16940 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016941 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16942 .channel_mode = alc861vd_3stack_2ch_modes,
16943 .input_mux = &alc861vd_capture_source,
16944 },
Mike Crash6963f842007-06-25 12:12:51 +020016945 [ALC660VD_3ST_DIG] = {
16946 .mixers = { alc861vd_3st_mixer },
16947 .init_verbs = { alc861vd_volume_init_verbs,
16948 alc861vd_3stack_init_verbs },
16949 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16950 .dac_nids = alc660vd_dac_nids,
16951 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016952 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16953 .channel_mode = alc861vd_3stack_2ch_modes,
16954 .input_mux = &alc861vd_capture_source,
16955 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016956 [ALC861VD_3ST] = {
16957 .mixers = { alc861vd_3st_mixer },
16958 .init_verbs = { alc861vd_volume_init_verbs,
16959 alc861vd_3stack_init_verbs },
16960 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16961 .dac_nids = alc861vd_dac_nids,
16962 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16963 .channel_mode = alc861vd_3stack_2ch_modes,
16964 .input_mux = &alc861vd_capture_source,
16965 },
16966 [ALC861VD_3ST_DIG] = {
16967 .mixers = { alc861vd_3st_mixer },
16968 .init_verbs = { alc861vd_volume_init_verbs,
16969 alc861vd_3stack_init_verbs },
16970 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16971 .dac_nids = alc861vd_dac_nids,
16972 .dig_out_nid = ALC861VD_DIGOUT_NID,
16973 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16974 .channel_mode = alc861vd_3stack_2ch_modes,
16975 .input_mux = &alc861vd_capture_source,
16976 },
16977 [ALC861VD_6ST_DIG] = {
16978 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16979 .init_verbs = { alc861vd_volume_init_verbs,
16980 alc861vd_6stack_init_verbs },
16981 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16982 .dac_nids = alc861vd_dac_nids,
16983 .dig_out_nid = ALC861VD_DIGOUT_NID,
16984 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16985 .channel_mode = alc861vd_6stack_modes,
16986 .input_mux = &alc861vd_capture_source,
16987 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016988 [ALC861VD_LENOVO] = {
16989 .mixers = { alc861vd_lenovo_mixer },
16990 .init_verbs = { alc861vd_volume_init_verbs,
16991 alc861vd_3stack_init_verbs,
16992 alc861vd_eapd_verbs,
16993 alc861vd_lenovo_unsol_verbs },
16994 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16995 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016996 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16997 .channel_mode = alc861vd_3stack_2ch_modes,
16998 .input_mux = &alc861vd_capture_source,
16999 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017000 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017001 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017002 },
Kailang Yang272a5272007-05-14 11:00:38 +020017003 [ALC861VD_DALLAS] = {
17004 .mixers = { alc861vd_dallas_mixer },
17005 .init_verbs = { alc861vd_dallas_verbs },
17006 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
17007 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020017008 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17009 .channel_mode = alc861vd_3stack_2ch_modes,
17010 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017011 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017012 .setup = alc861vd_dallas_setup,
17013 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017014 },
17015 [ALC861VD_HP] = {
17016 .mixers = { alc861vd_hp_mixer },
17017 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
17018 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
17019 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017020 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017021 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17022 .channel_mode = alc861vd_3stack_2ch_modes,
17023 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017024 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017025 .setup = alc861vd_dallas_setup,
17026 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020017027 },
Takashi Iwai13c94742008-11-05 08:06:08 +010017028 [ALC660VD_ASUS_V1S] = {
17029 .mixers = { alc861vd_lenovo_mixer },
17030 .init_verbs = { alc861vd_volume_init_verbs,
17031 alc861vd_3stack_init_verbs,
17032 alc861vd_eapd_verbs,
17033 alc861vd_lenovo_unsol_verbs },
17034 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
17035 .dac_nids = alc660vd_dac_nids,
17036 .dig_out_nid = ALC861VD_DIGOUT_NID,
17037 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17038 .channel_mode = alc861vd_3stack_2ch_modes,
17039 .input_mux = &alc861vd_capture_source,
17040 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017041 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017042 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010017043 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017044};
17045
17046/*
17047 * BIOS auto configuration
17048 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017049static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
17050 const struct auto_pin_cfg *cfg)
17051{
Herton Ronaldo Krzesinski71675942010-11-25 00:08:01 -020017052 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x22, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020017053}
17054
17055
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017056static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
17057 hda_nid_t nid, int pin_type, int dac_idx)
17058{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017059 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017060}
17061
17062static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
17063{
17064 struct alc_spec *spec = codec->spec;
17065 int i;
17066
17067 for (i = 0; i <= HDA_SIDE; i++) {
17068 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017069 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017070 if (nid)
17071 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017072 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017073 }
17074}
17075
17076
17077static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
17078{
17079 struct alc_spec *spec = codec->spec;
17080 hda_nid_t pin;
17081
17082 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017083 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017084 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017085 pin = spec->autocfg.speaker_pins[0];
17086 if (pin)
17087 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017088}
17089
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017090#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
17091
17092static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
17093{
17094 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017095 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017096 int i;
17097
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017098 for (i = 0; i < cfg->num_inputs; i++) {
17099 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017100 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020017101 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +010017102 if (nid != ALC861VD_PIN_CD_NID &&
17103 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017104 snd_hda_codec_write(codec, nid, 0,
17105 AC_VERB_SET_AMP_GAIN_MUTE,
17106 AMP_OUT_MUTE);
17107 }
17108 }
17109}
17110
Takashi Iwaif511b012008-08-15 16:46:42 +020017111#define alc861vd_auto_init_input_src alc882_auto_init_input_src
17112
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017113#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
17114#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
17115
17116/* add playback controls from the parsed DAC table */
Takashi Iwai569ed342011-01-19 10:14:46 +010017117/* Based on ALC880 version. But ALC861VD has separate,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017118 * different NIDs for mute/unmute switch and volume control */
17119static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
17120 const struct auto_pin_cfg *cfg)
17121{
Takashi Iwaiea734962011-01-17 11:29:34 +010017122 static const char * const chname[4] = {
17123 "Front", "Surround", "CLFE", "Side"
17124 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017125 const char *pfx = alc_get_line_out_pfx(cfg, true);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017126 hda_nid_t nid_v, nid_s;
17127 int i, err;
17128
17129 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017130 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017131 continue;
17132 nid_v = alc861vd_idx_to_mixer_vol(
17133 alc880_dac_to_idx(
17134 spec->multiout.dac_nids[i]));
17135 nid_s = alc861vd_idx_to_mixer_switch(
17136 alc880_dac_to_idx(
17137 spec->multiout.dac_nids[i]));
17138
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017139 if (!pfx && i == 2) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017140 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017141 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17142 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017143 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
17144 HDA_OUTPUT));
17145 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017146 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017147 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17148 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017149 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
17150 HDA_OUTPUT));
17151 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017152 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017153 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17154 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017155 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
17156 HDA_INPUT));
17157 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017158 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017159 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17160 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017161 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
17162 HDA_INPUT));
17163 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017164 return err;
17165 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017166 const char *name = pfx;
David Henningsson5a882642011-03-23 08:35:07 +010017167 int index = i;
17168 if (!name) {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017169 name = chname[i];
David Henningsson5a882642011-03-23 08:35:07 +010017170 index = 0;
17171 }
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017172 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
David Henningsson5a882642011-03-23 08:35:07 +010017173 name, index,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017174 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
17175 HDA_OUTPUT));
17176 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017177 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017178 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
David Henningsson5a882642011-03-23 08:35:07 +010017179 name, index,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017180 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017181 HDA_INPUT));
17182 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017183 return err;
17184 }
17185 }
17186 return 0;
17187}
17188
17189/* add playback controls for speaker and HP outputs */
17190/* Based on ALC880 version. But ALC861VD has separate,
17191 * different NIDs for mute/unmute switch and volume control */
17192static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
17193 hda_nid_t pin, const char *pfx)
17194{
17195 hda_nid_t nid_v, nid_s;
17196 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017197
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017198 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017199 return 0;
17200
17201 if (alc880_is_fixed_pin(pin)) {
17202 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17203 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017204 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017205 spec->multiout.hp_nid = nid_v;
17206 else
17207 spec->multiout.extra_out_nid[0] = nid_v;
17208 /* control HP volume/switch on the output mixer amp */
17209 nid_v = alc861vd_idx_to_mixer_vol(
17210 alc880_fixed_pin_idx(pin));
17211 nid_s = alc861vd_idx_to_mixer_switch(
17212 alc880_fixed_pin_idx(pin));
17213
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017214 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017215 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
17216 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017217 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017218 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017219 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
17220 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017221 return err;
17222 } else if (alc880_is_multi_pin(pin)) {
17223 /* set manual connection */
17224 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017225 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017226 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17227 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017228 return err;
17229 }
17230 return 0;
17231}
17232
17233/* parse the BIOS configuration and set up the alc_spec
17234 * return 1 if successful, 0 if the proper config is not found,
17235 * or a negative error code
17236 * Based on ALC880 version - had to change it to override
17237 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
17238static int alc861vd_parse_auto_config(struct hda_codec *codec)
17239{
17240 struct alc_spec *spec = codec->spec;
17241 int err;
17242 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
17243
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017244 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17245 alc861vd_ignore);
17246 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017247 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017248 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017249 return 0; /* can't find valid BIOS pin config */
17250
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017251 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17252 if (err < 0)
17253 return err;
17254 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
17255 if (err < 0)
17256 return err;
17257 err = alc861vd_auto_create_extra_out(spec,
17258 spec->autocfg.speaker_pins[0],
17259 "Speaker");
17260 if (err < 0)
17261 return err;
17262 err = alc861vd_auto_create_extra_out(spec,
17263 spec->autocfg.hp_pins[0],
17264 "Headphone");
17265 if (err < 0)
17266 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017267 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017268 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017269 return err;
17270
17271 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17272
Takashi Iwai757899a2010-07-30 10:48:14 +020017273 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017274
Takashi Iwai603c4012008-07-30 15:01:44 +020017275 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017276 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017277
Takashi Iwaid88897e2008-10-31 15:01:37 +010017278 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017279
17280 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017281 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017282
Takashi Iwai776e1842007-08-29 15:07:11 +020017283 err = alc_auto_add_mic_boost(codec);
17284 if (err < 0)
17285 return err;
17286
Kailang Yang6227cdc2010-02-25 08:36:52 +010017287 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017288
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017289 return 1;
17290}
17291
17292/* additional initialization for auto-configuration model */
17293static void alc861vd_auto_init(struct hda_codec *codec)
17294{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017295 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017296 alc861vd_auto_init_multi_out(codec);
17297 alc861vd_auto_init_hp_out(codec);
17298 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017299 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020017300 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017301 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017302 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017303}
17304
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017305enum {
17306 ALC660VD_FIX_ASUS_GPIO1
17307};
17308
17309/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017310static const struct alc_fixup alc861vd_fixups[] = {
17311 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017312 .type = ALC_FIXUP_VERBS,
17313 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020017314 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
17315 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
17316 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
17317 { }
17318 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017319 },
17320};
17321
17322static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
17323 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
17324 {}
17325};
17326
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017327static int patch_alc861vd(struct hda_codec *codec)
17328{
17329 struct alc_spec *spec;
17330 int err, board_config;
17331
17332 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17333 if (spec == NULL)
17334 return -ENOMEM;
17335
17336 codec->spec = spec;
17337
17338 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
17339 alc861vd_models,
17340 alc861vd_cfg_tbl);
17341
17342 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017343 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17344 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017345 board_config = ALC861VD_AUTO;
17346 }
17347
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017348 if (board_config == ALC861VD_AUTO) {
17349 alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
17350 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
17351 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017352
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017353 if (board_config == ALC861VD_AUTO) {
17354 /* automatic parse from the BIOS config */
17355 err = alc861vd_parse_auto_config(codec);
17356 if (err < 0) {
17357 alc_free(codec);
17358 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017359 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017360 printk(KERN_INFO
17361 "hda_codec: Cannot set up configuration "
17362 "from BIOS. Using base mode...\n");
17363 board_config = ALC861VD_3ST;
17364 }
17365 }
17366
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017367 err = snd_hda_attach_beep_device(codec, 0x23);
17368 if (err < 0) {
17369 alc_free(codec);
17370 return err;
17371 }
17372
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017373 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017374 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017375
Kailang Yang2f893282008-05-27 12:14:47 +020017376 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020017377 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010017378 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020017379 }
17380
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017381 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
17382 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
17383
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017384 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
17385 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
17386
Takashi Iwaidd704692009-08-11 08:45:11 +020017387 if (!spec->adc_nids) {
17388 spec->adc_nids = alc861vd_adc_nids;
17389 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
17390 }
17391 if (!spec->capsrc_nids)
17392 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017393
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017394 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010017395 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017396
Takashi Iwai2134ea42008-01-10 16:53:55 +010017397 spec->vmaster_nid = 0x02;
17398
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017399 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017400
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017401 codec->patch_ops = alc_patch_ops;
17402
17403 if (board_config == ALC861VD_AUTO)
17404 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017405#ifdef CONFIG_SND_HDA_POWER_SAVE
17406 if (!spec->loopback.amplist)
17407 spec->loopback.amplist = alc861vd_loopbacks;
17408#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017409
17410 return 0;
17411}
17412
17413/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017414 * ALC662 support
17415 *
17416 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
17417 * configuration. Each pin widget can choose any input DACs and a mixer.
17418 * Each ADC is connected from a mixer of all inputs. This makes possible
17419 * 6-channel independent captures.
17420 *
17421 * In addition, an independent DAC for the multi-playback (not used in this
17422 * driver yet).
17423 */
17424#define ALC662_DIGOUT_NID 0x06
17425#define ALC662_DIGIN_NID 0x0a
17426
17427static hda_nid_t alc662_dac_nids[4] = {
17428 /* front, rear, clfe, rear_surr */
17429 0x02, 0x03, 0x04
17430};
17431
Kailang Yang622e84c2009-04-21 07:39:04 +020017432static hda_nid_t alc272_dac_nids[2] = {
17433 0x02, 0x03
17434};
17435
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017436static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017437 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017438 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017439};
Takashi Iwaie1406342008-02-11 18:32:32 +010017440
Kailang Yang622e84c2009-04-21 07:39:04 +020017441static hda_nid_t alc272_adc_nids[1] = {
17442 /* ADC1-2 */
17443 0x08,
17444};
17445
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017446static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020017447static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
17448
Takashi Iwaie1406342008-02-11 18:32:32 +010017449
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017450/* input MUX */
17451/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017452static struct hda_input_mux alc662_capture_source = {
17453 .num_items = 4,
17454 .items = {
17455 { "Mic", 0x0 },
17456 { "Front Mic", 0x1 },
17457 { "Line", 0x2 },
17458 { "CD", 0x4 },
17459 },
17460};
17461
17462static struct hda_input_mux alc662_lenovo_101e_capture_source = {
17463 .num_items = 2,
17464 .items = {
17465 { "Mic", 0x1 },
17466 { "Line", 0x2 },
17467 },
17468};
Kailang Yang291702f2007-10-16 14:28:03 +020017469
Kailang Yang6dda9f42008-05-27 12:05:31 +020017470static struct hda_input_mux alc663_capture_source = {
17471 .num_items = 3,
17472 .items = {
17473 { "Mic", 0x0 },
17474 { "Front Mic", 0x1 },
17475 { "Line", 0x2 },
17476 },
17477};
17478
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017479#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020017480static struct hda_input_mux alc272_nc10_capture_source = {
17481 .num_items = 16,
17482 .items = {
17483 { "Autoselect Mic", 0x0 },
17484 { "Internal Mic", 0x1 },
17485 { "In-0x02", 0x2 },
17486 { "In-0x03", 0x3 },
17487 { "In-0x04", 0x4 },
17488 { "In-0x05", 0x5 },
17489 { "In-0x06", 0x6 },
17490 { "In-0x07", 0x7 },
17491 { "In-0x08", 0x8 },
17492 { "In-0x09", 0x9 },
17493 { "In-0x0a", 0x0a },
17494 { "In-0x0b", 0x0b },
17495 { "In-0x0c", 0x0c },
17496 { "In-0x0d", 0x0d },
17497 { "In-0x0e", 0x0e },
17498 { "In-0x0f", 0x0f },
17499 },
17500};
17501#endif
17502
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017503/*
17504 * 2ch mode
17505 */
17506static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17507 { 2, NULL }
17508};
17509
17510/*
17511 * 2ch mode
17512 */
17513static struct hda_verb alc662_3ST_ch2_init[] = {
17514 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17515 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17516 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17517 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17518 { } /* end */
17519};
17520
17521/*
17522 * 6ch mode
17523 */
17524static struct hda_verb alc662_3ST_ch6_init[] = {
17525 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17526 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17527 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17528 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17529 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17530 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17531 { } /* end */
17532};
17533
17534static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17535 { 2, alc662_3ST_ch2_init },
17536 { 6, alc662_3ST_ch6_init },
17537};
17538
17539/*
17540 * 2ch mode
17541 */
17542static struct hda_verb alc662_sixstack_ch6_init[] = {
17543 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17544 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17545 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17546 { } /* end */
17547};
17548
17549/*
17550 * 6ch mode
17551 */
17552static struct hda_verb alc662_sixstack_ch8_init[] = {
17553 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17554 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17555 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17556 { } /* end */
17557};
17558
17559static struct hda_channel_mode alc662_5stack_modes[2] = {
17560 { 2, alc662_sixstack_ch6_init },
17561 { 6, alc662_sixstack_ch8_init },
17562};
17563
17564/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17565 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17566 */
17567
17568static struct snd_kcontrol_new alc662_base_mixer[] = {
17569 /* output mixer control */
17570 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 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_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017573 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017574 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17575 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017576 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17577 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017578 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17579
17580 /*Input mixer control */
17581 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17582 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17583 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17584 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17585 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17586 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17587 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17588 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017589 { } /* end */
17590};
17591
17592static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17593 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017594 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017595 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17596 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17597 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17598 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17599 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17600 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17601 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17602 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17603 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017604 { } /* end */
17605};
17606
17607static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17608 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017609 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017610 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017611 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017612 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17613 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017614 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17615 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017616 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17617 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17618 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17619 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17620 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17621 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17622 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17623 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17624 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017625 { } /* end */
17626};
17627
17628static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17629 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17630 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017631 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17632 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017633 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17634 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17635 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17636 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17637 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017638 { } /* end */
17639};
17640
Kailang Yang291702f2007-10-16 14:28:03 +020017641static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017642 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17643 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017644
David Henningsson5f99f862011-01-04 15:24:24 +010017645 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017646 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17647 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017648
David Henningsson5f99f862011-01-04 15:24:24 +010017649 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017650 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17651 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017652 { } /* end */
17653};
17654
Kailang Yang8c427222008-01-10 13:03:59 +010017655static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017656 ALC262_HIPPO_MASTER_SWITCH,
17657 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017658 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017659 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17660 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017661 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17662 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17663 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17664 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17665 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17666 { } /* end */
17667};
17668
Kailang Yangf1d4e282008-08-26 14:03:29 +020017669static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17670 .ops = &snd_hda_bind_vol,
17671 .values = {
17672 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17673 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17674 0
17675 },
17676};
17677
17678static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17679 .ops = &snd_hda_bind_sw,
17680 .values = {
17681 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17682 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17683 0
17684 },
17685};
17686
Kailang Yang6dda9f42008-05-27 12:05:31 +020017687static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017688 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17689 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17690 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17691 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17692 { } /* end */
17693};
17694
17695static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17696 .ops = &snd_hda_bind_sw,
17697 .values = {
17698 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17699 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17700 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17701 0
17702 },
17703};
17704
17705static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17706 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17707 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17708 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17709 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17710 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17711 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17712
17713 { } /* end */
17714};
17715
17716static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17717 .ops = &snd_hda_bind_sw,
17718 .values = {
17719 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17720 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17721 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17722 0
17723 },
17724};
17725
17726static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17727 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17728 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17729 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17730 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17731 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17732 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17733 { } /* end */
17734};
17735
17736static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017737 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17738 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017739 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17740 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17741 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17742 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17743 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17744 { } /* end */
17745};
17746
17747static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17748 .ops = &snd_hda_bind_vol,
17749 .values = {
17750 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17751 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17752 0
17753 },
17754};
17755
17756static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17757 .ops = &snd_hda_bind_sw,
17758 .values = {
17759 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17760 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17761 0
17762 },
17763};
17764
17765static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17766 HDA_BIND_VOL("Master Playback Volume",
17767 &alc663_asus_two_bind_master_vol),
17768 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17769 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017770 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17771 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17772 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017773 { } /* end */
17774};
17775
17776static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17777 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17778 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17779 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17780 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17781 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17782 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017783 { } /* end */
17784};
17785
17786static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17787 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17788 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17789 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17790 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17791 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17792
17793 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17794 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017795 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17796 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017797 { } /* end */
17798};
17799
17800static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17801 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17802 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17803 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17804
17805 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17806 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017807 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17808 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017809 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17810 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17811 { } /* end */
17812};
17813
Kailang Yangebb83ee2009-12-17 12:23:00 +010017814static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17815 .ops = &snd_hda_bind_sw,
17816 .values = {
17817 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17818 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17819 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17820 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17821 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17822 0
17823 },
17824};
17825
17826static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17827 .ops = &snd_hda_bind_sw,
17828 .values = {
17829 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17830 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17831 0
17832 },
17833};
17834
17835static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17836 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17837 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17838 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17839 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17840 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17841 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17842 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17843 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17844 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17845 { } /* end */
17846};
17847
17848static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17849 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17850 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17851 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17852 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17853 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17854 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17855 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17856 { } /* end */
17857};
17858
17859
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017860static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17861 {
17862 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17863 .name = "Channel Mode",
17864 .info = alc_ch_mode_info,
17865 .get = alc_ch_mode_get,
17866 .put = alc_ch_mode_put,
17867 },
17868 { } /* end */
17869};
17870
17871static struct hda_verb alc662_init_verbs[] = {
17872 /* ADC: mute amp left and right */
17873 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17874 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017875
Kailang Yangb60dd392007-09-20 12:50:29 +020017876 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17877 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17878 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17879 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17880 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17881 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017882
17883 /* Front Pin: output 0 (0x0c) */
17884 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17885 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17886
17887 /* Rear Pin: output 1 (0x0d) */
17888 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17889 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17890
17891 /* CLFE Pin: output 2 (0x0e) */
17892 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17893 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17894
17895 /* Mic (rear) pin: input vref at 80% */
17896 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17897 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17898 /* Front Mic pin: input vref at 80% */
17899 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17900 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17901 /* Line In pin: input */
17902 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17903 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17904 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17905 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17906 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17907 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17908 /* CD pin widget for input */
17909 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17910
17911 /* FIXME: use matrix-type input source selection */
17912 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17913 /* Input mixer */
17914 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017915 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017916
17917 /* always trun on EAPD */
17918 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17919 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17920
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017921 { }
17922};
17923
Kailang Yangcec27c82010-02-04 14:18:18 +010017924static struct hda_verb alc663_init_verbs[] = {
17925 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17926 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17927 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17928 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17929 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17930 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17931 { }
17932};
17933
17934static struct hda_verb alc272_init_verbs[] = {
17935 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17936 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17937 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17938 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17939 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17940 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17941 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17942 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17943 { }
17944};
17945
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017946static struct hda_verb alc662_sue_init_verbs[] = {
17947 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17948 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017949 {}
17950};
17951
17952static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17953 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17954 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17955 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017956};
17957
Kailang Yang8c427222008-01-10 13:03:59 +010017958/* Set Unsolicited Event*/
17959static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17960 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17961 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17962 {}
17963};
17964
Kailang Yang6dda9f42008-05-27 12:05:31 +020017965static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017966 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17967 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017968 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17969 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017970 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17971 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17972 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017973 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17974 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17975 {}
17976};
17977
Kailang Yangf1d4e282008-08-26 14:03:29 +020017978static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17979 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17980 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17981 {0x21, 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 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17986 {}
17987};
17988
17989static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17990 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17991 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17992 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17993 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17994 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17995 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17996 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17997 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17998 {}
17999};
18000
18001static struct hda_verb alc663_15jd_amic_init_verbs[] = {
18002 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18003 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18004 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18005 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18006 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18007 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18008 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18009 {}
18010};
18011
18012static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
18013 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18014 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18015 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18016 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
18017 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18018 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18019 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
18020 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18021 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18022 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18023 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18024 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18025 {}
18026};
18027
18028static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
18029 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18030 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18031 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18032 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18033 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18034 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18035 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18036 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18037 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18038 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18039 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18040 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18041 {}
18042};
18043
Kailang Yang6dda9f42008-05-27 12:05:31 +020018044static struct hda_verb alc663_g71v_init_verbs[] = {
18045 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18046 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
18047 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
18048
18049 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18050 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18051 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18052
18053 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
18054 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
18055 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
18056 {}
18057};
18058
18059static struct hda_verb alc663_g50v_init_verbs[] = {
18060 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18061 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18062 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18063
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
Kailang Yangf1d4e282008-08-26 14:03:29 +020018069static struct hda_verb alc662_ecs_init_verbs[] = {
18070 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
18071 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18072 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18073 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18074 {}
18075};
18076
Kailang Yang622e84c2009-04-21 07:39:04 +020018077static struct hda_verb alc272_dell_zm1_init_verbs[] = {
18078 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18079 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18080 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18081 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18082 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18083 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18084 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18085 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18086 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18087 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18088 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18089 {}
18090};
18091
18092static struct hda_verb alc272_dell_init_verbs[] = {
18093 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18094 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18095 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18096 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18097 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18098 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18099 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18100 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18101 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18102 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18103 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18104 {}
18105};
18106
Kailang Yangebb83ee2009-12-17 12:23:00 +010018107static struct hda_verb alc663_mode7_init_verbs[] = {
18108 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18109 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18110 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18111 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18112 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18113 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18114 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
18115 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18116 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18117 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18118 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18119 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18120 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18121 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18122 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18123 {}
18124};
18125
18126static struct hda_verb alc663_mode8_init_verbs[] = {
18127 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18128 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18129 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18130 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
18131 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18132 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18133 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18134 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18135 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18136 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18137 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18138 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18139 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18140 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18141 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18142 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18143 {}
18144};
18145
Kailang Yangf1d4e282008-08-26 14:03:29 +020018146static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
18147 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
18148 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
18149 { } /* end */
18150};
18151
Kailang Yang622e84c2009-04-21 07:39:04 +020018152static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
18153 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
18154 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
18155 { } /* end */
18156};
18157
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018158static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
18159{
18160 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018161 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018162
Wu Fengguang864f92b2009-11-18 12:38:02 +080018163 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018164 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018165
Takashi Iwai47fd8302007-08-10 17:11:07 +020018166 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18167 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018168}
18169
18170static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
18171{
18172 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018173 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018174
Wu Fengguang864f92b2009-11-18 12:38:02 +080018175 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018176 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018177
Takashi Iwai47fd8302007-08-10 17:11:07 +020018178 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18179 HDA_AMP_MUTE, bits);
18180 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18181 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018182}
18183
18184static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
18185 unsigned int res)
18186{
18187 if ((res >> 26) == ALC880_HP_EVENT)
18188 alc662_lenovo_101e_all_automute(codec);
18189 if ((res >> 26) == ALC880_FRONT_EVENT)
18190 alc662_lenovo_101e_ispeaker_automute(codec);
18191}
18192
Kailang Yang291702f2007-10-16 14:28:03 +020018193/* unsolicited event for HP jack sensing */
18194static void alc662_eeepc_unsol_event(struct hda_codec *codec,
18195 unsigned int res)
18196{
Kailang Yang291702f2007-10-16 14:28:03 +020018197 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018198 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020018199 else
18200 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020018201}
18202
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018203static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020018204{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018205 struct alc_spec *spec = codec->spec;
18206
18207 alc262_hippo1_setup(codec);
18208 spec->ext_mic.pin = 0x18;
18209 spec->ext_mic.mux_idx = 0;
18210 spec->int_mic.pin = 0x19;
18211 spec->int_mic.mux_idx = 1;
18212 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020018213}
18214
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018215static void alc662_eeepc_inithook(struct hda_codec *codec)
18216{
18217 alc262_hippo_automute(codec);
18218 alc_mic_automute(codec);
18219}
18220
18221static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010018222{
Takashi Iwai42171c12009-05-08 14:11:43 +020018223 struct alc_spec *spec = codec->spec;
18224
18225 spec->autocfg.hp_pins[0] = 0x14;
18226 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010018227}
18228
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018229#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
18230
Kailang Yang6dda9f42008-05-27 12:05:31 +020018231static void alc663_m51va_speaker_automute(struct hda_codec *codec)
18232{
18233 unsigned int present;
18234 unsigned char bits;
18235
Wu Fengguang864f92b2009-11-18 12:38:02 +080018236 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018237 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018238 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018239 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018240 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018241 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018242}
18243
18244static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
18245{
18246 unsigned int present;
18247 unsigned char bits;
18248
Wu Fengguang864f92b2009-11-18 12:38:02 +080018249 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018250 bits = present ? HDA_AMP_MUTE : 0;
18251 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018252 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018253 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018254 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018255 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018256 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018257 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018258 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018259}
18260
18261static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
18262{
18263 unsigned int present;
18264 unsigned char bits;
18265
Wu Fengguang864f92b2009-11-18 12:38:02 +080018266 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018267 bits = present ? HDA_AMP_MUTE : 0;
18268 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018269 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018270 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018271 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018272 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018273 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018274 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018275 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018276}
18277
18278static void alc662_f5z_speaker_automute(struct hda_codec *codec)
18279{
18280 unsigned int present;
18281 unsigned char bits;
18282
Wu Fengguang864f92b2009-11-18 12:38:02 +080018283 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018284 bits = present ? 0 : PIN_OUT;
18285 snd_hda_codec_write(codec, 0x14, 0,
18286 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
18287}
18288
18289static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
18290{
18291 unsigned int present1, present2;
18292
Wu Fengguang864f92b2009-11-18 12:38:02 +080018293 present1 = snd_hda_jack_detect(codec, 0x21);
18294 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018295
18296 if (present1 || present2) {
18297 snd_hda_codec_write_cache(codec, 0x14, 0,
18298 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18299 } else {
18300 snd_hda_codec_write_cache(codec, 0x14, 0,
18301 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18302 }
18303}
18304
18305static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
18306{
18307 unsigned int present1, present2;
18308
Wu Fengguang864f92b2009-11-18 12:38:02 +080018309 present1 = snd_hda_jack_detect(codec, 0x1b);
18310 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018311
18312 if (present1 || present2) {
18313 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018314 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018315 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018316 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018317 } else {
18318 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018319 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018320 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018321 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018322 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020018323}
18324
Kailang Yangebb83ee2009-12-17 12:23:00 +010018325static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
18326{
18327 unsigned int present1, present2;
18328
18329 present1 = snd_hda_codec_read(codec, 0x1b, 0,
18330 AC_VERB_GET_PIN_SENSE, 0)
18331 & AC_PINSENSE_PRESENCE;
18332 present2 = snd_hda_codec_read(codec, 0x21, 0,
18333 AC_VERB_GET_PIN_SENSE, 0)
18334 & AC_PINSENSE_PRESENCE;
18335
18336 if (present1 || present2) {
18337 snd_hda_codec_write_cache(codec, 0x14, 0,
18338 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18339 snd_hda_codec_write_cache(codec, 0x17, 0,
18340 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18341 } else {
18342 snd_hda_codec_write_cache(codec, 0x14, 0,
18343 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18344 snd_hda_codec_write_cache(codec, 0x17, 0,
18345 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18346 }
18347}
18348
18349static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
18350{
18351 unsigned int present1, present2;
18352
18353 present1 = snd_hda_codec_read(codec, 0x21, 0,
18354 AC_VERB_GET_PIN_SENSE, 0)
18355 & AC_PINSENSE_PRESENCE;
18356 present2 = snd_hda_codec_read(codec, 0x15, 0,
18357 AC_VERB_GET_PIN_SENSE, 0)
18358 & AC_PINSENSE_PRESENCE;
18359
18360 if (present1 || present2) {
18361 snd_hda_codec_write_cache(codec, 0x14, 0,
18362 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18363 snd_hda_codec_write_cache(codec, 0x17, 0,
18364 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18365 } else {
18366 snd_hda_codec_write_cache(codec, 0x14, 0,
18367 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18368 snd_hda_codec_write_cache(codec, 0x17, 0,
18369 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18370 }
18371}
18372
Kailang Yang6dda9f42008-05-27 12:05:31 +020018373static void alc663_m51va_unsol_event(struct hda_codec *codec,
18374 unsigned int res)
18375{
18376 switch (res >> 26) {
18377 case ALC880_HP_EVENT:
18378 alc663_m51va_speaker_automute(codec);
18379 break;
18380 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018381 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018382 break;
18383 }
18384}
18385
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018386static void alc663_m51va_setup(struct hda_codec *codec)
18387{
18388 struct alc_spec *spec = codec->spec;
18389 spec->ext_mic.pin = 0x18;
18390 spec->ext_mic.mux_idx = 0;
18391 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018392 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018393 spec->auto_mic = 1;
18394}
18395
Kailang Yang6dda9f42008-05-27 12:05:31 +020018396static void alc663_m51va_inithook(struct hda_codec *codec)
18397{
18398 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018399 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018400}
18401
Kailang Yangf1d4e282008-08-26 14:03:29 +020018402/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018403#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010018404
18405static void alc663_mode1_setup(struct hda_codec *codec)
18406{
18407 struct alc_spec *spec = codec->spec;
18408 spec->ext_mic.pin = 0x18;
18409 spec->ext_mic.mux_idx = 0;
18410 spec->int_mic.pin = 0x19;
18411 spec->int_mic.mux_idx = 1;
18412 spec->auto_mic = 1;
18413}
18414
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018415#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020018416
Kailang Yangf1d4e282008-08-26 14:03:29 +020018417/* ***************** Mode2 ******************************/
18418static void alc662_mode2_unsol_event(struct hda_codec *codec,
18419 unsigned int res)
18420{
18421 switch (res >> 26) {
18422 case ALC880_HP_EVENT:
18423 alc662_f5z_speaker_automute(codec);
18424 break;
18425 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018426 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018427 break;
18428 }
18429}
18430
Kailang Yangebb83ee2009-12-17 12:23:00 +010018431#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018432
Kailang Yangf1d4e282008-08-26 14:03:29 +020018433static void alc662_mode2_inithook(struct hda_codec *codec)
18434{
18435 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018436 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018437}
18438/* ***************** Mode3 ******************************/
18439static void alc663_mode3_unsol_event(struct hda_codec *codec,
18440 unsigned int res)
18441{
18442 switch (res >> 26) {
18443 case ALC880_HP_EVENT:
18444 alc663_two_hp_m1_speaker_automute(codec);
18445 break;
18446 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018447 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018448 break;
18449 }
18450}
18451
Kailang Yangebb83ee2009-12-17 12:23:00 +010018452#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018453
Kailang Yangf1d4e282008-08-26 14:03:29 +020018454static void alc663_mode3_inithook(struct hda_codec *codec)
18455{
18456 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018457 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018458}
18459/* ***************** Mode4 ******************************/
18460static void alc663_mode4_unsol_event(struct hda_codec *codec,
18461 unsigned int res)
18462{
18463 switch (res >> 26) {
18464 case ALC880_HP_EVENT:
18465 alc663_21jd_two_speaker_automute(codec);
18466 break;
18467 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018468 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018469 break;
18470 }
18471}
18472
Kailang Yangebb83ee2009-12-17 12:23:00 +010018473#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018474
Kailang Yangf1d4e282008-08-26 14:03:29 +020018475static void alc663_mode4_inithook(struct hda_codec *codec)
18476{
18477 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018478 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018479}
18480/* ***************** Mode5 ******************************/
18481static void alc663_mode5_unsol_event(struct hda_codec *codec,
18482 unsigned int res)
18483{
18484 switch (res >> 26) {
18485 case ALC880_HP_EVENT:
18486 alc663_15jd_two_speaker_automute(codec);
18487 break;
18488 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018489 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018490 break;
18491 }
18492}
18493
Kailang Yangebb83ee2009-12-17 12:23:00 +010018494#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018495
Kailang Yangf1d4e282008-08-26 14:03:29 +020018496static void alc663_mode5_inithook(struct hda_codec *codec)
18497{
18498 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018499 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018500}
18501/* ***************** Mode6 ******************************/
18502static void alc663_mode6_unsol_event(struct hda_codec *codec,
18503 unsigned int res)
18504{
18505 switch (res >> 26) {
18506 case ALC880_HP_EVENT:
18507 alc663_two_hp_m2_speaker_automute(codec);
18508 break;
18509 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018510 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018511 break;
18512 }
18513}
18514
Kailang Yangebb83ee2009-12-17 12:23:00 +010018515#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018516
Kailang Yangf1d4e282008-08-26 14:03:29 +020018517static void alc663_mode6_inithook(struct hda_codec *codec)
18518{
18519 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018520 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018521}
18522
Kailang Yangebb83ee2009-12-17 12:23:00 +010018523/* ***************** Mode7 ******************************/
18524static void alc663_mode7_unsol_event(struct hda_codec *codec,
18525 unsigned int res)
18526{
18527 switch (res >> 26) {
18528 case ALC880_HP_EVENT:
18529 alc663_two_hp_m7_speaker_automute(codec);
18530 break;
18531 case ALC880_MIC_EVENT:
18532 alc_mic_automute(codec);
18533 break;
18534 }
18535}
18536
18537#define alc663_mode7_setup alc663_mode1_setup
18538
18539static void alc663_mode7_inithook(struct hda_codec *codec)
18540{
18541 alc663_two_hp_m7_speaker_automute(codec);
18542 alc_mic_automute(codec);
18543}
18544
18545/* ***************** Mode8 ******************************/
18546static void alc663_mode8_unsol_event(struct hda_codec *codec,
18547 unsigned int res)
18548{
18549 switch (res >> 26) {
18550 case ALC880_HP_EVENT:
18551 alc663_two_hp_m8_speaker_automute(codec);
18552 break;
18553 case ALC880_MIC_EVENT:
18554 alc_mic_automute(codec);
18555 break;
18556 }
18557}
18558
18559#define alc663_mode8_setup alc663_m51va_setup
18560
18561static void alc663_mode8_inithook(struct hda_codec *codec)
18562{
18563 alc663_two_hp_m8_speaker_automute(codec);
18564 alc_mic_automute(codec);
18565}
18566
Kailang Yang6dda9f42008-05-27 12:05:31 +020018567static void alc663_g71v_hp_automute(struct hda_codec *codec)
18568{
18569 unsigned int present;
18570 unsigned char bits;
18571
Wu Fengguang864f92b2009-11-18 12:38:02 +080018572 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018573 bits = present ? HDA_AMP_MUTE : 0;
18574 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18575 HDA_AMP_MUTE, bits);
18576 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18577 HDA_AMP_MUTE, bits);
18578}
18579
18580static void alc663_g71v_front_automute(struct hda_codec *codec)
18581{
18582 unsigned int present;
18583 unsigned char bits;
18584
Wu Fengguang864f92b2009-11-18 12:38:02 +080018585 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018586 bits = present ? HDA_AMP_MUTE : 0;
18587 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18588 HDA_AMP_MUTE, bits);
18589}
18590
18591static void alc663_g71v_unsol_event(struct hda_codec *codec,
18592 unsigned int res)
18593{
18594 switch (res >> 26) {
18595 case ALC880_HP_EVENT:
18596 alc663_g71v_hp_automute(codec);
18597 break;
18598 case ALC880_FRONT_EVENT:
18599 alc663_g71v_front_automute(codec);
18600 break;
18601 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018602 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018603 break;
18604 }
18605}
18606
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018607#define alc663_g71v_setup alc663_m51va_setup
18608
Kailang Yang6dda9f42008-05-27 12:05:31 +020018609static void alc663_g71v_inithook(struct hda_codec *codec)
18610{
18611 alc663_g71v_front_automute(codec);
18612 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018613 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018614}
18615
18616static void alc663_g50v_unsol_event(struct hda_codec *codec,
18617 unsigned int res)
18618{
18619 switch (res >> 26) {
18620 case ALC880_HP_EVENT:
18621 alc663_m51va_speaker_automute(codec);
18622 break;
18623 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018624 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018625 break;
18626 }
18627}
18628
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018629#define alc663_g50v_setup alc663_m51va_setup
18630
Kailang Yang6dda9f42008-05-27 12:05:31 +020018631static void alc663_g50v_inithook(struct hda_codec *codec)
18632{
18633 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018634 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018635}
18636
Kailang Yangf1d4e282008-08-26 14:03:29 +020018637static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18638 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018639 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018640
David Henningsson5f99f862011-01-04 15:24:24 +010018641 HDA_CODEC_VOLUME("Mic/LineIn Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018642 HDA_CODEC_VOLUME("Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18643 HDA_CODEC_MUTE("Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018644
David Henningsson5f99f862011-01-04 15:24:24 +010018645 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018646 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18647 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018648 { } /* end */
18649};
18650
Chris Pockelé9541ba12009-05-12 08:08:53 +020018651static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18652 /* Master Playback automatically created from Speaker and Headphone */
18653 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18654 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18655 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18656 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18657
David Henningsson8607f7c2010-12-20 14:43:54 +010018658 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18659 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018660 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018661
David Henningsson28c4edb2010-12-20 14:24:29 +010018662 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18663 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018664 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018665 { } /* end */
18666};
18667
Takashi Iwaicb53c622007-08-10 17:21:45 +020018668#ifdef CONFIG_SND_HDA_POWER_SAVE
18669#define alc662_loopbacks alc880_loopbacks
18670#endif
18671
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018672
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018673/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018674#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18675#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18676#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18677#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18678
18679/*
18680 * configuration and preset
18681 */
Takashi Iwaiea734962011-01-17 11:29:34 +010018682static const char * const alc662_models[ALC662_MODEL_LAST] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018683 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18684 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18685 [ALC662_3ST_6ch] = "3stack-6ch",
18686 [ALC662_5ST_DIG] = "6stack-dig",
18687 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018688 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018689 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018690 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018691 [ALC663_ASUS_M51VA] = "m51va",
18692 [ALC663_ASUS_G71V] = "g71v",
18693 [ALC663_ASUS_H13] = "h13",
18694 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018695 [ALC663_ASUS_MODE1] = "asus-mode1",
18696 [ALC662_ASUS_MODE2] = "asus-mode2",
18697 [ALC663_ASUS_MODE3] = "asus-mode3",
18698 [ALC663_ASUS_MODE4] = "asus-mode4",
18699 [ALC663_ASUS_MODE5] = "asus-mode5",
18700 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018701 [ALC663_ASUS_MODE7] = "asus-mode7",
18702 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018703 [ALC272_DELL] = "dell",
18704 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018705 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018706 [ALC662_AUTO] = "auto",
18707};
18708
18709static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018710 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018711 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18712 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018713 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18714 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018715 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018716 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18717 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18718 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18719 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018720 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18721 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018722 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018723 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18724 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18725 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18726 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18727 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018728 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018729 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18730 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018731 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18732 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18733 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18734 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018735 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018736 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18737 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18738 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018739 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18740 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18741 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18742 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018743 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018744 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18745 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018746 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018747 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18748 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18749 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018750 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018751 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018752 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18753 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018754 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18755 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18756 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018757 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018758 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18759 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018760 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018761 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018762 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018763 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18764 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18765 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018766 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018767 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18768 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018769 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018770 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018771 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018772 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018773 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18774 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018775 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018776 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018777 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18778 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018779 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018780 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018781 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018782 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018783 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018784 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018785 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18786 ALC663_ASUS_H13),
Anisse Astier965b76d2011-02-10 13:14:44 +010018787 SND_PCI_QUIRK(0x1991, 0x5628, "Ordissimo EVE", ALC662_LENOVO_101E),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018788 {}
18789};
18790
18791static struct alc_config_preset alc662_presets[] = {
18792 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018793 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018794 .init_verbs = { alc662_init_verbs },
18795 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18796 .dac_nids = alc662_dac_nids,
18797 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018798 .dig_in_nid = ALC662_DIGIN_NID,
18799 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18800 .channel_mode = alc662_3ST_2ch_modes,
18801 .input_mux = &alc662_capture_source,
18802 },
18803 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018804 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018805 .init_verbs = { alc662_init_verbs },
18806 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18807 .dac_nids = alc662_dac_nids,
18808 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018809 .dig_in_nid = ALC662_DIGIN_NID,
18810 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18811 .channel_mode = alc662_3ST_6ch_modes,
18812 .need_dac_fix = 1,
18813 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018814 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018815 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018816 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018817 .init_verbs = { alc662_init_verbs },
18818 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18819 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018820 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18821 .channel_mode = alc662_3ST_6ch_modes,
18822 .need_dac_fix = 1,
18823 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018824 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018825 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018826 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018827 .init_verbs = { alc662_init_verbs },
18828 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18829 .dac_nids = alc662_dac_nids,
18830 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018831 .dig_in_nid = ALC662_DIGIN_NID,
18832 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18833 .channel_mode = alc662_5stack_modes,
18834 .input_mux = &alc662_capture_source,
18835 },
18836 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018837 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018838 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18839 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18840 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018841 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18842 .channel_mode = alc662_3ST_2ch_modes,
18843 .input_mux = &alc662_lenovo_101e_capture_source,
18844 .unsol_event = alc662_lenovo_101e_unsol_event,
18845 .init_hook = alc662_lenovo_101e_all_automute,
18846 },
Kailang Yang291702f2007-10-16 14:28:03 +020018847 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018848 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018849 .init_verbs = { alc662_init_verbs,
18850 alc662_eeepc_sue_init_verbs },
18851 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18852 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018853 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18854 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018855 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018856 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018857 .init_hook = alc662_eeepc_inithook,
18858 },
Kailang Yang8c427222008-01-10 13:03:59 +010018859 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018860 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018861 alc662_chmode_mixer },
18862 .init_verbs = { alc662_init_verbs,
18863 alc662_eeepc_ep20_sue_init_verbs },
18864 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18865 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018866 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18867 .channel_mode = alc662_3ST_6ch_modes,
18868 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018869 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018870 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018871 .init_hook = alc662_eeepc_ep20_inithook,
18872 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018873 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018874 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018875 .init_verbs = { alc662_init_verbs,
18876 alc662_ecs_init_verbs },
18877 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18878 .dac_nids = alc662_dac_nids,
18879 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18880 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018881 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018882 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018883 .init_hook = alc662_eeepc_inithook,
18884 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018885 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018886 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018887 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18888 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18889 .dac_nids = alc662_dac_nids,
18890 .dig_out_nid = ALC662_DIGOUT_NID,
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,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018894 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018895 .init_hook = alc663_m51va_inithook,
18896 },
18897 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018898 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018899 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18900 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18901 .dac_nids = alc662_dac_nids,
18902 .dig_out_nid = ALC662_DIGOUT_NID,
18903 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18904 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018905 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018906 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018907 .init_hook = alc663_g71v_inithook,
18908 },
18909 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018910 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018911 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18912 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18913 .dac_nids = alc662_dac_nids,
18914 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18915 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018916 .unsol_event = alc663_m51va_unsol_event,
18917 .init_hook = alc663_m51va_inithook,
18918 },
18919 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018920 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018921 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18922 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18923 .dac_nids = alc662_dac_nids,
18924 .dig_out_nid = ALC662_DIGOUT_NID,
18925 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18926 .channel_mode = alc662_3ST_6ch_modes,
18927 .input_mux = &alc663_capture_source,
18928 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018929 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018930 .init_hook = alc663_g50v_inithook,
18931 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018932 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018933 .mixers = { alc663_m51va_mixer },
18934 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018935 .init_verbs = { alc662_init_verbs,
18936 alc663_21jd_amic_init_verbs },
18937 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18938 .hp_nid = 0x03,
18939 .dac_nids = alc662_dac_nids,
18940 .dig_out_nid = ALC662_DIGOUT_NID,
18941 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18942 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018943 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018944 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018945 .init_hook = alc663_mode1_inithook,
18946 },
18947 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018948 .mixers = { alc662_1bjd_mixer },
18949 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018950 .init_verbs = { alc662_init_verbs,
18951 alc662_1bjd_amic_init_verbs },
18952 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18953 .dac_nids = alc662_dac_nids,
18954 .dig_out_nid = ALC662_DIGOUT_NID,
18955 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18956 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018957 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018958 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018959 .init_hook = alc662_mode2_inithook,
18960 },
18961 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018962 .mixers = { alc663_two_hp_m1_mixer },
18963 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018964 .init_verbs = { alc662_init_verbs,
18965 alc663_two_hp_amic_m1_init_verbs },
18966 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18967 .hp_nid = 0x03,
18968 .dac_nids = alc662_dac_nids,
18969 .dig_out_nid = ALC662_DIGOUT_NID,
18970 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18971 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018972 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018973 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018974 .init_hook = alc663_mode3_inithook,
18975 },
18976 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018977 .mixers = { alc663_asus_21jd_clfe_mixer },
18978 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018979 .init_verbs = { alc662_init_verbs,
18980 alc663_21jd_amic_init_verbs},
18981 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18982 .hp_nid = 0x03,
18983 .dac_nids = alc662_dac_nids,
18984 .dig_out_nid = ALC662_DIGOUT_NID,
18985 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18986 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018987 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018988 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018989 .init_hook = alc663_mode4_inithook,
18990 },
18991 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018992 .mixers = { alc663_asus_15jd_clfe_mixer },
18993 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018994 .init_verbs = { alc662_init_verbs,
18995 alc663_15jd_amic_init_verbs },
18996 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18997 .hp_nid = 0x03,
18998 .dac_nids = alc662_dac_nids,
18999 .dig_out_nid = ALC662_DIGOUT_NID,
19000 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19001 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019002 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019003 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019004 .init_hook = alc663_mode5_inithook,
19005 },
19006 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019007 .mixers = { alc663_two_hp_m2_mixer },
19008 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019009 .init_verbs = { alc662_init_verbs,
19010 alc663_two_hp_amic_m2_init_verbs },
19011 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
19012 .hp_nid = 0x03,
19013 .dac_nids = alc662_dac_nids,
19014 .dig_out_nid = ALC662_DIGOUT_NID,
19015 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19016 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019017 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019018 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019019 .init_hook = alc663_mode6_inithook,
19020 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019021 [ALC663_ASUS_MODE7] = {
19022 .mixers = { alc663_mode7_mixer },
19023 .cap_mixer = alc662_auto_capture_mixer,
19024 .init_verbs = { alc662_init_verbs,
19025 alc663_mode7_init_verbs },
19026 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
19027 .hp_nid = 0x03,
19028 .dac_nids = alc662_dac_nids,
19029 .dig_out_nid = ALC662_DIGOUT_NID,
19030 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19031 .channel_mode = alc662_3ST_2ch_modes,
19032 .unsol_event = alc663_mode7_unsol_event,
19033 .setup = alc663_mode7_setup,
19034 .init_hook = alc663_mode7_inithook,
19035 },
19036 [ALC663_ASUS_MODE8] = {
19037 .mixers = { alc663_mode8_mixer },
19038 .cap_mixer = alc662_auto_capture_mixer,
19039 .init_verbs = { alc662_init_verbs,
19040 alc663_mode8_init_verbs },
19041 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
19042 .hp_nid = 0x03,
19043 .dac_nids = alc662_dac_nids,
19044 .dig_out_nid = ALC662_DIGOUT_NID,
19045 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19046 .channel_mode = alc662_3ST_2ch_modes,
19047 .unsol_event = alc663_mode8_unsol_event,
19048 .setup = alc663_mode8_setup,
19049 .init_hook = alc663_mode8_inithook,
19050 },
Kailang Yang622e84c2009-04-21 07:39:04 +020019051 [ALC272_DELL] = {
19052 .mixers = { alc663_m51va_mixer },
19053 .cap_mixer = alc272_auto_capture_mixer,
19054 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
19055 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19056 .dac_nids = alc662_dac_nids,
19057 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19058 .adc_nids = alc272_adc_nids,
19059 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
19060 .capsrc_nids = alc272_capsrc_nids,
19061 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020019062 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019063 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020019064 .init_hook = alc663_m51va_inithook,
19065 },
19066 [ALC272_DELL_ZM1] = {
19067 .mixers = { alc663_m51va_mixer },
19068 .cap_mixer = alc662_auto_capture_mixer,
19069 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
19070 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19071 .dac_nids = alc662_dac_nids,
19072 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19073 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019074 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020019075 .capsrc_nids = alc662_capsrc_nids,
19076 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020019077 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019078 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020019079 .init_hook = alc663_m51va_inithook,
19080 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020019081 [ALC272_SAMSUNG_NC10] = {
19082 .mixers = { alc272_nc10_mixer },
19083 .init_verbs = { alc662_init_verbs,
19084 alc663_21jd_amic_init_verbs },
19085 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19086 .dac_nids = alc272_dac_nids,
19087 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19088 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019089 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020019090 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019091 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020019092 .init_hook = alc663_mode4_inithook,
19093 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019094};
19095
19096
19097/*
19098 * BIOS auto configuration
19099 */
19100
Takashi Iwai7085ec12009-10-02 09:03:58 +020019101/* convert from MIX nid to DAC */
19102static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
19103{
19104 if (nid == 0x0f)
19105 return 0x02;
19106 else if (nid >= 0x0c && nid <= 0x0e)
19107 return nid - 0x0c + 0x02;
David Henningssoncc1c4522010-11-24 14:17:47 +010019108 else if (nid == 0x26) /* ALC887-VD has this DAC too */
19109 return 0x25;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019110 else
19111 return 0;
19112}
19113
19114/* get MIX nid connected to the given pin targeted to DAC */
19115static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
19116 hda_nid_t dac)
19117{
David Henningssoncc1c4522010-11-24 14:17:47 +010019118 hda_nid_t mix[5];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019119 int i, num;
19120
19121 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
19122 for (i = 0; i < num; i++) {
19123 if (alc662_mix_to_dac(mix[i]) == dac)
19124 return mix[i];
19125 }
19126 return 0;
19127}
19128
19129/* look for an empty DAC slot */
19130static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
19131{
19132 struct alc_spec *spec = codec->spec;
19133 hda_nid_t srcs[5];
19134 int i, j, num;
19135
19136 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
19137 if (num < 0)
19138 return 0;
19139 for (i = 0; i < num; i++) {
19140 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
19141 if (!nid)
19142 continue;
19143 for (j = 0; j < spec->multiout.num_dacs; j++)
19144 if (spec->multiout.dac_nids[j] == nid)
19145 break;
19146 if (j >= spec->multiout.num_dacs)
19147 return nid;
19148 }
19149 return 0;
19150}
19151
19152/* fill in the dac_nids table from the parsed pin configuration */
19153static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
19154 const struct auto_pin_cfg *cfg)
19155{
19156 struct alc_spec *spec = codec->spec;
19157 int i;
19158 hda_nid_t dac;
19159
19160 spec->multiout.dac_nids = spec->private_dac_nids;
19161 for (i = 0; i < cfg->line_outs; i++) {
19162 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
19163 if (!dac)
19164 continue;
19165 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19166 }
19167 return 0;
19168}
19169
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019170static inline int __alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
19171 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019172{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019173 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019174 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
19175}
19176
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019177static inline int __alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
19178 hda_nid_t nid, int idx, unsigned int chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019179{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019180 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019181 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
19182}
19183
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019184#define alc662_add_vol_ctl(spec, pfx, nid, chs) \
19185 __alc662_add_vol_ctl(spec, pfx, nid, 0, chs)
19186#define alc662_add_sw_ctl(spec, pfx, nid, chs) \
19187 __alc662_add_sw_ctl(spec, pfx, nid, 0, chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019188#define alc662_add_stereo_vol(spec, pfx, nid) \
19189 alc662_add_vol_ctl(spec, pfx, nid, 3)
19190#define alc662_add_stereo_sw(spec, pfx, nid) \
19191 alc662_add_sw_ctl(spec, pfx, nid, 3)
19192
19193/* add playback controls from the parsed DAC table */
19194static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
19195 const struct auto_pin_cfg *cfg)
19196{
19197 struct alc_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +010019198 static const char * const chname[4] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019199 "Front", "Surround", NULL /*CLFE*/, "Side"
19200 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019201 const char *pfx = alc_get_line_out_pfx(cfg, true);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019202 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019203 int i, err;
19204
19205 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019206 nid = spec->multiout.dac_nids[i];
19207 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019208 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019209 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
19210 if (!mix)
19211 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019212 if (!pfx && i == 2) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019213 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019214 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019215 if (err < 0)
19216 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019217 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019218 if (err < 0)
19219 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019220 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019221 if (err < 0)
19222 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019223 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019224 if (err < 0)
19225 return err;
19226 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019227 const char *name = pfx;
David Henningsson5a882642011-03-23 08:35:07 +010019228 int index = i;
19229 if (!name) {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019230 name = chname[i];
David Henningsson5a882642011-03-23 08:35:07 +010019231 index = 0;
19232 }
19233 err = __alc662_add_vol_ctl(spec, name, nid, index, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019234 if (err < 0)
19235 return err;
David Henningsson5a882642011-03-23 08:35:07 +010019236 err = __alc662_add_sw_ctl(spec, name, mix, index, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019237 if (err < 0)
19238 return err;
19239 }
19240 }
19241 return 0;
19242}
19243
19244/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019245/* return DAC nid if any new DAC is assigned */
19246static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019247 const char *pfx)
19248{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019249 struct alc_spec *spec = codec->spec;
19250 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019251 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019252
19253 if (!pin)
19254 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019255 nid = alc662_look_for_dac(codec, pin);
19256 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019257 /* the corresponding DAC is already occupied */
19258 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
19259 return 0; /* no way */
19260 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019261 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019262 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19263 }
19264
19265 mix = alc662_dac_to_mix(codec, pin, nid);
19266 if (!mix)
19267 return 0;
19268 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
19269 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020019270 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019271 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
19272 if (err < 0)
19273 return err;
19274 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019275}
19276
19277/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020019278#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020019279 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019280
19281static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
19282 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019283 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019284{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019285 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020019286 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019287
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019288 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019289 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019290 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
19291 if (num <= 1)
19292 return;
19293 for (i = 0; i < num; i++) {
19294 if (alc662_mix_to_dac(srcs[i]) != dac)
19295 continue;
19296 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
19297 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019298 }
19299}
19300
19301static void alc662_auto_init_multi_out(struct hda_codec *codec)
19302{
19303 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019304 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019305 int i;
19306
19307 for (i = 0; i <= HDA_SIDE; i++) {
19308 hda_nid_t nid = spec->autocfg.line_out_pins[i];
19309 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020019310 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019311 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019312 }
19313}
19314
19315static void alc662_auto_init_hp_out(struct hda_codec *codec)
19316{
19317 struct alc_spec *spec = codec->spec;
19318 hda_nid_t pin;
19319
19320 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019321 if (pin)
19322 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
19323 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019324 pin = spec->autocfg.speaker_pins[0];
19325 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019326 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
19327 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019328}
19329
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019330#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
19331
19332static void alc662_auto_init_analog_input(struct hda_codec *codec)
19333{
19334 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019335 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019336 int i;
19337
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019338 for (i = 0; i < cfg->num_inputs; i++) {
19339 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019340 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020019341 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010019342 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010019343 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019344 snd_hda_codec_write(codec, nid, 0,
19345 AC_VERB_SET_AMP_GAIN_MUTE,
19346 AMP_OUT_MUTE);
19347 }
19348 }
19349}
19350
Takashi Iwaif511b012008-08-15 16:46:42 +020019351#define alc662_auto_init_input_src alc882_auto_init_input_src
19352
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019353static int alc662_parse_auto_config(struct hda_codec *codec)
19354{
19355 struct alc_spec *spec = codec->spec;
19356 int err;
19357 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
19358
19359 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19360 alc662_ignore);
19361 if (err < 0)
19362 return err;
19363 if (!spec->autocfg.line_outs)
19364 return 0; /* can't find valid BIOS pin config */
19365
Takashi Iwai7085ec12009-10-02 09:03:58 +020019366 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019367 if (err < 0)
19368 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019369 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019370 if (err < 0)
19371 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019372 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019373 spec->autocfg.speaker_pins[0],
19374 "Speaker");
19375 if (err < 0)
19376 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019377 if (err)
19378 spec->multiout.extra_out_nid[0] = err;
19379 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019380 "Headphone");
19381 if (err < 0)
19382 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019383 if (err)
19384 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019385 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019386 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019387 return err;
19388
19389 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
19390
Takashi Iwai757899a2010-07-30 10:48:14 +020019391 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019392
Takashi Iwai603c4012008-07-30 15:01:44 +020019393 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010019394 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019395
19396 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020019397 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020019398
Kailang Yangcec27c82010-02-04 14:18:18 +010019399 add_verb(spec, alc662_init_verbs);
19400 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019401 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Kailang Yangcec27c82010-02-04 14:18:18 +010019402 add_verb(spec, alc663_init_verbs);
19403
19404 if (codec->vendor_id == 0x10ec0272)
19405 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020019406
19407 err = alc_auto_add_mic_boost(codec);
19408 if (err < 0)
19409 return err;
19410
Kailang Yang6227cdc2010-02-25 08:36:52 +010019411 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
19412 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
19413 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
19414 else
19415 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020019416
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019417 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019418}
19419
19420/* additional initialization for auto-configuration model */
19421static void alc662_auto_init(struct hda_codec *codec)
19422{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019423 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019424 alc662_auto_init_multi_out(codec);
19425 alc662_auto_init_hp_out(codec);
19426 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020019427 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019428 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019429 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020019430 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019431}
19432
Todd Broch6be79482010-12-07 16:51:05 -080019433static void alc272_fixup_mario(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019434 const struct alc_fixup *fix, int action)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010019435{
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019436 if (action != ALC_FIXUP_ACT_PROBE)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010019437 return;
Todd Broch6be79482010-12-07 16:51:05 -080019438 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
19439 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
19440 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
19441 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
19442 (0 << AC_AMPCAP_MUTE_SHIFT)))
19443 printk(KERN_WARNING
19444 "hda_codec: failed to override amp caps for NID 0x2\n");
19445}
19446
David Henningsson6cb3b702010-09-09 08:51:44 +020019447enum {
Daniel T Chen2df03512010-10-10 22:39:28 -040019448 ALC662_FIXUP_ASPIRE,
David Henningsson6cb3b702010-09-09 08:51:44 +020019449 ALC662_FIXUP_IDEAPAD,
Todd Broch6be79482010-12-07 16:51:05 -080019450 ALC272_FIXUP_MARIO,
Anisse Astierd2ebd472011-01-20 12:36:21 +010019451 ALC662_FIXUP_CZC_P10T,
David Henningsson6cb3b702010-09-09 08:51:44 +020019452};
19453
19454static const struct alc_fixup alc662_fixups[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019455 [ALC662_FIXUP_ASPIRE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019456 .type = ALC_FIXUP_PINS,
19457 .v.pins = (const struct alc_pincfg[]) {
Daniel T Chen2df03512010-10-10 22:39:28 -040019458 { 0x15, 0x99130112 }, /* subwoofer */
19459 { }
19460 }
19461 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019462 [ALC662_FIXUP_IDEAPAD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019463 .type = ALC_FIXUP_PINS,
19464 .v.pins = (const struct alc_pincfg[]) {
David Henningsson6cb3b702010-09-09 08:51:44 +020019465 { 0x17, 0x99130112 }, /* subwoofer */
19466 { }
19467 }
19468 },
Todd Broch6be79482010-12-07 16:51:05 -080019469 [ALC272_FIXUP_MARIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019470 .type = ALC_FIXUP_FUNC,
19471 .v.func = alc272_fixup_mario,
Anisse Astierd2ebd472011-01-20 12:36:21 +010019472 },
19473 [ALC662_FIXUP_CZC_P10T] = {
19474 .type = ALC_FIXUP_VERBS,
19475 .v.verbs = (const struct hda_verb[]) {
19476 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
19477 {}
19478 }
19479 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019480};
19481
19482static struct snd_pci_quirk alc662_fixup_tbl[] = {
David Henningssona6c47a82011-02-10 15:39:19 +010019483 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
Daniel T Chen2df03512010-10-10 22:39:28 -040019484 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
Daniel T Chena0e90ac2010-11-20 10:20:35 -050019485 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
Valentine Sinitsynd4118582010-10-01 22:24:08 +060019486 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
David Henningsson6cb3b702010-09-09 08:51:44 +020019487 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
Anisse Astierd2ebd472011-01-20 12:36:21 +010019488 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
David Henningsson6cb3b702010-09-09 08:51:44 +020019489 {}
19490};
19491
Todd Broch6be79482010-12-07 16:51:05 -080019492static const struct alc_model_fixup alc662_fixup_models[] = {
19493 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
19494 {}
19495};
David Henningsson6cb3b702010-09-09 08:51:44 +020019496
19497
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019498static int patch_alc662(struct hda_codec *codec)
19499{
19500 struct alc_spec *spec;
19501 int err, board_config;
Kailang Yang693194f2010-10-21 08:51:48 +020019502 int coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019503
19504 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19505 if (!spec)
19506 return -ENOMEM;
19507
19508 codec->spec = spec;
19509
Kailang Yangda00c242010-03-19 11:23:45 +010019510 alc_auto_parse_customize_define(codec);
19511
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020019512 alc_fix_pll_init(codec, 0x20, 0x04, 15);
19513
Kailang Yang693194f2010-10-21 08:51:48 +020019514 coef = alc_read_coef_idx(codec, 0);
19515 if (coef == 0x8020 || coef == 0x8011)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019516 alc_codec_rename(codec, "ALC661");
Kailang Yang693194f2010-10-21 08:51:48 +020019517 else if (coef & (1 << 14) &&
19518 codec->bus->pci->subsystem_vendor == 0x1025 &&
19519 spec->cdefine.platform_type == 1)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019520 alc_codec_rename(codec, "ALC272X");
Kailang Yang693194f2010-10-21 08:51:48 +020019521 else if (coef == 0x4011)
19522 alc_codec_rename(codec, "ALC656");
Kailang Yang274693f2009-12-03 10:07:50 +010019523
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019524 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19525 alc662_models,
19526 alc662_cfg_tbl);
19527 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019528 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19529 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019530 board_config = ALC662_AUTO;
19531 }
19532
19533 if (board_config == ALC662_AUTO) {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019534 alc_pick_fixup(codec, alc662_fixup_models,
19535 alc662_fixup_tbl, alc662_fixups);
19536 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019537 /* automatic parse from the BIOS config */
19538 err = alc662_parse_auto_config(codec);
19539 if (err < 0) {
19540 alc_free(codec);
19541 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019542 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019543 printk(KERN_INFO
19544 "hda_codec: Cannot set up configuration "
19545 "from BIOS. Using base mode...\n");
19546 board_config = ALC662_3ST_2ch_DIG;
19547 }
19548 }
19549
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019550 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019551 err = snd_hda_attach_beep_device(codec, 0x1);
19552 if (err < 0) {
19553 alc_free(codec);
19554 return err;
19555 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019556 }
19557
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019558 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019559 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019560
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019561 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19562 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19563
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019564 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19565 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19566
Takashi Iwaidd704692009-08-11 08:45:11 +020019567 if (!spec->adc_nids) {
19568 spec->adc_nids = alc662_adc_nids;
19569 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19570 }
19571 if (!spec->capsrc_nids)
19572 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019573
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019574 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019575 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019576
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019577 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019578 switch (codec->vendor_id) {
19579 case 0x10ec0662:
19580 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19581 break;
19582 case 0x10ec0272:
19583 case 0x10ec0663:
19584 case 0x10ec0665:
19585 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19586 break;
19587 case 0x10ec0273:
19588 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19589 break;
19590 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019591 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019592 spec->vmaster_nid = 0x02;
19593
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019594 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
19595
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019596 codec->patch_ops = alc_patch_ops;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019597 if (board_config == ALC662_AUTO)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019598 spec->init_hook = alc662_auto_init;
David Henningsson6cb3b702010-09-09 08:51:44 +020019599
Kailang Yangbf1b0222010-10-21 08:49:56 +020019600 alc_init_jacks(codec);
19601
Takashi Iwaicb53c622007-08-10 17:21:45 +020019602#ifdef CONFIG_SND_HDA_POWER_SAVE
19603 if (!spec->loopback.amplist)
19604 spec->loopback.amplist = alc662_loopbacks;
19605#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019606
19607 return 0;
19608}
19609
Kailang Yang274693f2009-12-03 10:07:50 +010019610static int patch_alc888(struct hda_codec *codec)
19611{
19612 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19613 kfree(codec->chip_name);
Kailang Yang01e0f132010-11-22 10:59:36 +010019614 if (codec->vendor_id == 0x10ec0887)
19615 codec->chip_name = kstrdup("ALC887-VD", GFP_KERNEL);
19616 else
19617 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019618 if (!codec->chip_name) {
19619 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019620 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019621 }
19622 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019623 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019624 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019625}
19626
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019627/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019628 * ALC680 support
19629 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019630#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019631#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19632#define alc680_modes alc260_modes
19633
19634static hda_nid_t alc680_dac_nids[3] = {
19635 /* Lout1, Lout2, hp */
19636 0x02, 0x03, 0x04
19637};
19638
19639static hda_nid_t alc680_adc_nids[3] = {
19640 /* ADC0-2 */
19641 /* DMIC, MIC, Line-in*/
19642 0x07, 0x08, 0x09
19643};
19644
Kailang Yangc69aefa2010-08-17 10:39:22 +020019645/*
19646 * Analog capture ADC cgange
19647 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019648static void alc680_rec_autoswitch(struct hda_codec *codec)
19649{
19650 struct alc_spec *spec = codec->spec;
19651 struct auto_pin_cfg *cfg = &spec->autocfg;
19652 int pin_found = 0;
19653 int type_found = AUTO_PIN_LAST;
19654 hda_nid_t nid;
19655 int i;
19656
19657 for (i = 0; i < cfg->num_inputs; i++) {
19658 nid = cfg->inputs[i].pin;
19659 if (!(snd_hda_query_pin_caps(codec, nid) &
19660 AC_PINCAP_PRES_DETECT))
19661 continue;
19662 if (snd_hda_jack_detect(codec, nid)) {
19663 if (cfg->inputs[i].type < type_found) {
19664 type_found = cfg->inputs[i].type;
19665 pin_found = nid;
19666 }
19667 }
19668 }
19669
19670 nid = 0x07;
19671 if (pin_found)
19672 snd_hda_get_connections(codec, pin_found, &nid, 1);
19673
19674 if (nid != spec->cur_adc)
19675 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19676 spec->cur_adc = nid;
19677 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19678 spec->cur_adc_format);
19679}
19680
Kailang Yangc69aefa2010-08-17 10:39:22 +020019681static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19682 struct hda_codec *codec,
19683 unsigned int stream_tag,
19684 unsigned int format,
19685 struct snd_pcm_substream *substream)
19686{
19687 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019688
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019689 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019690 spec->cur_adc_stream_tag = stream_tag;
19691 spec->cur_adc_format = format;
19692
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019693 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019694 return 0;
19695}
19696
19697static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19698 struct hda_codec *codec,
19699 struct snd_pcm_substream *substream)
19700{
19701 snd_hda_codec_cleanup_stream(codec, 0x07);
19702 snd_hda_codec_cleanup_stream(codec, 0x08);
19703 snd_hda_codec_cleanup_stream(codec, 0x09);
19704 return 0;
19705}
19706
19707static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19708 .substreams = 1, /* can be overridden */
19709 .channels_min = 2,
19710 .channels_max = 2,
19711 /* NID is set in alc_build_pcms */
19712 .ops = {
19713 .prepare = alc680_capture_pcm_prepare,
19714 .cleanup = alc680_capture_pcm_cleanup
19715 },
19716};
19717
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019718static struct snd_kcontrol_new alc680_base_mixer[] = {
19719 /* output mixer control */
19720 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19721 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19722 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19723 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010019724 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x12, 0, HDA_INPUT),
19725 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
19726 HDA_CODEC_VOLUME("Line In Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019727 { }
19728};
19729
Kailang Yangc69aefa2010-08-17 10:39:22 +020019730static struct hda_bind_ctls alc680_bind_cap_vol = {
19731 .ops = &snd_hda_bind_vol,
19732 .values = {
19733 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19734 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19735 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19736 0
19737 },
19738};
19739
19740static struct hda_bind_ctls alc680_bind_cap_switch = {
19741 .ops = &snd_hda_bind_sw,
19742 .values = {
19743 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19744 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19745 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19746 0
19747 },
19748};
19749
19750static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19751 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19752 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019753 { } /* end */
19754};
19755
19756/*
19757 * generic initialization of ADC, input mixers and output mixers
19758 */
19759static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019760 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19761 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19762 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019763
Kailang Yangc69aefa2010-08-17 10:39:22 +020019764 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19765 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19766 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19767 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19768 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19769 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019770
19771 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19772 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19773 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19774 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19775 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019776
19777 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19778 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019779 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019780
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019781 { }
19782};
19783
Kailang Yangc69aefa2010-08-17 10:39:22 +020019784/* toggle speaker-output according to the hp-jack state */
19785static void alc680_base_setup(struct hda_codec *codec)
19786{
19787 struct alc_spec *spec = codec->spec;
19788
19789 spec->autocfg.hp_pins[0] = 0x16;
19790 spec->autocfg.speaker_pins[0] = 0x14;
19791 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019792 spec->autocfg.num_inputs = 2;
19793 spec->autocfg.inputs[0].pin = 0x18;
19794 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19795 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019796 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019797}
19798
19799static void alc680_unsol_event(struct hda_codec *codec,
19800 unsigned int res)
19801{
19802 if ((res >> 26) == ALC880_HP_EVENT)
19803 alc_automute_amp(codec);
19804 if ((res >> 26) == ALC880_MIC_EVENT)
19805 alc680_rec_autoswitch(codec);
19806}
19807
19808static void alc680_inithook(struct hda_codec *codec)
19809{
19810 alc_automute_amp(codec);
19811 alc680_rec_autoswitch(codec);
19812}
19813
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019814/* create input playback/capture controls for the given pin */
19815static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19816 const char *ctlname, int idx)
19817{
19818 hda_nid_t dac;
19819 int err;
19820
19821 switch (nid) {
19822 case 0x14:
19823 dac = 0x02;
19824 break;
19825 case 0x15:
19826 dac = 0x03;
19827 break;
19828 case 0x16:
19829 dac = 0x04;
19830 break;
19831 default:
19832 return 0;
19833 }
19834 if (spec->multiout.dac_nids[0] != dac &&
19835 spec->multiout.dac_nids[1] != dac) {
19836 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19837 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19838 HDA_OUTPUT));
19839 if (err < 0)
19840 return err;
19841
19842 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19843 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19844
19845 if (err < 0)
19846 return err;
19847 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19848 }
19849
19850 return 0;
19851}
19852
19853/* add playback controls from the parsed DAC table */
19854static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19855 const struct auto_pin_cfg *cfg)
19856{
19857 hda_nid_t nid;
19858 int err;
19859
19860 spec->multiout.dac_nids = spec->private_dac_nids;
19861
19862 nid = cfg->line_out_pins[0];
19863 if (nid) {
19864 const char *name;
19865 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19866 name = "Speaker";
19867 else
19868 name = "Front";
19869 err = alc680_new_analog_output(spec, nid, name, 0);
19870 if (err < 0)
19871 return err;
19872 }
19873
19874 nid = cfg->speaker_pins[0];
19875 if (nid) {
19876 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19877 if (err < 0)
19878 return err;
19879 }
19880 nid = cfg->hp_pins[0];
19881 if (nid) {
19882 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19883 if (err < 0)
19884 return err;
19885 }
19886
19887 return 0;
19888}
19889
19890static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19891 hda_nid_t nid, int pin_type)
19892{
19893 alc_set_pin_output(codec, nid, pin_type);
19894}
19895
19896static void alc680_auto_init_multi_out(struct hda_codec *codec)
19897{
19898 struct alc_spec *spec = codec->spec;
19899 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19900 if (nid) {
19901 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19902 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19903 }
19904}
19905
19906static void alc680_auto_init_hp_out(struct hda_codec *codec)
19907{
19908 struct alc_spec *spec = codec->spec;
19909 hda_nid_t pin;
19910
19911 pin = spec->autocfg.hp_pins[0];
19912 if (pin)
19913 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19914 pin = spec->autocfg.speaker_pins[0];
19915 if (pin)
19916 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19917}
19918
19919/* pcm configuration: identical with ALC880 */
19920#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19921#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19922#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19923#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019924#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019925
19926/*
19927 * BIOS auto configuration
19928 */
19929static int alc680_parse_auto_config(struct hda_codec *codec)
19930{
19931 struct alc_spec *spec = codec->spec;
19932 int err;
19933 static hda_nid_t alc680_ignore[] = { 0 };
19934
19935 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19936 alc680_ignore);
19937 if (err < 0)
19938 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019939
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019940 if (!spec->autocfg.line_outs) {
19941 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19942 spec->multiout.max_channels = 2;
19943 spec->no_analog = 1;
19944 goto dig_only;
19945 }
19946 return 0; /* can't find valid BIOS pin config */
19947 }
19948 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19949 if (err < 0)
19950 return err;
19951
19952 spec->multiout.max_channels = 2;
19953
19954 dig_only:
19955 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019956 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019957 if (spec->kctls.list)
19958 add_mixer(spec, spec->kctls.list);
19959
19960 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019961
19962 err = alc_auto_add_mic_boost(codec);
19963 if (err < 0)
19964 return err;
19965
19966 return 1;
19967}
19968
19969#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19970
19971/* init callback for auto-configuration model -- overriding the default init */
19972static void alc680_auto_init(struct hda_codec *codec)
19973{
19974 struct alc_spec *spec = codec->spec;
19975 alc680_auto_init_multi_out(codec);
19976 alc680_auto_init_hp_out(codec);
19977 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019978 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019979 if (spec->unsol_event)
19980 alc_inithook(codec);
19981}
19982
19983/*
19984 * configuration and preset
19985 */
Takashi Iwaiea734962011-01-17 11:29:34 +010019986static const char * const alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019987 [ALC680_BASE] = "base",
19988 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019989};
19990
19991static struct snd_pci_quirk alc680_cfg_tbl[] = {
19992 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19993 {}
19994};
19995
19996static struct alc_config_preset alc680_presets[] = {
19997 [ALC680_BASE] = {
19998 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019999 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020000 .init_verbs = { alc680_init_verbs },
20001 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
20002 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020003 .dig_out_nid = ALC680_DIGOUT_NID,
20004 .num_channel_mode = ARRAY_SIZE(alc680_modes),
20005 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020020006 .unsol_event = alc680_unsol_event,
20007 .setup = alc680_base_setup,
20008 .init_hook = alc680_inithook,
20009
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020010 },
20011};
20012
20013static int patch_alc680(struct hda_codec *codec)
20014{
20015 struct alc_spec *spec;
20016 int board_config;
20017 int err;
20018
20019 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
20020 if (spec == NULL)
20021 return -ENOMEM;
20022
20023 codec->spec = spec;
20024
20025 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
20026 alc680_models,
20027 alc680_cfg_tbl);
20028
20029 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
20030 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
20031 codec->chip_name);
20032 board_config = ALC680_AUTO;
20033 }
20034
20035 if (board_config == ALC680_AUTO) {
20036 /* automatic parse from the BIOS config */
20037 err = alc680_parse_auto_config(codec);
20038 if (err < 0) {
20039 alc_free(codec);
20040 return err;
20041 } else if (!err) {
20042 printk(KERN_INFO
20043 "hda_codec: Cannot set up configuration "
20044 "from BIOS. Using base mode...\n");
20045 board_config = ALC680_BASE;
20046 }
20047 }
20048
20049 if (board_config != ALC680_AUTO)
20050 setup_preset(codec, &alc680_presets[board_config]);
20051
20052 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020020053 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020054 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020020055 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020056
20057 if (!spec->adc_nids) {
20058 spec->adc_nids = alc680_adc_nids;
20059 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
20060 }
20061
20062 if (!spec->cap_mixer)
20063 set_capture_mixer(codec);
20064
20065 spec->vmaster_nid = 0x02;
20066
20067 codec->patch_ops = alc_patch_ops;
20068 if (board_config == ALC680_AUTO)
20069 spec->init_hook = alc680_auto_init;
20070
20071 return 0;
20072}
20073
20074/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070020075 * patch entries
20076 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010020077static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070020078 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020079 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020080 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020020081 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020082 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020083 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020020084 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020085 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020086 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020087 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020088 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
20089 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
20090 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020091 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020092 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020093 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
20094 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020020095 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010020096 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010020097 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020098 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020099 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020100 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020101 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020020102 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020103 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020020104 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020105 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020106 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yang01e0f132010-11-22 10:59:36 +010020107 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc888 },
Kailang Yang44426082008-10-15 11:18:05 +020020108 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020109 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020110 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020111 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020112 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020113 {} /* terminator */
20114};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010020115
20116MODULE_ALIAS("snd-hda-codec-id:10ec*");
20117
20118MODULE_LICENSE("GPL");
20119MODULE_DESCRIPTION("Realtek HD-audio codec");
20120
20121static struct hda_codec_preset_list realtek_list = {
20122 .preset = snd_hda_preset_realtek,
20123 .owner = THIS_MODULE,
20124};
20125
20126static int __init patch_realtek_init(void)
20127{
20128 return snd_hda_add_codec_preset(&realtek_list);
20129}
20130
20131static void __exit patch_realtek_exit(void)
20132{
20133 snd_hda_delete_codec_preset(&realtek_list);
20134}
20135
20136module_init(patch_realtek_init)
20137module_exit(patch_realtek_exit)