blob: f44d0e355835a96e8bc6521c1d1389f19025b5bf [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
Kailang Yang9ad0e492010-09-14 23:22:00 +020031#include <sound/jack.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include "hda_codec.h"
33#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090034#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
Kailang Yangccc656c2006-10-17 12:32:26 +020036#define ALC880_FRONT_EVENT 0x01
37#define ALC880_DCVOL_EVENT 0x02
38#define ALC880_HP_EVENT 0x04
39#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
41/* ALC880 board config type */
42enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 ALC880_3ST,
44 ALC880_3ST_DIG,
45 ALC880_5ST,
46 ALC880_5ST_DIG,
47 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020048 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020049 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020050 ALC880_6ST_DIG,
51 ALC880_F1734,
52 ALC880_ASUS,
53 ALC880_ASUS_DIG,
54 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010055 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010056 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020057 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020058 ALC880_UNIWILL,
59 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010060 ALC880_CLEVO,
61 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010062 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010063 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020064 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020065#ifdef CONFIG_SND_DEBUG
66 ALC880_TEST,
67#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010068 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020069 ALC880_MODEL_LAST /* last tag */
70};
71
72/* ALC260 models */
73enum {
74 ALC260_BASIC,
75 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020076 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010077 ALC260_HP_3013,
78 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010079 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020080 ALC260_WILL,
81 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010082 ALC260_FAVORIT100,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010083#ifdef CONFIG_SND_DEBUG
84 ALC260_TEST,
85#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010086 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020087 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070088};
89
Kailang Yangdf694da2005-12-05 19:42:22 +010090/* ALC262 models */
91enum {
92 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020093 ALC262_HIPPO,
94 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010095 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020096 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010097 ALC262_HP_BPC_D7000_WL,
98 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010099 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +0100100 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200101 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200102 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200103 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200104 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100105 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200106 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200107 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200108 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000109 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100110 ALC262_AUTO,
111 ALC262_MODEL_LAST /* last tag */
112};
113
Kailang Yanga361d842007-06-05 12:30:55 +0200114/* ALC268 models */
115enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200116 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200117 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200118 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200119 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100120 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200121 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100122 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100123 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100124#ifdef CONFIG_SND_DEBUG
125 ALC268_TEST,
126#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200127 ALC268_AUTO,
128 ALC268_MODEL_LAST /* last tag */
129};
130
Kailang Yangf6a92242007-12-13 16:52:54 +0100131/* ALC269 models */
132enum {
133 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200134 ALC269_QUANTA_FL1,
Kailang Yang84898e82010-02-04 14:16:14 +0100135 ALC269_AMIC,
136 ALC269_DMIC,
137 ALC269VB_AMIC,
138 ALC269VB_DMIC,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100139 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000140 ALC269_LIFEBOOK,
Kailang Yangfe3eb0a2010-08-06 10:02:57 +0200141 ALC271_ACER,
Kailang Yangf6a92242007-12-13 16:52:54 +0100142 ALC269_AUTO,
143 ALC269_MODEL_LAST /* last tag */
144};
145
Kailang Yangdf694da2005-12-05 19:42:22 +0100146/* ALC861 models */
147enum {
148 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200149 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100150 ALC861_3ST_DIG,
151 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200152 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200153 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200154 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100155 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100156 ALC861_AUTO,
157 ALC861_MODEL_LAST,
158};
159
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100160/* ALC861-VD models */
161enum {
162 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200163 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100164 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100165 ALC861VD_3ST,
166 ALC861VD_3ST_DIG,
167 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200168 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200169 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200170 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100171 ALC861VD_AUTO,
172 ALC861VD_MODEL_LAST,
173};
174
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200175/* ALC662 models */
176enum {
177 ALC662_3ST_2ch_DIG,
178 ALC662_3ST_6ch_DIG,
179 ALC662_3ST_6ch,
180 ALC662_5ST_DIG,
181 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200182 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100183 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200184 ALC663_ASUS_M51VA,
185 ALC663_ASUS_G71V,
186 ALC663_ASUS_H13,
187 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200188 ALC662_ECS,
189 ALC663_ASUS_MODE1,
190 ALC662_ASUS_MODE2,
191 ALC663_ASUS_MODE3,
192 ALC663_ASUS_MODE4,
193 ALC663_ASUS_MODE5,
194 ALC663_ASUS_MODE6,
Kailang Yangebb83ee2009-12-17 12:23:00 +0100195 ALC663_ASUS_MODE7,
196 ALC663_ASUS_MODE8,
Kailang Yang622e84c2009-04-21 07:39:04 +0200197 ALC272_DELL,
198 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200199 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200200 ALC662_AUTO,
201 ALC662_MODEL_LAST,
202};
203
Kailang Yangdf694da2005-12-05 19:42:22 +0100204/* ALC882 models */
205enum {
206 ALC882_3ST_DIG,
207 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200208 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200209 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200210 ALC882_TARGA,
211 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200212 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100213 ALC885_MACPRO,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -0800214 ALC885_MBA21,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200215 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200216 ALC885_MB5,
Luke Yelaviche458b1f2010-02-12 16:28:29 +1100217 ALC885_MACMINI3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200218 ALC885_IMAC24,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -0800219 ALC885_IMAC91,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200220 ALC883_3ST_2ch_DIG,
221 ALC883_3ST_6ch_DIG,
222 ALC883_3ST_6ch,
223 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200224 ALC883_TARGA_DIG,
225 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200226 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200227 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200228 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800229 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100230 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200231 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200232 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200233 ALC883_MEDION,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +0200234 ALC883_MEDION_WIM2160,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100235 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200236 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200237 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200238 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200239 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200240 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200241 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100242 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100243 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430244 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100245 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100246 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800247 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200248 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200249 ALC889A_INTEL,
250 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200251 ALC888_ASUS_M90V,
252 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200253 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100254 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200255 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200256 ALC882_AUTO,
257 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200258};
259
Takashi Iwaid4a86d82010-06-23 17:51:26 +0200260/* ALC680 models */
261enum {
262 ALC680_BASE,
263 ALC680_AUTO,
264 ALC680_MODEL_LAST,
265};
266
Kailang Yangdf694da2005-12-05 19:42:22 +0100267/* for GPIO Poll */
268#define GPIO_MASK 0x03
269
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200270/* extra amp-initialization sequence types */
271enum {
272 ALC_INIT_NONE,
273 ALC_INIT_DEFAULT,
274 ALC_INIT_GPIO1,
275 ALC_INIT_GPIO2,
276 ALC_INIT_GPIO3,
277};
278
Takashi Iwai6c819492009-08-10 18:47:44 +0200279struct alc_mic_route {
280 hda_nid_t pin;
281 unsigned char mux_idx;
282 unsigned char amix_idx;
283};
284
Kailang Yang9ad0e492010-09-14 23:22:00 +0200285struct alc_jack {
286 hda_nid_t nid;
287 int type;
288 struct snd_jack *jack;
289};
290
Takashi Iwai6c819492009-08-10 18:47:44 +0200291#define MUX_IDX_UNDEF ((unsigned char)-1)
292
Kailang Yangda00c242010-03-19 11:23:45 +0100293struct alc_customize_define {
294 unsigned int sku_cfg;
295 unsigned char port_connectivity;
296 unsigned char check_sum;
297 unsigned char customization;
298 unsigned char external_amp;
299 unsigned int enable_pcbeep:1;
300 unsigned int platform_type:1;
301 unsigned int swap:1;
302 unsigned int override:1;
David Henningsson90622912010-10-14 14:50:18 +0200303 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
Kailang Yangda00c242010-03-19 11:23:45 +0100304};
305
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306struct alc_spec {
307 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100308 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100310 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100311 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200313 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200314 * don't forget NULL
315 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200316 */
317 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200319 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320 struct hda_pcm_stream *stream_analog_playback;
321 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100322 struct hda_pcm_stream *stream_analog_alt_playback;
323 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200325 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 struct hda_pcm_stream *stream_digital_playback;
327 struct hda_pcm_stream *stream_digital_capture;
328
329 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200330 struct hda_multi_out multiout; /* playback set-up
331 * max_channels, dacs must be set
332 * dig_out_nid and hp_nid are optional
333 */
Takashi Iwai63300792008-01-24 15:31:36 +0100334 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100335 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100336 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337
338 /* capture */
339 unsigned int num_adc_nids;
340 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100341 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200342 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343
Takashi Iwai840b64c2010-07-13 22:49:01 +0200344 /* capture setup for dynamic dual-adc switch */
345 unsigned int cur_adc_idx;
346 hda_nid_t cur_adc;
347 unsigned int cur_adc_stream_tag;
348 unsigned int cur_adc_format;
349
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200351 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 const struct hda_input_mux *input_mux;
353 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200354 struct alc_mic_route ext_mic;
355 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356
357 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100358 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200360 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200361 int const_channel_count;
362 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363
364 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100365 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200366
Kailang Yang9ad0e492010-09-14 23:22:00 +0200367 /* jack detection */
368 struct snd_array jacks;
369
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200370 /* dynamic controls, init_verbs and input_mux */
371 struct auto_pin_cfg autocfg;
Kailang Yangda00c242010-03-19 11:23:45 +0100372 struct alc_customize_define cdefine;
Takashi Iwai603c4012008-07-30 15:01:44 +0200373 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200374 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200375 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200376 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
377 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100378
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100379 /* hooks */
380 void (*init_hook)(struct hda_codec *codec);
381 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100382#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -0500383 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100384#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100385
Takashi Iwai834be882006-03-01 14:16:17 +0100386 /* for pin sensing */
387 unsigned int sense_updated: 1;
388 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100389 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200390 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200391
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100392 /* other flags */
393 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai840b64c2010-07-13 22:49:01 +0200394 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200395 int init_amp;
Takashi Iwaid433a672010-09-20 15:11:54 +0200396 int codec_variant; /* flag for other variants */
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100397
Takashi Iwai2134ea42008-01-10 16:53:55 +0100398 /* for virtual master */
399 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200400#ifdef CONFIG_SND_HDA_POWER_SAVE
401 struct hda_loopback_check loopback;
402#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200403
404 /* for PLL fix */
405 hda_nid_t pll_nid;
406 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100407};
408
409/*
410 * configuration template - to be copied to the spec instance
411 */
412struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200413 struct snd_kcontrol_new *mixers[5]; /* should be identical size
414 * with spec
415 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100416 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100417 const struct hda_verb *init_verbs[5];
418 unsigned int num_dacs;
419 hda_nid_t *dac_nids;
420 hda_nid_t dig_out_nid; /* optional */
421 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800422 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100423 unsigned int num_adc_nids;
424 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100425 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100426 hda_nid_t dig_in_nid;
427 unsigned int num_channel_mode;
428 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200429 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200430 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200431 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100432 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100433 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200434 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100435 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200436#ifdef CONFIG_SND_HDA_POWER_SAVE
437 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500438 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200439#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440};
441
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442
443/*
444 * input MUX handling
445 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200446static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
447 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448{
449 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
450 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200451 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
452 if (mux_idx >= spec->num_mux_defs)
453 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100454 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
455 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200456 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457}
458
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200459static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
460 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461{
462 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
463 struct alc_spec *spec = codec->spec;
464 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
465
466 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
467 return 0;
468}
469
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200470static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
471 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472{
473 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
474 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100475 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100477 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100478 hda_nid_t nid = spec->capsrc_nids ?
479 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200480 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481
Takashi Iwaicd896c32008-11-18 12:36:33 +0100482 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
483 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100484 if (!imux->num_items && mux_idx > 0)
485 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100486
Takashi Iwaia22d5432009-07-27 12:54:26 +0200487 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200488 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100489 /* Matrix-mixer style (e.g. ALC882) */
490 unsigned int *cur_val = &spec->cur_mux[adc_idx];
491 unsigned int i, idx;
492
493 idx = ucontrol->value.enumerated.item[0];
494 if (idx >= imux->num_items)
495 idx = imux->num_items - 1;
496 if (*cur_val == idx)
497 return 0;
498 for (i = 0; i < imux->num_items; i++) {
499 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
500 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
501 imux->items[i].index,
502 HDA_AMP_MUTE, v);
503 }
504 *cur_val = idx;
505 return 1;
506 } else {
507 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100508 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100509 &spec->cur_mux[adc_idx]);
510 }
511}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200512
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513/*
514 * channel mode setting
515 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200516static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
517 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518{
519 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
520 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100521 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
522 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523}
524
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200525static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
526 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527{
528 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
529 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100530 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200531 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200532 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533}
534
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200535static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
536 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537{
538 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
539 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200540 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
541 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200542 &spec->ext_channel_count);
543 if (err >= 0 && !spec->const_channel_count) {
544 spec->multiout.max_channels = spec->ext_channel_count;
545 if (spec->need_dac_fix)
546 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
547 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200548 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549}
550
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100552 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200553 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100554 * being part of a format specifier. Maximum allowed length of a value is
555 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100556 *
557 * Note: some retasking pin complexes seem to ignore requests for input
558 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
559 * are requested. Therefore order this list so that this behaviour will not
560 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200561 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
562 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200563 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100564static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100565 "Mic 50pc bias", "Mic 80pc bias",
566 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100567};
568static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100569 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100570};
571/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200572 * in the pin being assumed to be exclusively an input or an output pin. In
573 * addition, "input" pins may or may not process the mic bias option
574 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
575 * accept requests for bias as of chip versions up to March 2006) and/or
576 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100577 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200578#define ALC_PIN_DIR_IN 0x00
579#define ALC_PIN_DIR_OUT 0x01
580#define ALC_PIN_DIR_INOUT 0x02
581#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
582#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100583
Kailang Yangea1fb292008-08-26 12:58:38 +0200584/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100585 * For each direction the minimum and maximum values are given.
586 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200587static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100588 { 0, 2 }, /* ALC_PIN_DIR_IN */
589 { 3, 4 }, /* ALC_PIN_DIR_OUT */
590 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200591 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
592 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100593};
594#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
595#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
596#define alc_pin_mode_n_items(_dir) \
597 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
598
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200599static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
600 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200601{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100602 unsigned int item_num = uinfo->value.enumerated.item;
603 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
604
605 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200606 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100607 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
608
609 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
610 item_num = alc_pin_mode_min(dir);
611 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200612 return 0;
613}
614
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200615static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
616 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200617{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100618 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200619 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
620 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100621 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200622 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200623 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
624 AC_VERB_GET_PIN_WIDGET_CONTROL,
625 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200626
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100627 /* Find enumerated value for current pinctl setting */
628 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200629 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100630 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200631 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100632 return 0;
633}
634
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200635static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
636 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100637{
638 signed int change;
639 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
640 hda_nid_t nid = kcontrol->private_value & 0xffff;
641 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
642 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200643 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
644 AC_VERB_GET_PIN_WIDGET_CONTROL,
645 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100646
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200647 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100648 val = alc_pin_mode_min(dir);
649
650 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100651 if (change) {
652 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200653 snd_hda_codec_write_cache(codec, nid, 0,
654 AC_VERB_SET_PIN_WIDGET_CONTROL,
655 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100656
Kailang Yangea1fb292008-08-26 12:58:38 +0200657 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100658 * for the requested pin mode. Enum values of 2 or less are
659 * input modes.
660 *
661 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200662 * reduces noise slightly (particularly on input) so we'll
663 * do it. However, having both input and output buffers
664 * enabled simultaneously doesn't seem to be problematic if
665 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100666 */
667 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200668 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
669 HDA_AMP_MUTE, HDA_AMP_MUTE);
670 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
671 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100672 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200673 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
674 HDA_AMP_MUTE, HDA_AMP_MUTE);
675 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
676 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100677 }
678 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200679 return change;
680}
681
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100682#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200683 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100684 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100685 .info = alc_pin_mode_info, \
686 .get = alc_pin_mode_get, \
687 .put = alc_pin_mode_put, \
688 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100689
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100690/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
691 * together using a mask with more than one bit set. This control is
692 * currently used only by the ALC260 test model. At this stage they are not
693 * needed for any "production" models.
694 */
695#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200696#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200697
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200698static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
699 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100700{
701 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
702 hda_nid_t nid = kcontrol->private_value & 0xffff;
703 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
704 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200705 unsigned int val = snd_hda_codec_read(codec, nid, 0,
706 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100707
708 *valp = (val & mask) != 0;
709 return 0;
710}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200711static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
712 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100713{
714 signed int change;
715 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
716 hda_nid_t nid = kcontrol->private_value & 0xffff;
717 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
718 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200719 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
720 AC_VERB_GET_GPIO_DATA,
721 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100722
723 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200724 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
725 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100726 gpio_data &= ~mask;
727 else
728 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200729 snd_hda_codec_write_cache(codec, nid, 0,
730 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100731
732 return change;
733}
734#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
735 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100736 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100737 .info = alc_gpio_data_info, \
738 .get = alc_gpio_data_get, \
739 .put = alc_gpio_data_put, \
740 .private_value = nid | (mask<<16) }
741#endif /* CONFIG_SND_DEBUG */
742
Jonathan Woithe92621f12006-02-28 11:47:47 +0100743/* A switch control to allow the enabling of the digital IO pins on the
744 * ALC260. This is incredibly simplistic; the intention of this control is
745 * to provide something in the test model allowing digital outputs to be
746 * identified if present. If models are found which can utilise these
747 * outputs a more complete mixer control can be devised for those models if
748 * necessary.
749 */
750#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200751#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200752
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200753static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
754 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100755{
756 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
757 hda_nid_t nid = kcontrol->private_value & 0xffff;
758 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
759 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200760 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100761 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100762
763 *valp = (val & mask) != 0;
764 return 0;
765}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200766static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
767 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100768{
769 signed int change;
770 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
771 hda_nid_t nid = kcontrol->private_value & 0xffff;
772 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
773 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200774 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100775 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200776 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100777
778 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200779 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100780 if (val==0)
781 ctrl_data &= ~mask;
782 else
783 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200784 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
785 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100786
787 return change;
788}
789#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
790 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100791 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100792 .info = alc_spdif_ctrl_info, \
793 .get = alc_spdif_ctrl_get, \
794 .put = alc_spdif_ctrl_put, \
795 .private_value = nid | (mask<<16) }
796#endif /* CONFIG_SND_DEBUG */
797
Jonathan Woithef8225f62008-01-08 12:16:54 +0100798/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
799 * Again, this is only used in the ALC26x test models to help identify when
800 * the EAPD line must be asserted for features to work.
801 */
802#ifdef CONFIG_SND_DEBUG
803#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
804
805static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
806 struct snd_ctl_elem_value *ucontrol)
807{
808 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
809 hda_nid_t nid = kcontrol->private_value & 0xffff;
810 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
811 long *valp = ucontrol->value.integer.value;
812 unsigned int val = snd_hda_codec_read(codec, nid, 0,
813 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
814
815 *valp = (val & mask) != 0;
816 return 0;
817}
818
819static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
820 struct snd_ctl_elem_value *ucontrol)
821{
822 int change;
823 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
824 hda_nid_t nid = kcontrol->private_value & 0xffff;
825 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
826 long val = *ucontrol->value.integer.value;
827 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
828 AC_VERB_GET_EAPD_BTLENABLE,
829 0x00);
830
831 /* Set/unset the masked control bit(s) as needed */
832 change = (!val ? 0 : mask) != (ctrl_data & mask);
833 if (!val)
834 ctrl_data &= ~mask;
835 else
836 ctrl_data |= mask;
837 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
838 ctrl_data);
839
840 return change;
841}
842
843#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
844 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100845 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100846 .info = alc_eapd_ctrl_info, \
847 .get = alc_eapd_ctrl_get, \
848 .put = alc_eapd_ctrl_put, \
849 .private_value = nid | (mask<<16) }
850#endif /* CONFIG_SND_DEBUG */
851
Kailang Yangdf694da2005-12-05 19:42:22 +0100852/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100853 * set up the input pin config (depending on the given auto-pin type)
854 */
855static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
856 int auto_pin_type)
857{
858 unsigned int val = PIN_IN;
859
Takashi Iwai86e29592010-09-09 14:50:17 +0200860 if (auto_pin_type == AUTO_PIN_MIC) {
Takashi Iwai23f0c042009-02-26 13:03:58 +0100861 unsigned int pincap;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200862 unsigned int oldval;
863 oldval = snd_hda_codec_read(codec, nid, 0,
864 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Takashi Iwai1327a322009-03-23 13:07:47 +0100865 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100866 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200867 /* if the default pin setup is vref50, we give it priority */
868 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
Takashi Iwai23f0c042009-02-26 13:03:58 +0100869 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200870 else if (pincap & AC_PINCAP_VREF_50)
871 val = PIN_VREF50;
872 else if (pincap & AC_PINCAP_VREF_100)
873 val = PIN_VREF100;
874 else if (pincap & AC_PINCAP_VREF_GRD)
875 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100876 }
877 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
878}
879
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200880static void alc_fixup_autocfg_pin_nums(struct hda_codec *codec)
881{
882 struct alc_spec *spec = codec->spec;
883 struct auto_pin_cfg *cfg = &spec->autocfg;
884
885 if (!cfg->line_outs) {
886 while (cfg->line_outs < AUTO_CFG_MAX_OUTS &&
887 cfg->line_out_pins[cfg->line_outs])
888 cfg->line_outs++;
889 }
890 if (!cfg->speaker_outs) {
891 while (cfg->speaker_outs < AUTO_CFG_MAX_OUTS &&
892 cfg->speaker_pins[cfg->speaker_outs])
893 cfg->speaker_outs++;
894 }
895 if (!cfg->hp_outs) {
896 while (cfg->hp_outs < AUTO_CFG_MAX_OUTS &&
897 cfg->hp_pins[cfg->hp_outs])
898 cfg->hp_outs++;
899 }
900}
901
Takashi Iwai23f0c042009-02-26 13:03:58 +0100902/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100903 */
904static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
905{
906 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
907 return;
908 spec->mixers[spec->num_mixers++] = mix;
909}
910
911static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
912{
913 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
914 return;
915 spec->init_verbs[spec->num_init_verbs++] = verb;
916}
917
918/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100919 * set up from the preset table
920 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200921static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200922 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100923{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200924 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100925 int i;
926
927 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100928 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100929 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200930 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
931 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100932 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200933
Kailang Yangdf694da2005-12-05 19:42:22 +0100934 spec->channel_mode = preset->channel_mode;
935 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200936 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200937 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100938
Hector Martin3b315d72009-06-02 10:54:19 +0200939 if (preset->const_channel_count)
940 spec->multiout.max_channels = preset->const_channel_count;
941 else
942 spec->multiout.max_channels = spec->channel_mode[0].channels;
943 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100944
945 spec->multiout.num_dacs = preset->num_dacs;
946 spec->multiout.dac_nids = preset->dac_nids;
947 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800948 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100949 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200950
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200951 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200952 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200953 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100954 spec->input_mux = preset->input_mux;
955
956 spec->num_adc_nids = preset->num_adc_nids;
957 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100958 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100959 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100960
961 spec->unsol_event = preset->unsol_event;
962 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200963#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100964 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200965 spec->loopback.amplist = preset->loopbacks;
966#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200967
968 if (preset->setup)
969 preset->setup(codec);
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200970
971 alc_fixup_autocfg_pin_nums(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100972}
973
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200974/* Enable GPIO mask and set output */
975static struct hda_verb alc_gpio1_init_verbs[] = {
976 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
977 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
978 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
979 { }
980};
981
982static struct hda_verb alc_gpio2_init_verbs[] = {
983 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
984 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
985 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
986 { }
987};
988
Kailang Yangbdd148a2007-05-08 15:19:08 +0200989static struct hda_verb alc_gpio3_init_verbs[] = {
990 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
991 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
992 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
993 { }
994};
995
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200996/*
997 * Fix hardware PLL issue
998 * On some codecs, the analog PLL gating control must be off while
999 * the default value is 1.
1000 */
1001static void alc_fix_pll(struct hda_codec *codec)
1002{
1003 struct alc_spec *spec = codec->spec;
1004 unsigned int val;
1005
1006 if (!spec->pll_nid)
1007 return;
1008 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1009 spec->pll_coef_idx);
1010 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
1011 AC_VERB_GET_PROC_COEF, 0);
1012 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1013 spec->pll_coef_idx);
1014 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
1015 val & ~(1 << spec->pll_coef_bit));
1016}
1017
1018static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
1019 unsigned int coef_idx, unsigned int coef_bit)
1020{
1021 struct alc_spec *spec = codec->spec;
1022 spec->pll_nid = nid;
1023 spec->pll_coef_idx = coef_idx;
1024 spec->pll_coef_bit = coef_bit;
1025 alc_fix_pll(codec);
1026}
1027
Kailang Yang9ad0e492010-09-14 23:22:00 +02001028#ifdef CONFIG_SND_HDA_INPUT_JACK
1029static void alc_free_jack_priv(struct snd_jack *jack)
1030{
1031 struct alc_jack *jacks = jack->private_data;
1032 jacks->nid = 0;
1033 jacks->jack = NULL;
1034}
1035
1036static int alc_add_jack(struct hda_codec *codec,
1037 hda_nid_t nid, int type)
1038{
1039 struct alc_spec *spec;
1040 struct alc_jack *jack;
1041 const char *name;
1042 int err;
1043
1044 spec = codec->spec;
1045 snd_array_init(&spec->jacks, sizeof(*jack), 32);
1046 jack = snd_array_new(&spec->jacks);
1047 if (!jack)
1048 return -ENOMEM;
1049
1050 jack->nid = nid;
1051 jack->type = type;
1052 name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ;
1053
1054 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
1055 if (err < 0)
1056 return err;
1057 jack->jack->private_data = jack;
1058 jack->jack->private_free = alc_free_jack_priv;
1059 return 0;
1060}
1061
1062static void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1063{
1064 struct alc_spec *spec = codec->spec;
1065 struct alc_jack *jacks = spec->jacks.list;
1066
1067 if (jacks) {
1068 int i;
1069 for (i = 0; i < spec->jacks.used; i++) {
1070 if (jacks->nid == nid) {
1071 unsigned int present;
1072 present = snd_hda_jack_detect(codec, nid);
1073
1074 present = (present) ? jacks->type : 0;
1075
1076 snd_jack_report(jacks->jack, present);
1077 }
1078 jacks++;
1079 }
1080 }
1081}
1082
1083static int alc_init_jacks(struct hda_codec *codec)
1084{
1085 struct alc_spec *spec = codec->spec;
1086 int err;
1087 unsigned int hp_nid = spec->autocfg.hp_pins[0];
1088 unsigned int mic_nid = spec->ext_mic.pin;
1089
Takashi Iwai265a0242010-09-21 11:26:21 +02001090 if (hp_nid) {
1091 err = alc_add_jack(codec, hp_nid, SND_JACK_HEADPHONE);
1092 if (err < 0)
1093 return err;
1094 alc_report_jack(codec, hp_nid);
1095 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001096
Takashi Iwai265a0242010-09-21 11:26:21 +02001097 if (mic_nid) {
1098 err = alc_add_jack(codec, mic_nid, SND_JACK_MICROPHONE);
1099 if (err < 0)
1100 return err;
1101 alc_report_jack(codec, mic_nid);
1102 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001103
1104 return 0;
1105}
1106#else
1107static inline void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1108{
1109}
1110
1111static inline int alc_init_jacks(struct hda_codec *codec)
1112{
1113 return 0;
1114}
1115#endif
1116
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001117static void alc_automute_speaker(struct hda_codec *codec, int pinctl)
Kailang Yangc9b58002007-10-16 14:30:01 +02001118{
1119 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001120 unsigned int mute;
1121 hda_nid_t nid;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001122 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +02001123
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001124 spec->jack_present = 0;
1125 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1126 nid = spec->autocfg.hp_pins[i];
1127 if (!nid)
1128 break;
1129 if (snd_hda_jack_detect(codec, nid)) {
1130 spec->jack_present = 1;
1131 break;
1132 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001133 alc_report_jack(codec, spec->autocfg.hp_pins[i]);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001134 }
1135
1136 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1137 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001138 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1139 nid = spec->autocfg.speaker_pins[i];
1140 if (!nid)
1141 break;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001142 if (pinctl) {
1143 snd_hda_codec_write(codec, nid, 0,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001144 AC_VERB_SET_PIN_WIDGET_CONTROL,
1145 spec->jack_present ? 0 : PIN_OUT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001146 } else {
1147 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1148 HDA_AMP_MUTE, mute);
1149 }
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001150 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001151}
1152
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001153static void alc_automute_pin(struct hda_codec *codec)
1154{
1155 alc_automute_speaker(codec, 1);
1156}
1157
Takashi Iwai6c819492009-08-10 18:47:44 +02001158static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1159 hda_nid_t nid)
1160{
1161 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1162 int i, nums;
1163
1164 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1165 for (i = 0; i < nums; i++)
1166 if (conn[i] == nid)
1167 return i;
1168 return -1;
1169}
1170
Takashi Iwai840b64c2010-07-13 22:49:01 +02001171/* switch the current ADC according to the jack state */
1172static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1173{
1174 struct alc_spec *spec = codec->spec;
1175 unsigned int present;
1176 hda_nid_t new_adc;
1177
1178 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1179 if (present)
1180 spec->cur_adc_idx = 1;
1181 else
1182 spec->cur_adc_idx = 0;
1183 new_adc = spec->adc_nids[spec->cur_adc_idx];
1184 if (spec->cur_adc && spec->cur_adc != new_adc) {
1185 /* stream is running, let's swap the current ADC */
Takashi Iwaif0cea792010-08-13 11:56:53 +02001186 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
Takashi Iwai840b64c2010-07-13 22:49:01 +02001187 spec->cur_adc = new_adc;
1188 snd_hda_codec_setup_stream(codec, new_adc,
1189 spec->cur_adc_stream_tag, 0,
1190 spec->cur_adc_format);
1191 }
1192}
1193
Kailang Yang7fb0d782008-10-15 11:12:35 +02001194static void alc_mic_automute(struct hda_codec *codec)
1195{
1196 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001197 struct alc_mic_route *dead, *alive;
1198 unsigned int present, type;
1199 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001200
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001201 if (!spec->auto_mic)
1202 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001203 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1204 return;
1205 if (snd_BUG_ON(!spec->adc_nids))
1206 return;
1207
Takashi Iwai840b64c2010-07-13 22:49:01 +02001208 if (spec->dual_adc_switch) {
1209 alc_dual_mic_adc_auto_switch(codec);
1210 return;
1211 }
1212
Takashi Iwai6c819492009-08-10 18:47:44 +02001213 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1214
Wu Fengguang864f92b2009-11-18 12:38:02 +08001215 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001216 if (present) {
1217 alive = &spec->ext_mic;
1218 dead = &spec->int_mic;
1219 } else {
1220 alive = &spec->int_mic;
1221 dead = &spec->ext_mic;
1222 }
1223
Takashi Iwai6c819492009-08-10 18:47:44 +02001224 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1225 if (type == AC_WID_AUD_MIX) {
1226 /* Matrix-mixer style (e.g. ALC882) */
1227 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1228 alive->mux_idx,
1229 HDA_AMP_MUTE, 0);
1230 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1231 dead->mux_idx,
1232 HDA_AMP_MUTE, HDA_AMP_MUTE);
1233 } else {
1234 /* MUX style (e.g. ALC880) */
1235 snd_hda_codec_write_cache(codec, cap_nid, 0,
1236 AC_VERB_SET_CONNECT_SEL,
1237 alive->mux_idx);
1238 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001239 alc_report_jack(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001240
1241 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001242}
1243
Kailang Yangc9b58002007-10-16 14:30:01 +02001244/* unsolicited event for HP jack sensing */
1245static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1246{
1247 if (codec->vendor_id == 0x10ec0880)
1248 res >>= 28;
1249 else
1250 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001251 switch (res) {
1252 case ALC880_HP_EVENT:
1253 alc_automute_pin(codec);
1254 break;
1255 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001256 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001257 break;
1258 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001259}
1260
1261static void alc_inithook(struct hda_codec *codec)
1262{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001263 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001264 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001265}
1266
Kailang Yangf9423e72008-05-27 12:32:25 +02001267/* additional initialization for ALC888 variants */
1268static void alc888_coef_init(struct hda_codec *codec)
1269{
1270 unsigned int tmp;
1271
1272 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1273 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1274 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001275 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001276 /* alc888S-VC */
1277 snd_hda_codec_read(codec, 0x20, 0,
1278 AC_VERB_SET_PROC_COEF, 0x830);
1279 else
1280 /* alc888-VB */
1281 snd_hda_codec_read(codec, 0x20, 0,
1282 AC_VERB_SET_PROC_COEF, 0x3030);
1283}
1284
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001285static void alc889_coef_init(struct hda_codec *codec)
1286{
1287 unsigned int tmp;
1288
1289 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1290 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1291 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1292 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1293}
1294
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001295/* turn on/off EAPD control (only if available) */
1296static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1297{
1298 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1299 return;
1300 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1301 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1302 on ? 2 : 0);
1303}
1304
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001305static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001306{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001307 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001308
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001309 switch (type) {
1310 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001311 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1312 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001313 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001314 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1315 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001316 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001317 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1318 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001319 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001320 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001321 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001322 set_eapd(codec, 0x0f, 1);
1323 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001324 break;
1325 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001326 case 0x10ec0267:
1327 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001328 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001329 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001330 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001331 case 0x10ec0660:
1332 case 0x10ec0662:
1333 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001334 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001335 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001336 set_eapd(codec, 0x14, 1);
1337 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001338 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001339 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001340 switch (codec->vendor_id) {
1341 case 0x10ec0260:
1342 snd_hda_codec_write(codec, 0x1a, 0,
1343 AC_VERB_SET_COEF_INDEX, 7);
1344 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1345 AC_VERB_GET_PROC_COEF, 0);
1346 snd_hda_codec_write(codec, 0x1a, 0,
1347 AC_VERB_SET_COEF_INDEX, 7);
1348 snd_hda_codec_write(codec, 0x1a, 0,
1349 AC_VERB_SET_PROC_COEF,
1350 tmp | 0x2010);
1351 break;
1352 case 0x10ec0262:
1353 case 0x10ec0880:
1354 case 0x10ec0882:
1355 case 0x10ec0883:
1356 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001357 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001358 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001359 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001360 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001361 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001362 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001363 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001364#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001365 case 0x10ec0267:
1366 case 0x10ec0268:
1367 snd_hda_codec_write(codec, 0x20, 0,
1368 AC_VERB_SET_COEF_INDEX, 7);
1369 tmp = snd_hda_codec_read(codec, 0x20, 0,
1370 AC_VERB_GET_PROC_COEF, 0);
1371 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001372 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001373 snd_hda_codec_write(codec, 0x20, 0,
1374 AC_VERB_SET_PROC_COEF,
1375 tmp | 0x3000);
1376 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001377#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001378 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001379 break;
1380 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001381}
Kailang Yangea1fb292008-08-26 12:58:38 +02001382
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001383static void alc_init_auto_hp(struct hda_codec *codec)
1384{
1385 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001386 struct auto_pin_cfg *cfg = &spec->autocfg;
1387 int i;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001388
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001389 if (!cfg->hp_pins[0]) {
1390 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001391 return;
1392 }
1393
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001394 if (!cfg->speaker_pins[0]) {
1395 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
1396 return;
1397 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1398 sizeof(cfg->speaker_pins));
1399 cfg->speaker_outs = cfg->line_outs;
1400 }
1401
1402 if (!cfg->hp_pins[0]) {
1403 memcpy(cfg->hp_pins, cfg->line_out_pins,
1404 sizeof(cfg->hp_pins));
1405 cfg->hp_outs = cfg->line_outs;
1406 }
1407
1408 for (i = 0; i < cfg->hp_outs; i++) {
1409 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1410 cfg->hp_pins[i]);
1411 snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0,
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001412 AC_VERB_SET_UNSOLICITED_ENABLE,
1413 AC_USRSP_EN | ALC880_HP_EVENT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001414 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001415 spec->unsol_event = alc_sku_unsol_event;
1416}
1417
Takashi Iwai6c819492009-08-10 18:47:44 +02001418static void alc_init_auto_mic(struct hda_codec *codec)
1419{
1420 struct alc_spec *spec = codec->spec;
1421 struct auto_pin_cfg *cfg = &spec->autocfg;
1422 hda_nid_t fixed, ext;
1423 int i;
1424
1425 /* there must be only two mic inputs exclusively */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001426 for (i = 0; i < cfg->num_inputs; i++)
Takashi Iwai86e29592010-09-09 14:50:17 +02001427 if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
Takashi Iwai6c819492009-08-10 18:47:44 +02001428 return;
1429
1430 fixed = ext = 0;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001431 for (i = 0; i < cfg->num_inputs; i++) {
1432 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai6c819492009-08-10 18:47:44 +02001433 unsigned int defcfg;
Takashi Iwai6c819492009-08-10 18:47:44 +02001434 defcfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001435 switch (snd_hda_get_input_pin_attr(defcfg)) {
1436 case INPUT_PIN_ATTR_INT:
Takashi Iwai6c819492009-08-10 18:47:44 +02001437 if (fixed)
1438 return; /* already occupied */
1439 fixed = nid;
1440 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001441 case INPUT_PIN_ATTR_UNUSED:
1442 return; /* invalid entry */
1443 default:
Takashi Iwai6c819492009-08-10 18:47:44 +02001444 if (ext)
1445 return; /* already occupied */
1446 ext = nid;
1447 break;
Takashi Iwai6c819492009-08-10 18:47:44 +02001448 }
1449 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001450 if (!ext || !fixed)
1451 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001452 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1453 return; /* no unsol support */
1454 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1455 ext, fixed);
1456 spec->ext_mic.pin = ext;
1457 spec->int_mic.pin = fixed;
1458 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1459 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1460 spec->auto_mic = 1;
1461 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1462 AC_VERB_SET_UNSOLICITED_ENABLE,
1463 AC_USRSP_EN | ALC880_MIC_EVENT);
1464 spec->unsol_event = alc_sku_unsol_event;
1465}
1466
David Henningsson90622912010-10-14 14:50:18 +02001467/* Could be any non-zero and even value. When used as fixup, tells
1468 * the driver to ignore any present sku defines.
1469 */
1470#define ALC_FIXUP_SKU_IGNORE (2)
1471
Kailang Yangda00c242010-03-19 11:23:45 +01001472static int alc_auto_parse_customize_define(struct hda_codec *codec)
1473{
1474 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001475 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001476 struct alc_spec *spec = codec->spec;
1477
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001478 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1479
David Henningsson90622912010-10-14 14:50:18 +02001480 if (spec->cdefine.fixup) {
1481 ass = spec->cdefine.sku_cfg;
1482 if (ass == ALC_FIXUP_SKU_IGNORE)
1483 return -1;
1484 goto do_sku;
1485 }
1486
Kailang Yangda00c242010-03-19 11:23:45 +01001487 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001488 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +01001489 goto do_sku;
1490
1491 nid = 0x1d;
1492 if (codec->vendor_id == 0x10ec0260)
1493 nid = 0x17;
1494 ass = snd_hda_codec_get_pincfg(codec, nid);
1495
1496 if (!(ass & 1)) {
1497 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1498 codec->chip_name, ass);
1499 return -1;
1500 }
1501
1502 /* check sum */
1503 tmp = 0;
1504 for (i = 1; i < 16; i++) {
1505 if ((ass >> i) & 1)
1506 tmp++;
1507 }
1508 if (((ass >> 16) & 0xf) != tmp)
1509 return -1;
1510
1511 spec->cdefine.port_connectivity = ass >> 30;
1512 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1513 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1514 spec->cdefine.customization = ass >> 8;
1515do_sku:
1516 spec->cdefine.sku_cfg = ass;
1517 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1518 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1519 spec->cdefine.swap = (ass & 0x2) >> 1;
1520 spec->cdefine.override = ass & 0x1;
1521
1522 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1523 nid, spec->cdefine.sku_cfg);
1524 snd_printd("SKU: port_connectivity=0x%x\n",
1525 spec->cdefine.port_connectivity);
1526 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1527 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1528 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1529 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1530 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1531 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1532 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1533
1534 return 0;
1535}
1536
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001537/* check subsystem ID and set up device-specific initialization;
1538 * return 1 if initialized, 0 if invalid SSID
1539 */
1540/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1541 * 31 ~ 16 : Manufacture ID
1542 * 15 ~ 8 : SKU ID
1543 * 7 ~ 0 : Assembly ID
1544 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1545 */
1546static int alc_subsystem_id(struct hda_codec *codec,
1547 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001548 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001549{
1550 unsigned int ass, tmp, i;
1551 unsigned nid;
1552 struct alc_spec *spec = codec->spec;
1553
David Henningsson90622912010-10-14 14:50:18 +02001554 if (spec->cdefine.fixup) {
1555 ass = spec->cdefine.sku_cfg;
1556 if (ass == ALC_FIXUP_SKU_IGNORE)
1557 return 0;
1558 goto do_sku;
1559 }
1560
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001561 ass = codec->subsystem_id & 0xffff;
1562 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1563 goto do_sku;
1564
1565 /* invalid SSID, check the special NID pin defcfg instead */
1566 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001567 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001568 * 29~21 : reserve
1569 * 20 : PCBEEP input
1570 * 19~16 : Check sum (15:1)
1571 * 15~1 : Custom
1572 * 0 : override
1573 */
1574 nid = 0x1d;
1575 if (codec->vendor_id == 0x10ec0260)
1576 nid = 0x17;
1577 ass = snd_hda_codec_get_pincfg(codec, nid);
1578 snd_printd("realtek: No valid SSID, "
1579 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001580 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001581 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001582 return 0;
1583 if ((ass >> 30) != 1) /* no physical connection */
1584 return 0;
1585
1586 /* check sum */
1587 tmp = 0;
1588 for (i = 1; i < 16; i++) {
1589 if ((ass >> i) & 1)
1590 tmp++;
1591 }
1592 if (((ass >> 16) & 0xf) != tmp)
1593 return 0;
1594do_sku:
1595 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1596 ass & 0xffff, codec->vendor_id);
1597 /*
1598 * 0 : override
1599 * 1 : Swap Jack
1600 * 2 : 0 --> Desktop, 1 --> Laptop
1601 * 3~5 : External Amplifier control
1602 * 7~6 : Reserved
1603 */
1604 tmp = (ass & 0x38) >> 3; /* external Amp control */
1605 switch (tmp) {
1606 case 1:
1607 spec->init_amp = ALC_INIT_GPIO1;
1608 break;
1609 case 3:
1610 spec->init_amp = ALC_INIT_GPIO2;
1611 break;
1612 case 7:
1613 spec->init_amp = ALC_INIT_GPIO3;
1614 break;
1615 case 5:
Takashi Iwai5a8cfb42010-11-26 17:11:18 +01001616 default:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001617 spec->init_amp = ALC_INIT_DEFAULT;
1618 break;
1619 }
1620
1621 /* is laptop or Desktop and enable the function "Mute internal speaker
1622 * when the external headphone out jack is plugged"
1623 */
1624 if (!(ass & 0x8000))
1625 return 1;
1626 /*
1627 * 10~8 : Jack location
1628 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1629 * 14~13: Resvered
1630 * 15 : 1 --> enable the function "Mute internal speaker
1631 * when the external headphone out jack is plugged"
1632 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001633 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001634 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001635 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1636 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001637 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001638 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001639 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001640 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001641 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001642 else if (tmp == 3)
1643 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001644 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001645 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001646 for (i = 0; i < spec->autocfg.line_outs; i++)
1647 if (spec->autocfg.line_out_pins[i] == nid)
1648 return 1;
1649 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001650 }
1651
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001652 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001653 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001654 return 1;
1655}
Kailang Yangea1fb292008-08-26 12:58:38 +02001656
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001657static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001658 hda_nid_t porta, hda_nid_t porte,
1659 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001660{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001661 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001662 struct alc_spec *spec = codec->spec;
1663 snd_printd("realtek: "
1664 "Enable default setup for auto mode as fallback\n");
1665 spec->init_amp = ALC_INIT_DEFAULT;
1666 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001667 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001668 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001669}
1670
Takashi Iwai41e41f12005-06-08 14:48:49 +02001671/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001672 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001673 */
1674
1675struct alc_pincfg {
1676 hda_nid_t nid;
1677 u32 val;
1678};
1679
Todd Broche1eb5f12010-12-06 11:19:51 -08001680struct alc_model_fixup {
1681 const int id;
1682 const char *name;
1683};
1684
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001685struct alc_fixup {
David Henningsson90622912010-10-14 14:50:18 +02001686 unsigned int sku;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001687 const struct alc_pincfg *pins;
1688 const struct hda_verb *verbs;
Takashi Iwai9d578832010-11-22 13:29:19 +01001689 void (*func)(struct hda_codec *codec, const struct alc_fixup *fix,
1690 int pre_init);
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001691};
1692
Todd Broche1eb5f12010-12-06 11:19:51 -08001693static void __alc_pick_fixup(struct hda_codec *codec,
1694 const struct alc_fixup *fix,
1695 const char *modelname,
1696 int pre_init)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001697{
1698 const struct alc_pincfg *cfg;
David Henningsson90622912010-10-14 14:50:18 +02001699 struct alc_spec *spec;
Takashi Iwaif95474e2007-07-10 00:47:43 +02001700
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001701 cfg = fix->pins;
David Henningsson90622912010-10-14 14:50:18 +02001702 if (pre_init && fix->sku) {
1703#ifdef CONFIG_SND_DEBUG_VERBOSE
1704 snd_printdd(KERN_INFO "hda_codec: %s: Apply sku override for %s\n",
Todd Broche1eb5f12010-12-06 11:19:51 -08001705 codec->chip_name, modelname);
David Henningsson90622912010-10-14 14:50:18 +02001706#endif
1707 spec = codec->spec;
1708 spec->cdefine.sku_cfg = fix->sku;
1709 spec->cdefine.fixup = 1;
1710 }
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001711 if (pre_init && cfg) {
1712#ifdef CONFIG_SND_DEBUG_VERBOSE
1713 snd_printdd(KERN_INFO "hda_codec: %s: Apply pincfg for %s\n",
Todd Broche1eb5f12010-12-06 11:19:51 -08001714 codec->chip_name, modelname);
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001715#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001716 for (; cfg->nid; cfg++)
1717 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1718 }
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001719 if (!pre_init && fix->verbs) {
1720#ifdef CONFIG_SND_DEBUG_VERBOSE
1721 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-verbs for %s\n",
Todd Broche1eb5f12010-12-06 11:19:51 -08001722 codec->chip_name, modelname);
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001723#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001724 add_verb(codec->spec, fix->verbs);
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001725 }
Takashi Iwai9d578832010-11-22 13:29:19 +01001726 if (fix->func) {
1727#ifdef CONFIG_SND_DEBUG_VERBOSE
1728 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-func for %s\n",
Todd Broche1eb5f12010-12-06 11:19:51 -08001729 codec->chip_name, modelname);
Takashi Iwai9d578832010-11-22 13:29:19 +01001730#endif
1731 fix->func(codec, fix, pre_init);
1732 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001733}
1734
Todd Broche1eb5f12010-12-06 11:19:51 -08001735static void alc_pick_fixup(struct hda_codec *codec,
1736 const struct snd_pci_quirk *quirk,
1737 const struct alc_fixup *fix,
1738 int pre_init)
1739{
1740 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1741 if (quirk) {
1742 fix += quirk->value;
1743#ifdef CONFIG_SND_DEBUG_VERBOSE
1744 __alc_pick_fixup(codec, fix, quirk->name, pre_init);
1745#else
1746 __alc_pick_fixup(codec, fix, NULL, pre_init);
1747#endif
1748 }
1749}
1750
1751static void alc_pick_fixup_model(struct hda_codec *codec,
1752 const struct alc_model_fixup *models,
1753 const struct snd_pci_quirk *quirk,
1754 const struct alc_fixup *fix,
1755 int pre_init)
1756{
1757 if (codec->modelname && models) {
1758 while (models->name) {
1759 if (!strcmp(codec->modelname, models->name)) {
1760 fix += models->id;
1761 break;
1762 }
1763 models++;
1764 }
1765 __alc_pick_fixup(codec, fix, codec->modelname, pre_init);
1766 } else {
1767 alc_pick_fixup(codec, quirk, fix, pre_init);
1768 }
1769}
1770
Kailang Yang274693f2009-12-03 10:07:50 +01001771static int alc_read_coef_idx(struct hda_codec *codec,
1772 unsigned int coef_idx)
1773{
1774 unsigned int val;
1775 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1776 coef_idx);
1777 val = snd_hda_codec_read(codec, 0x20, 0,
1778 AC_VERB_GET_PROC_COEF, 0);
1779 return val;
1780}
1781
Kailang Yang977ddd62010-09-15 10:02:29 +02001782static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1783 unsigned int coef_val)
1784{
1785 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1786 coef_idx);
1787 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1788 coef_val);
1789}
1790
Takashi Iwai757899a2010-07-30 10:48:14 +02001791/* set right pin controls for digital I/O */
1792static void alc_auto_init_digital(struct hda_codec *codec)
1793{
1794 struct alc_spec *spec = codec->spec;
1795 int i;
1796 hda_nid_t pin;
1797
1798 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1799 pin = spec->autocfg.dig_out_pins[i];
1800 if (pin) {
1801 snd_hda_codec_write(codec, pin, 0,
1802 AC_VERB_SET_PIN_WIDGET_CONTROL,
1803 PIN_OUT);
1804 }
1805 }
1806 pin = spec->autocfg.dig_in_pin;
1807 if (pin)
1808 snd_hda_codec_write(codec, pin, 0,
1809 AC_VERB_SET_PIN_WIDGET_CONTROL,
1810 PIN_IN);
1811}
1812
1813/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1814static void alc_auto_parse_digital(struct hda_codec *codec)
1815{
1816 struct alc_spec *spec = codec->spec;
1817 int i, err;
1818 hda_nid_t dig_nid;
1819
1820 /* support multiple SPDIFs; the secondary is set up as a slave */
1821 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1822 err = snd_hda_get_connections(codec,
1823 spec->autocfg.dig_out_pins[i],
1824 &dig_nid, 1);
1825 if (err < 0)
1826 continue;
1827 if (!i) {
1828 spec->multiout.dig_out_nid = dig_nid;
1829 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1830 } else {
1831 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1832 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1833 break;
1834 spec->slave_dig_outs[i - 1] = dig_nid;
1835 }
1836 }
1837
1838 if (spec->autocfg.dig_in_pin) {
Takashi Iwai01fdf182010-09-24 09:09:42 +02001839 dig_nid = codec->start_nid;
1840 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
1841 unsigned int wcaps = get_wcaps(codec, dig_nid);
1842 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
1843 continue;
1844 if (!(wcaps & AC_WCAP_DIGITAL))
1845 continue;
1846 if (!(wcaps & AC_WCAP_CONN_LIST))
1847 continue;
1848 err = get_connection_index(codec, dig_nid,
1849 spec->autocfg.dig_in_pin);
1850 if (err >= 0) {
1851 spec->dig_in_nid = dig_nid;
1852 break;
1853 }
1854 }
Takashi Iwai757899a2010-07-30 10:48:14 +02001855 }
1856}
1857
Takashi Iwaif95474e2007-07-10 00:47:43 +02001858/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001859 * ALC888
1860 */
1861
1862/*
1863 * 2ch mode
1864 */
1865static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1866/* Mic-in jack as mic in */
1867 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1868 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1869/* Line-in jack as Line in */
1870 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1871 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1872/* Line-Out as Front */
1873 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1874 { } /* end */
1875};
1876
1877/*
1878 * 4ch mode
1879 */
1880static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1881/* Mic-in jack as mic in */
1882 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1883 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1884/* Line-in jack as Surround */
1885 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1886 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1887/* Line-Out as Front */
1888 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1889 { } /* end */
1890};
1891
1892/*
1893 * 6ch mode
1894 */
1895static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1896/* Mic-in jack as CLFE */
1897 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1898 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1899/* Line-in jack as Surround */
1900 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1901 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1902/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1903 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1904 { } /* end */
1905};
1906
1907/*
1908 * 8ch mode
1909 */
1910static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1911/* Mic-in jack as CLFE */
1912 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1913 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1914/* Line-in jack as Surround */
1915 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1916 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1917/* Line-Out as Side */
1918 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1919 { } /* end */
1920};
1921
1922static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1923 { 2, alc888_4ST_ch2_intel_init },
1924 { 4, alc888_4ST_ch4_intel_init },
1925 { 6, alc888_4ST_ch6_intel_init },
1926 { 8, alc888_4ST_ch8_intel_init },
1927};
1928
1929/*
1930 * ALC888 Fujitsu Siemens Amillo xa3530
1931 */
1932
1933static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1934/* Front Mic: set to PIN_IN (empty by default) */
1935 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1936/* Connect Internal HP to Front */
1937 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1938 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1939 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1940/* Connect Bass HP to Front */
1941 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1942 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1943 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1944/* Connect Line-Out side jack (SPDIF) to Side */
1945 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1946 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1947 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1948/* Connect Mic jack to CLFE */
1949 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1950 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1951 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1952/* Connect Line-in jack to Surround */
1953 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1954 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1955 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1956/* Connect HP out jack to Front */
1957 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1958 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1959 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1960/* Enable unsolicited event for HP jack and Line-out jack */
1961 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1962 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1963 {}
1964};
1965
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001966static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001967{
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001968 alc_automute_speaker(codec, 0);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001969}
1970
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001971static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1972 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001973{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001974 if (codec->vendor_id == 0x10ec0880)
1975 res >>= 28;
1976 else
1977 res >>= 26;
1978 if (res == ALC880_HP_EVENT)
1979 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001980}
1981
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001982static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001983{
1984 struct alc_spec *spec = codec->spec;
1985
1986 spec->autocfg.hp_pins[0] = 0x15;
1987 spec->autocfg.speaker_pins[0] = 0x14;
1988 spec->autocfg.speaker_pins[1] = 0x16;
1989 spec->autocfg.speaker_pins[2] = 0x17;
1990 spec->autocfg.speaker_pins[3] = 0x19;
1991 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001992}
1993
1994static void alc889_intel_init_hook(struct hda_codec *codec)
1995{
1996 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001997 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001998}
1999
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002000static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002001{
2002 struct alc_spec *spec = codec->spec;
2003
2004 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
2005 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
2006 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
2007 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002008}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002009
2010/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002011 * ALC888 Acer Aspire 4930G model
2012 */
2013
2014static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
2015/* Front Mic: set to PIN_IN (empty by default) */
2016 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2017/* Unselect Front Mic by default in input mixer 3 */
2018 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002019/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002020 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2021/* Connect Internal HP to front */
2022 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2023 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2024 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2025/* Connect HP out to front */
2026 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2027 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2028 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie2e93292011-01-12 08:03:39 +01002029 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002030 { }
2031};
2032
Hector Martin3b315d72009-06-02 10:54:19 +02002033/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01002034 * ALC888 Acer Aspire 6530G model
2035 */
2036
2037static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01002038/* Route to built-in subwoofer as well as speakers */
2039 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2040 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2041 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2042 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002043/* Bias voltage on for external mic port */
2044 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02002045/* Front Mic: set to PIN_IN (empty by default) */
2046 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2047/* Unselect Front Mic by default in input mixer 3 */
2048 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002049/* Enable unsolicited event for HP jack */
2050 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2051/* Enable speaker output */
2052 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2053 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01002054 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002055/* Enable headphone output */
2056 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2057 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2058 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01002059 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002060 { }
2061};
2062
2063/*
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002064 *ALC888 Acer Aspire 7730G model
2065 */
2066
2067static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
2068/* Bias voltage on for external mic port */
2069 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
2070/* Front Mic: set to PIN_IN (empty by default) */
2071 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2072/* Unselect Front Mic by default in input mixer 3 */
2073 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2074/* Enable unsolicited event for HP jack */
2075 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2076/* Enable speaker output */
2077 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2078 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2079 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
2080/* Enable headphone output */
2081 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2082 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2083 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2084 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
2085/*Enable internal subwoofer */
2086 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2087 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2088 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
2089 {0x17, AC_VERB_SET_EAPD_BTLENABLE, 2},
2090 { }
2091};
2092
2093/*
Hector Martin018df412009-06-04 00:13:40 +02002094 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02002095 */
2096
Hector Martin018df412009-06-04 00:13:40 +02002097static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02002098/* Front Mic: set to PIN_IN (empty by default) */
2099 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2100/* Unselect Front Mic by default in input mixer 3 */
2101 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2102/* Enable unsolicited event for HP jack */
2103 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2104/* Connect Internal Front to Front */
2105 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2106 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2107 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2108/* Connect Internal Rear to Rear */
2109 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2110 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2111 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
2112/* Connect Internal CLFE to CLFE */
2113 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2114 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2115 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
2116/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02002117 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02002118 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2119 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2120/* Enable all DACs */
2121/* DAC DISABLE/MUTE 1? */
2122/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
2123 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
2124 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2125/* DAC DISABLE/MUTE 2? */
2126/* some bit here disables the other DACs. Init=0x4900 */
2127 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
2128 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02002129/* DMIC fix
2130 * This laptop has a stereo digital microphone. The mics are only 1cm apart
2131 * which makes the stereo useless. However, either the mic or the ALC889
2132 * makes the signal become a difference/sum signal instead of standard
2133 * stereo, which is annoying. So instead we flip this bit which makes the
2134 * codec replicate the sum signal to both channels, turning it into a
2135 * normal mono mic.
2136 */
2137/* DMIC_CONTROL? Init value = 0x0001 */
2138 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
2139 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02002140 { }
2141};
2142
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002143static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002144 /* Front mic only available on one ADC */
2145 {
2146 .num_items = 4,
2147 .items = {
2148 { "Mic", 0x0 },
2149 { "Line", 0x2 },
2150 { "CD", 0x4 },
2151 { "Front Mic", 0xb },
2152 },
2153 },
2154 {
2155 .num_items = 3,
2156 .items = {
2157 { "Mic", 0x0 },
2158 { "Line", 0x2 },
2159 { "CD", 0x4 },
2160 },
2161 }
2162};
2163
Tony Vroond2fd4b02009-06-21 00:40:10 +01002164static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2165 /* Interal mic only available on one ADC */
2166 {
Tony Vroon684a8842009-06-26 09:27:50 +01002167 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002168 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +01002169 { "Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002170 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002171 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002172 { "Input Mix", 0xa },
David Henningsson28c4edb2010-12-20 14:24:29 +01002173 { "Internal Mic", 0xb },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002174 },
2175 },
2176 {
Tony Vroon684a8842009-06-26 09:27:50 +01002177 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002178 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +01002179 { "Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002180 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002181 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002182 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002183 },
2184 }
2185};
2186
Hector Martin018df412009-06-04 00:13:40 +02002187static struct hda_input_mux alc889_capture_sources[3] = {
2188 /* Digital mic only available on first "ADC" */
2189 {
2190 .num_items = 5,
2191 .items = {
2192 { "Mic", 0x0 },
2193 { "Line", 0x2 },
2194 { "CD", 0x4 },
2195 { "Front Mic", 0xb },
2196 { "Input Mix", 0xa },
2197 },
2198 },
2199 {
2200 .num_items = 4,
2201 .items = {
2202 { "Mic", 0x0 },
2203 { "Line", 0x2 },
2204 { "CD", 0x4 },
2205 { "Input Mix", 0xa },
2206 },
2207 },
2208 {
2209 .num_items = 4,
2210 .items = {
2211 { "Mic", 0x0 },
2212 { "Line", 0x2 },
2213 { "CD", 0x4 },
2214 { "Input Mix", 0xa },
2215 },
2216 }
2217};
2218
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002219static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002220 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2221 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2222 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2223 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2224 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2225 HDA_OUTPUT),
2226 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2227 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2228 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2229 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2230 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2231 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2232 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2233 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2234 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2235 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01002236 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002237 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002238 { } /* end */
2239};
2240
Hector Martin556eea92009-12-20 22:51:23 +01002241static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2242 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2243 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2244 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2245 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2246 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2247 HDA_OUTPUT),
2248 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2249 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2250 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2251 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2252 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2253 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01002254 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hector Martin556eea92009-12-20 22:51:23 +01002255 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2256 { } /* end */
2257};
2258
2259
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002260static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002261{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002262 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002263
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002264 spec->autocfg.hp_pins[0] = 0x15;
2265 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01002266 spec->autocfg.speaker_pins[1] = 0x16;
2267 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002268}
2269
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002270static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02002271{
2272 struct alc_spec *spec = codec->spec;
2273
2274 spec->autocfg.hp_pins[0] = 0x15;
2275 spec->autocfg.speaker_pins[0] = 0x14;
2276 spec->autocfg.speaker_pins[1] = 0x16;
2277 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02002278}
2279
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002280static void alc888_acer_aspire_7730g_setup(struct hda_codec *codec)
2281{
2282 struct alc_spec *spec = codec->spec;
2283
2284 spec->autocfg.hp_pins[0] = 0x15;
2285 spec->autocfg.speaker_pins[0] = 0x14;
2286 spec->autocfg.speaker_pins[1] = 0x16;
2287 spec->autocfg.speaker_pins[2] = 0x17;
2288}
2289
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002290static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02002291{
2292 struct alc_spec *spec = codec->spec;
2293
2294 spec->autocfg.hp_pins[0] = 0x15;
2295 spec->autocfg.speaker_pins[0] = 0x14;
2296 spec->autocfg.speaker_pins[1] = 0x16;
2297 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02002298}
2299
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002300/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002301 * ALC880 3-stack model
2302 *
2303 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002304 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2305 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07002306 */
2307
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002308static hda_nid_t alc880_dac_nids[4] = {
2309 /* front, rear, clfe, rear_surr */
2310 0x02, 0x05, 0x04, 0x03
2311};
2312
2313static hda_nid_t alc880_adc_nids[3] = {
2314 /* ADC0-2 */
2315 0x07, 0x08, 0x09,
2316};
2317
2318/* The datasheet says the node 0x07 is connected from inputs,
2319 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01002320 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07002321 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002322static hda_nid_t alc880_adc_nids_alt[2] = {
2323 /* ADC1-2 */
2324 0x08, 0x09,
2325};
2326
2327#define ALC880_DIGOUT_NID 0x06
2328#define ALC880_DIGIN_NID 0x0a
2329
2330static struct hda_input_mux alc880_capture_source = {
2331 .num_items = 4,
2332 .items = {
2333 { "Mic", 0x0 },
2334 { "Front Mic", 0x3 },
2335 { "Line", 0x2 },
2336 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002337 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002338};
2339
2340/* channel source setting (2/6 channel selection for 3-stack) */
2341/* 2ch mode */
2342static struct hda_verb alc880_threestack_ch2_init[] = {
2343 /* set line-in to input, mute it */
2344 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2345 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2346 /* set mic-in to input vref 80%, mute it */
2347 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2348 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002349 { } /* end */
2350};
2351
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002352/* 6ch mode */
2353static struct hda_verb alc880_threestack_ch6_init[] = {
2354 /* set line-in to output, unmute it */
2355 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2356 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2357 /* set mic-in to output, unmute it */
2358 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2359 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2360 { } /* end */
2361};
2362
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002363static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002364 { 2, alc880_threestack_ch2_init },
2365 { 6, alc880_threestack_ch6_init },
2366};
2367
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002368static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002369 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002370 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002371 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002372 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002373 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2374 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002375 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2376 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002377 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2378 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2379 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2380 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2381 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2382 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2383 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2384 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002385 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002386 {
2387 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2388 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002389 .info = alc_ch_mode_info,
2390 .get = alc_ch_mode_get,
2391 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002392 },
2393 { } /* end */
2394};
2395
2396/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002397static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2398 struct snd_ctl_elem_info *uinfo)
2399{
2400 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2401 struct alc_spec *spec = codec->spec;
2402 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002403
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002404 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002405 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2406 HDA_INPUT);
2407 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002408 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002409 return err;
2410}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002411
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002412static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2413 unsigned int size, unsigned int __user *tlv)
2414{
2415 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2416 struct alc_spec *spec = codec->spec;
2417 int err;
2418
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002419 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002420 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2421 HDA_INPUT);
2422 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002423 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002424 return err;
2425}
2426
2427typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2428 struct snd_ctl_elem_value *ucontrol);
2429
2430static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2431 struct snd_ctl_elem_value *ucontrol,
2432 getput_call_t func)
2433{
2434 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2435 struct alc_spec *spec = codec->spec;
2436 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2437 int err;
2438
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002439 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002440 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2441 3, 0, HDA_INPUT);
2442 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002443 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002444 return err;
2445}
2446
2447static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2448 struct snd_ctl_elem_value *ucontrol)
2449{
2450 return alc_cap_getput_caller(kcontrol, ucontrol,
2451 snd_hda_mixer_amp_volume_get);
2452}
2453
2454static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2455 struct snd_ctl_elem_value *ucontrol)
2456{
2457 return alc_cap_getput_caller(kcontrol, ucontrol,
2458 snd_hda_mixer_amp_volume_put);
2459}
2460
2461/* capture mixer elements */
2462#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2463
2464static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2465 struct snd_ctl_elem_value *ucontrol)
2466{
2467 return alc_cap_getput_caller(kcontrol, ucontrol,
2468 snd_hda_mixer_amp_switch_get);
2469}
2470
2471static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2472 struct snd_ctl_elem_value *ucontrol)
2473{
2474 return alc_cap_getput_caller(kcontrol, ucontrol,
2475 snd_hda_mixer_amp_switch_put);
2476}
2477
Takashi Iwaia23b6882009-03-23 15:21:36 +01002478#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002479 { \
2480 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2481 .name = "Capture Switch", \
2482 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2483 .count = num, \
2484 .info = alc_cap_sw_info, \
2485 .get = alc_cap_sw_get, \
2486 .put = alc_cap_sw_put, \
2487 }, \
2488 { \
2489 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2490 .name = "Capture Volume", \
2491 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2492 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2493 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2494 .count = num, \
2495 .info = alc_cap_vol_info, \
2496 .get = alc_cap_vol_get, \
2497 .put = alc_cap_vol_put, \
2498 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002499 }
2500
2501#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002502 { \
2503 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2504 /* .name = "Capture Source", */ \
2505 .name = "Input Source", \
2506 .count = num, \
2507 .info = alc_mux_enum_info, \
2508 .get = alc_mux_enum_get, \
2509 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002510 }
2511
2512#define DEFINE_CAPMIX(num) \
2513static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2514 _DEFINE_CAPMIX(num), \
2515 _DEFINE_CAPSRC(num), \
2516 { } /* end */ \
2517}
2518
2519#define DEFINE_CAPMIX_NOSRC(num) \
2520static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2521 _DEFINE_CAPMIX(num), \
2522 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002523}
2524
2525/* up to three ADCs */
2526DEFINE_CAPMIX(1);
2527DEFINE_CAPMIX(2);
2528DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002529DEFINE_CAPMIX_NOSRC(1);
2530DEFINE_CAPMIX_NOSRC(2);
2531DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002532
2533/*
2534 * ALC880 5-stack model
2535 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002536 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2537 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002538 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2539 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2540 */
2541
2542/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002543static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002544 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002545 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002546 { } /* end */
2547};
2548
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002549/* channel source setting (6/8 channel selection for 5-stack) */
2550/* 6ch mode */
2551static struct hda_verb alc880_fivestack_ch6_init[] = {
2552 /* set line-in to input, mute it */
2553 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2554 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002555 { } /* end */
2556};
2557
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002558/* 8ch mode */
2559static struct hda_verb alc880_fivestack_ch8_init[] = {
2560 /* set line-in to output, unmute it */
2561 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2562 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2563 { } /* end */
2564};
2565
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002566static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002567 { 6, alc880_fivestack_ch6_init },
2568 { 8, alc880_fivestack_ch8_init },
2569};
2570
2571
2572/*
2573 * ALC880 6-stack model
2574 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002575 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2576 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002577 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2578 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2579 */
2580
2581static hda_nid_t alc880_6st_dac_nids[4] = {
2582 /* front, rear, clfe, rear_surr */
2583 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002584};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002585
2586static struct hda_input_mux alc880_6stack_capture_source = {
2587 .num_items = 4,
2588 .items = {
2589 { "Mic", 0x0 },
2590 { "Front Mic", 0x1 },
2591 { "Line", 0x2 },
2592 { "CD", 0x4 },
2593 },
2594};
2595
2596/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002597static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002598 { 8, NULL },
2599};
2600
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002601static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002602 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002603 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002604 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002605 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002606 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2607 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002608 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2609 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002610 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002611 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002612 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2613 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2614 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2615 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2616 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2617 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2618 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2619 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002620 {
2621 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2622 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002623 .info = alc_ch_mode_info,
2624 .get = alc_ch_mode_get,
2625 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002626 },
2627 { } /* end */
2628};
2629
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002630
2631/*
2632 * ALC880 W810 model
2633 *
2634 * W810 has rear IO for:
2635 * Front (DAC 02)
2636 * Surround (DAC 03)
2637 * Center/LFE (DAC 04)
2638 * Digital out (06)
2639 *
2640 * The system also has a pair of internal speakers, and a headphone jack.
2641 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002642 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002643 * There is a variable resistor to control the speaker or headphone
2644 * volume. This is a hardware-only device without a software API.
2645 *
2646 * Plugging headphones in will disable the internal speakers. This is
2647 * implemented in hardware, not via the driver using jack sense. In
2648 * a similar fashion, plugging into the rear socket marked "front" will
2649 * disable both the speakers and headphones.
2650 *
2651 * For input, there's a microphone jack, and an "audio in" jack.
2652 * These may not do anything useful with this driver yet, because I
2653 * haven't setup any initialization verbs for these yet...
2654 */
2655
2656static hda_nid_t alc880_w810_dac_nids[3] = {
2657 /* front, rear/surround, clfe */
2658 0x02, 0x03, 0x04
2659};
2660
2661/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002662static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002663 { 6, NULL }
2664};
2665
2666/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002667static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002668 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002669 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002670 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002671 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002672 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2673 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002674 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2675 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002676 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2677 { } /* end */
2678};
2679
2680
2681/*
2682 * Z710V model
2683 *
2684 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002685 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2686 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002687 */
2688
2689static hda_nid_t alc880_z71v_dac_nids[1] = {
2690 0x02
2691};
2692#define ALC880_Z71V_HP_DAC 0x03
2693
2694/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002695static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002696 { 2, NULL }
2697};
2698
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002699static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002700 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002701 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002702 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002703 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002704 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2705 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2706 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2707 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2708 { } /* end */
2709};
2710
2711
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002712/*
2713 * ALC880 F1734 model
2714 *
2715 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2716 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2717 */
2718
2719static hda_nid_t alc880_f1734_dac_nids[1] = {
2720 0x03
2721};
2722#define ALC880_F1734_HP_DAC 0x02
2723
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002724static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002725 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002726 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002727 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2728 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002729 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2730 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002731 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2732 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002733 { } /* end */
2734};
2735
Takashi Iwai937b4162008-02-11 14:52:36 +01002736static struct hda_input_mux alc880_f1734_capture_source = {
2737 .num_items = 2,
2738 .items = {
2739 { "Mic", 0x1 },
2740 { "CD", 0x4 },
2741 },
2742};
2743
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002744
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002745/*
2746 * ALC880 ASUS model
2747 *
2748 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2749 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2750 * Mic = 0x18, Line = 0x1a
2751 */
2752
2753#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2754#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2755
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002756static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002757 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002758 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002759 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002760 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002761 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2762 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002763 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2764 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002765 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2766 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2767 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2768 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2769 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2770 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002771 {
2772 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2773 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002774 .info = alc_ch_mode_info,
2775 .get = alc_ch_mode_get,
2776 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002777 },
2778 { } /* end */
2779};
2780
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002781/*
2782 * ALC880 ASUS W1V model
2783 *
2784 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2785 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2786 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2787 */
2788
2789/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002790static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002791 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2792 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002793 { } /* end */
2794};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002795
Kailang Yangdf694da2005-12-05 19:42:22 +01002796/* TCL S700 */
2797static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2798 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2799 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2800 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2801 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2802 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2803 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2804 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2805 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2806 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002807 { } /* end */
2808};
2809
Kailang Yangccc656c2006-10-17 12:32:26 +02002810/* Uniwill */
2811static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002812 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2813 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2814 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2815 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002816 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2817 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2818 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2819 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2820 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2821 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2822 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2823 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2824 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2825 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2826 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2827 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002828 {
2829 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2830 .name = "Channel Mode",
2831 .info = alc_ch_mode_info,
2832 .get = alc_ch_mode_get,
2833 .put = alc_ch_mode_put,
2834 },
2835 { } /* end */
2836};
2837
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002838static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2839 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2840 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2841 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2842 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2843 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2844 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +01002845 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2846 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01002847 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2848 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002849 { } /* end */
2850};
2851
Kailang Yangccc656c2006-10-17 12:32:26 +02002852static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002853 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2854 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2855 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2856 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002857 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2858 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2859 { } /* end */
2860};
2861
Linus Torvalds1da177e2005-04-16 15:20:36 -07002862/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002863 * virtual master controls
2864 */
2865
2866/*
2867 * slave controls for virtual master
2868 */
2869static const char *alc_slave_vols[] = {
2870 "Front Playback Volume",
2871 "Surround Playback Volume",
2872 "Center Playback Volume",
2873 "LFE Playback Volume",
2874 "Side Playback Volume",
2875 "Headphone Playback Volume",
2876 "Speaker Playback Volume",
2877 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002878 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002879 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002880 NULL,
2881};
2882
2883static const char *alc_slave_sws[] = {
2884 "Front Playback Switch",
2885 "Surround Playback Switch",
2886 "Center Playback Switch",
2887 "LFE Playback Switch",
2888 "Side Playback Switch",
2889 "Headphone Playback Switch",
2890 "Speaker Playback Switch",
2891 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002892 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002893 "Line-Out Playback Switch",
2894 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002895 NULL,
2896};
2897
2898/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002899 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002900 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002901
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002902#define NID_MAPPING (-1)
2903
2904#define SUBDEV_SPEAKER_ (0 << 6)
2905#define SUBDEV_HP_ (1 << 6)
2906#define SUBDEV_LINE_ (2 << 6)
2907#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2908#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2909#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2910
Takashi Iwai603c4012008-07-30 15:01:44 +02002911static void alc_free_kctls(struct hda_codec *codec);
2912
Takashi Iwai67d634c2009-11-16 15:35:59 +01002913#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002914/* additional beep mixers; the actual parameters are overwritten at build */
2915static struct snd_kcontrol_new alc_beep_mixer[] = {
2916 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002917 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002918 { } /* end */
2919};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002920#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002921
Linus Torvalds1da177e2005-04-16 15:20:36 -07002922static int alc_build_controls(struct hda_codec *codec)
2923{
2924 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02002925 struct snd_kcontrol *kctl = NULL;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002926 struct snd_kcontrol_new *knew;
2927 int i, j, err;
2928 unsigned int u;
2929 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002930
2931 for (i = 0; i < spec->num_mixers; i++) {
2932 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2933 if (err < 0)
2934 return err;
2935 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002936 if (spec->cap_mixer) {
2937 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2938 if (err < 0)
2939 return err;
2940 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002941 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002942 err = snd_hda_create_spdif_out_ctls(codec,
2943 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002944 if (err < 0)
2945 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002946 if (!spec->no_analog) {
2947 err = snd_hda_create_spdif_share_sw(codec,
2948 &spec->multiout);
2949 if (err < 0)
2950 return err;
2951 spec->multiout.share_spdif = 1;
2952 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002953 }
2954 if (spec->dig_in_nid) {
2955 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2956 if (err < 0)
2957 return err;
2958 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002959
Takashi Iwai67d634c2009-11-16 15:35:59 +01002960#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002961 /* create beep controls if needed */
2962 if (spec->beep_amp) {
2963 struct snd_kcontrol_new *knew;
2964 for (knew = alc_beep_mixer; knew->name; knew++) {
2965 struct snd_kcontrol *kctl;
2966 kctl = snd_ctl_new1(knew, codec);
2967 if (!kctl)
2968 return -ENOMEM;
2969 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002970 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002971 if (err < 0)
2972 return err;
2973 }
2974 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002975#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002976
Takashi Iwai2134ea42008-01-10 16:53:55 +01002977 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002978 if (!spec->no_analog &&
2979 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002980 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002981 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002982 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002983 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002984 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002985 if (err < 0)
2986 return err;
2987 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002988 if (!spec->no_analog &&
2989 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002990 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2991 NULL, alc_slave_sws);
2992 if (err < 0)
2993 return err;
2994 }
2995
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002996 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02002997 if (spec->capsrc_nids || spec->adc_nids) {
2998 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2999 if (!kctl)
3000 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
3001 for (i = 0; kctl && i < kctl->count; i++) {
3002 hda_nid_t *nids = spec->capsrc_nids;
3003 if (!nids)
3004 nids = spec->adc_nids;
3005 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
3006 if (err < 0)
3007 return err;
3008 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003009 }
3010 if (spec->cap_mixer) {
3011 const char *kname = kctl ? kctl->id.name : NULL;
3012 for (knew = spec->cap_mixer; knew->name; knew++) {
3013 if (kname && strcmp(knew->name, kname) == 0)
3014 continue;
3015 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3016 for (i = 0; kctl && i < kctl->count; i++) {
3017 err = snd_hda_add_nid(codec, kctl, i,
3018 spec->adc_nids[i]);
3019 if (err < 0)
3020 return err;
3021 }
3022 }
3023 }
3024
3025 /* other nid->control mapping */
3026 for (i = 0; i < spec->num_mixers; i++) {
3027 for (knew = spec->mixers[i]; knew->name; knew++) {
3028 if (knew->iface != NID_MAPPING)
3029 continue;
3030 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3031 if (kctl == NULL)
3032 continue;
3033 u = knew->subdevice;
3034 for (j = 0; j < 4; j++, u >>= 8) {
3035 nid = u & 0x3f;
3036 if (nid == 0)
3037 continue;
3038 switch (u & 0xc0) {
3039 case SUBDEV_SPEAKER_:
3040 nid = spec->autocfg.speaker_pins[nid];
3041 break;
3042 case SUBDEV_LINE_:
3043 nid = spec->autocfg.line_out_pins[nid];
3044 break;
3045 case SUBDEV_HP_:
3046 nid = spec->autocfg.hp_pins[nid];
3047 break;
3048 default:
3049 continue;
3050 }
3051 err = snd_hda_add_nid(codec, kctl, 0, nid);
3052 if (err < 0)
3053 return err;
3054 }
3055 u = knew->private_value;
3056 for (j = 0; j < 4; j++, u >>= 8) {
3057 nid = u & 0xff;
3058 if (nid == 0)
3059 continue;
3060 err = snd_hda_add_nid(codec, kctl, 0, nid);
3061 if (err < 0)
3062 return err;
3063 }
3064 }
3065 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01003066
3067 alc_free_kctls(codec); /* no longer needed */
3068
Linus Torvalds1da177e2005-04-16 15:20:36 -07003069 return 0;
3070}
3071
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003072
Linus Torvalds1da177e2005-04-16 15:20:36 -07003073/*
3074 * initialize the codec volumes, etc
3075 */
3076
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003077/*
3078 * generic initialization of ADC, input mixers and output mixers
3079 */
3080static struct hda_verb alc880_volume_init_verbs[] = {
3081 /*
3082 * Unmute ADC0-2 and set the default input to mic-in
3083 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003084 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003085 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003086 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003087 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003088 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003089 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003090
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003091 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3092 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003093 * Note: PASD motherboards uses the Line In 2 as the input for front
3094 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003095 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003096 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003097 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3098 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3099 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3101 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003104
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003105 /*
3106 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003107 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003108 /* set vol=0 to output mixers */
3109 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3110 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3111 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3112 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3113 /* set up input amps for analog loopback */
3114 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003115 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3116 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003117 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3118 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003119 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3120 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003121 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3122 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003123
3124 { }
3125};
3126
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003127/*
3128 * 3-stack pin configuration:
3129 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
3130 */
3131static struct hda_verb alc880_pin_3stack_init_verbs[] = {
3132 /*
3133 * preset connection lists of input pins
3134 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3135 */
3136 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3137 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3138 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3139
3140 /*
3141 * Set pin mode and muting
3142 */
3143 /* set front pin widgets 0x14 for output */
3144 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3145 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3146 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3147 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3148 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3149 /* Mic2 (as headphone out) for HP output */
3150 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3151 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3152 /* Line In pin widget for input */
3153 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3154 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3155 /* Line2 (as front mic) pin widget for input and vref at 80% */
3156 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3157 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3158 /* CD pin widget for input */
3159 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3160
3161 { }
3162};
3163
3164/*
3165 * 5-stack pin configuration:
3166 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3167 * line-in/side = 0x1a, f-mic = 0x1b
3168 */
3169static struct hda_verb alc880_pin_5stack_init_verbs[] = {
3170 /*
3171 * preset connection lists of input pins
3172 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3173 */
3174 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3175 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3176
3177 /*
3178 * Set pin mode and muting
3179 */
3180 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02003181 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3182 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3183 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3184 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003185 /* unmute pins for output (no gain on this amp) */
3186 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3187 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3188 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3189 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3190
Linus Torvalds1da177e2005-04-16 15:20:36 -07003191 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003192 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003193 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3194 /* Mic2 (as headphone out) for HP output */
3195 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003196 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003197 /* Line In pin widget for input */
3198 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3199 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3200 /* Line2 (as front mic) pin widget for input and vref at 80% */
3201 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3202 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3203 /* CD pin widget for input */
3204 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003205
3206 { }
3207};
3208
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003209/*
3210 * W810 pin configuration:
3211 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3212 */
3213static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003214 /* hphone/speaker input selector: front DAC */
3215 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3216
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003217 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3218 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3219 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3220 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3221 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3222 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3223
3224 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003225 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003226
Linus Torvalds1da177e2005-04-16 15:20:36 -07003227 { }
3228};
3229
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003230/*
3231 * Z71V pin configuration:
3232 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3233 */
3234static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003235 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003236 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02003237 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003238 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003239
Takashi Iwai16ded522005-06-10 19:58:24 +02003240 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003241 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003242 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003243 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003244
3245 { }
3246};
3247
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003248/*
3249 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003250 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3251 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003252 */
3253static struct hda_verb alc880_pin_6stack_init_verbs[] = {
3254 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3255
Takashi Iwai16ded522005-06-10 19:58:24 +02003256 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003257 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003258 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003259 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003260 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003261 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003262 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003263 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3264
Takashi Iwai16ded522005-06-10 19:58:24 +02003265 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003266 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003267 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003268 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003269 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003270 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003271 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003272 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003273 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003274
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003275 { }
3276};
Takashi Iwai16ded522005-06-10 19:58:24 +02003277
Kailang Yangccc656c2006-10-17 12:32:26 +02003278/*
3279 * Uniwill pin configuration:
3280 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3281 * line = 0x1a
3282 */
3283static struct hda_verb alc880_uniwill_init_verbs[] = {
3284 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3285
3286 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3287 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3288 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3289 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3290 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3291 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3292 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3293 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3294 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3295 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3296 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3297 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3298 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3299 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3300
3301 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3302 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3303 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3304 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3305 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3306 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3307 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3308 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3309 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3310
3311 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3312 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3313
3314 { }
3315};
3316
3317/*
3318* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003319* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003320 */
3321static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3322 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3323
3324 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3325 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3326 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3327 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3328 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3329 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3330 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3331 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3332 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3333 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3335 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3336
3337 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3338 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3339 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3340 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3341 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3342 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3343
3344 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3345 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3346
3347 { }
3348};
3349
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003350static struct hda_verb alc880_beep_init_verbs[] = {
3351 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3352 { }
3353};
3354
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003355/* auto-toggle front mic */
Anisse Astiereeb43382010-12-16 12:19:47 +01003356static void alc88x_simple_mic_automute(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003357{
3358 unsigned int present;
3359 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003360
Wu Fengguang864f92b2009-11-18 12:38:02 +08003361 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003362 bits = present ? HDA_AMP_MUTE : 0;
3363 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003364}
3365
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003366static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003367{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003368 struct alc_spec *spec = codec->spec;
3369
3370 spec->autocfg.hp_pins[0] = 0x14;
3371 spec->autocfg.speaker_pins[0] = 0x15;
3372 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003373}
3374
3375static void alc880_uniwill_init_hook(struct hda_codec *codec)
3376{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003377 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01003378 alc88x_simple_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003379}
3380
3381static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3382 unsigned int res)
3383{
3384 /* Looks like the unsol event is incompatible with the standard
3385 * definition. 4bit tag is placed at 28 bit!
3386 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003387 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003388 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01003389 alc88x_simple_mic_automute(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003390 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003391 default:
3392 alc_automute_amp_unsol_event(codec, res);
3393 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003394 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003395}
3396
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003397static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003398{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003399 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003400
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003401 spec->autocfg.hp_pins[0] = 0x14;
3402 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02003403}
3404
3405static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3406{
3407 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003408
Kailang Yangccc656c2006-10-17 12:32:26 +02003409 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003410 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3411 present &= HDA_AMP_VOLMASK;
3412 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3413 HDA_AMP_VOLMASK, present);
3414 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3415 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003416}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003417
Kailang Yangccc656c2006-10-17 12:32:26 +02003418static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3419 unsigned int res)
3420{
3421 /* Looks like the unsol event is incompatible with the standard
3422 * definition. 4bit tag is placed at 28 bit!
3423 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003424 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003425 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003426 else
3427 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003428}
3429
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003430/*
3431 * F1734 pin configuration:
3432 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3433 */
3434static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003435 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003436 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3437 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3438 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3439 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3440
3441 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3442 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3443 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3444 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3445
3446 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3447 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003448 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003449 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3450 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3451 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3452 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3453 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3454 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003455
Takashi Iwai937b4162008-02-11 14:52:36 +01003456 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3457 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3458
Takashi Iwai16ded522005-06-10 19:58:24 +02003459 { }
3460};
3461
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003462/*
3463 * ASUS pin configuration:
3464 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3465 */
3466static struct hda_verb alc880_pin_asus_init_verbs[] = {
3467 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3468 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3469 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3470 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3471
3472 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3473 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3474 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3475 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3476 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3477 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3478 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3479 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3480
3481 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3482 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3483 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3484 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3485 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3486 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3487 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3488 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3489 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003490
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003491 { }
3492};
3493
3494/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003495#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3496#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003497#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003498
Kailang Yangdf694da2005-12-05 19:42:22 +01003499/* Clevo m520g init */
3500static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3501 /* headphone output */
3502 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3503 /* line-out */
3504 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3505 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3506 /* Line-in */
3507 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3508 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3509 /* CD */
3510 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3511 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3512 /* Mic1 (rear panel) */
3513 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3514 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3515 /* Mic2 (front panel) */
3516 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3517 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3518 /* headphone */
3519 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3520 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3521 /* change to EAPD mode */
3522 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3523 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3524
3525 { }
3526};
3527
3528static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003529 /* change to EAPD mode */
3530 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3531 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3532
Kailang Yangdf694da2005-12-05 19:42:22 +01003533 /* Headphone output */
3534 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3535 /* Front output*/
3536 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3537 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3538
3539 /* Line In pin widget for input */
3540 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3541 /* CD pin widget for input */
3542 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3543 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3544 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3545
3546 /* change to EAPD mode */
3547 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3548 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3549
3550 { }
3551};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003552
3553/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003554 * LG m1 express dual
3555 *
3556 * Pin assignment:
3557 * Rear Line-In/Out (blue): 0x14
3558 * Build-in Mic-In: 0x15
3559 * Speaker-out: 0x17
3560 * HP-Out (green): 0x1b
3561 * Mic-In/Out (red): 0x19
3562 * SPDIF-Out: 0x1e
3563 */
3564
3565/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3566static hda_nid_t alc880_lg_dac_nids[3] = {
3567 0x05, 0x02, 0x03
3568};
3569
3570/* seems analog CD is not working */
3571static struct hda_input_mux alc880_lg_capture_source = {
3572 .num_items = 3,
3573 .items = {
3574 { "Mic", 0x1 },
3575 { "Line", 0x5 },
3576 { "Internal Mic", 0x6 },
3577 },
3578};
3579
3580/* 2,4,6 channel modes */
3581static struct hda_verb alc880_lg_ch2_init[] = {
3582 /* set line-in and mic-in to input */
3583 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3584 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3585 { }
3586};
3587
3588static struct hda_verb alc880_lg_ch4_init[] = {
3589 /* set line-in to out and mic-in to input */
3590 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3591 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3592 { }
3593};
3594
3595static struct hda_verb alc880_lg_ch6_init[] = {
3596 /* set line-in and mic-in to output */
3597 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3598 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3599 { }
3600};
3601
3602static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3603 { 2, alc880_lg_ch2_init },
3604 { 4, alc880_lg_ch4_init },
3605 { 6, alc880_lg_ch6_init },
3606};
3607
3608static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003609 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3610 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003611 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3612 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3613 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3614 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3615 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3616 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3617 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3618 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3619 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3620 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3621 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3622 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3623 {
3624 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3625 .name = "Channel Mode",
3626 .info = alc_ch_mode_info,
3627 .get = alc_ch_mode_get,
3628 .put = alc_ch_mode_put,
3629 },
3630 { } /* end */
3631};
3632
3633static struct hda_verb alc880_lg_init_verbs[] = {
3634 /* set capture source to mic-in */
3635 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3636 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3637 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3638 /* mute all amp mixer inputs */
3639 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003642 /* line-in to input */
3643 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3644 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3645 /* built-in mic */
3646 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3647 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3648 /* speaker-out */
3649 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3650 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3651 /* mic-in to input */
3652 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3653 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3654 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3655 /* HP-out */
3656 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3657 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3658 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3659 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003660 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003661 { }
3662};
3663
3664/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003665static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003666{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003667 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003668
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003669 spec->autocfg.hp_pins[0] = 0x1b;
3670 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003671}
3672
3673/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003674 * LG LW20
3675 *
3676 * Pin assignment:
3677 * Speaker-out: 0x14
3678 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003679 * Built-in Mic-In: 0x19
3680 * Line-In: 0x1b
3681 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003682 * SPDIF-Out: 0x1e
3683 */
3684
Takashi Iwaid6815182006-03-23 16:06:23 +01003685static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003686 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003687 .items = {
3688 { "Mic", 0x0 },
3689 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003690 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003691 },
3692};
3693
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003694#define alc880_lg_lw_modes alc880_threestack_modes
3695
Takashi Iwaid6815182006-03-23 16:06:23 +01003696static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003697 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3698 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3699 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3700 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3701 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3702 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3703 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3704 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3705 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3706 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3709 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3710 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003711 {
3712 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3713 .name = "Channel Mode",
3714 .info = alc_ch_mode_info,
3715 .get = alc_ch_mode_get,
3716 .put = alc_ch_mode_put,
3717 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003718 { } /* end */
3719};
3720
3721static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003722 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3723 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3724 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3725
Takashi Iwaid6815182006-03-23 16:06:23 +01003726 /* set capture source to mic-in */
3727 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3728 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3729 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003730 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003731 /* speaker-out */
3732 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3733 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3734 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003735 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3736 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3737 /* mic-in to input */
3738 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3739 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3740 /* built-in mic */
3741 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3742 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3743 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003744 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003745 { }
3746};
3747
3748/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003749static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003750{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003751 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003752
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003753 spec->autocfg.hp_pins[0] = 0x1b;
3754 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003755}
3756
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003757static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3758 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3759 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3760 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3761 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3762 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3763 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3764 { } /* end */
3765};
3766
3767static struct hda_input_mux alc880_medion_rim_capture_source = {
3768 .num_items = 2,
3769 .items = {
3770 { "Mic", 0x0 },
3771 { "Internal Mic", 0x1 },
3772 },
3773};
3774
3775static struct hda_verb alc880_medion_rim_init_verbs[] = {
3776 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3777
3778 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3779 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3780
3781 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3782 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3783 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3784 /* Mic2 (as headphone out) for HP output */
3785 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3786 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3787 /* Internal Speaker */
3788 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3789 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3790
3791 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3792 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3793
3794 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3795 { }
3796};
3797
3798/* toggle speaker-output according to the hp-jack state */
3799static void alc880_medion_rim_automute(struct hda_codec *codec)
3800{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003801 struct alc_spec *spec = codec->spec;
3802 alc_automute_amp(codec);
3803 /* toggle EAPD */
3804 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003805 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3806 else
3807 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3808}
3809
3810static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3811 unsigned int res)
3812{
3813 /* Looks like the unsol event is incompatible with the standard
3814 * definition. 4bit tag is placed at 28 bit!
3815 */
3816 if ((res >> 28) == ALC880_HP_EVENT)
3817 alc880_medion_rim_automute(codec);
3818}
3819
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003820static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003821{
3822 struct alc_spec *spec = codec->spec;
3823
3824 spec->autocfg.hp_pins[0] = 0x14;
3825 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003826}
3827
Takashi Iwaicb53c622007-08-10 17:21:45 +02003828#ifdef CONFIG_SND_HDA_POWER_SAVE
3829static struct hda_amp_list alc880_loopbacks[] = {
3830 { 0x0b, HDA_INPUT, 0 },
3831 { 0x0b, HDA_INPUT, 1 },
3832 { 0x0b, HDA_INPUT, 2 },
3833 { 0x0b, HDA_INPUT, 3 },
3834 { 0x0b, HDA_INPUT, 4 },
3835 { } /* end */
3836};
3837
3838static struct hda_amp_list alc880_lg_loopbacks[] = {
3839 { 0x0b, HDA_INPUT, 1 },
3840 { 0x0b, HDA_INPUT, 6 },
3841 { 0x0b, HDA_INPUT, 7 },
3842 { } /* end */
3843};
3844#endif
3845
Takashi Iwaid6815182006-03-23 16:06:23 +01003846/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003847 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003848 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003849
Linus Torvalds1da177e2005-04-16 15:20:36 -07003850static int alc_init(struct hda_codec *codec)
3851{
3852 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003853 unsigned int i;
3854
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003855 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003856 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003857
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003858 for (i = 0; i < spec->num_init_verbs; i++)
3859 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003860
3861 if (spec->init_hook)
3862 spec->init_hook(codec);
3863
Takashi Iwai9e5341b2010-09-21 09:57:06 +02003864 hda_call_check_power_status(codec, 0x01);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003865 return 0;
3866}
3867
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003868static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3869{
3870 struct alc_spec *spec = codec->spec;
3871
3872 if (spec->unsol_event)
3873 spec->unsol_event(codec, res);
3874}
3875
Takashi Iwaicb53c622007-08-10 17:21:45 +02003876#ifdef CONFIG_SND_HDA_POWER_SAVE
3877static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3878{
3879 struct alc_spec *spec = codec->spec;
3880 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3881}
3882#endif
3883
Linus Torvalds1da177e2005-04-16 15:20:36 -07003884/*
3885 * Analog playback callbacks
3886 */
3887static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3888 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003889 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003890{
3891 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003892 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3893 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003894}
3895
3896static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3897 struct hda_codec *codec,
3898 unsigned int stream_tag,
3899 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003900 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003901{
3902 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003903 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3904 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003905}
3906
3907static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3908 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003909 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003910{
3911 struct alc_spec *spec = codec->spec;
3912 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3913}
3914
3915/*
3916 * Digital out
3917 */
3918static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3919 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003920 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003921{
3922 struct alc_spec *spec = codec->spec;
3923 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3924}
3925
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003926static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3927 struct hda_codec *codec,
3928 unsigned int stream_tag,
3929 unsigned int format,
3930 struct snd_pcm_substream *substream)
3931{
3932 struct alc_spec *spec = codec->spec;
3933 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3934 stream_tag, format, substream);
3935}
3936
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003937static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3938 struct hda_codec *codec,
3939 struct snd_pcm_substream *substream)
3940{
3941 struct alc_spec *spec = codec->spec;
3942 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3943}
3944
Linus Torvalds1da177e2005-04-16 15:20:36 -07003945static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3946 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003947 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003948{
3949 struct alc_spec *spec = codec->spec;
3950 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3951}
3952
3953/*
3954 * Analog capture
3955 */
Takashi Iwai63300792008-01-24 15:31:36 +01003956static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003957 struct hda_codec *codec,
3958 unsigned int stream_tag,
3959 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003960 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003961{
3962 struct alc_spec *spec = codec->spec;
3963
Takashi Iwai63300792008-01-24 15:31:36 +01003964 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003965 stream_tag, 0, format);
3966 return 0;
3967}
3968
Takashi Iwai63300792008-01-24 15:31:36 +01003969static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003970 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003971 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003972{
3973 struct alc_spec *spec = codec->spec;
3974
Takashi Iwai888afa12008-03-18 09:57:50 +01003975 snd_hda_codec_cleanup_stream(codec,
3976 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003977 return 0;
3978}
3979
Takashi Iwai840b64c2010-07-13 22:49:01 +02003980/* analog capture with dynamic dual-adc changes */
3981static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3982 struct hda_codec *codec,
3983 unsigned int stream_tag,
3984 unsigned int format,
3985 struct snd_pcm_substream *substream)
3986{
3987 struct alc_spec *spec = codec->spec;
3988 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
3989 spec->cur_adc_stream_tag = stream_tag;
3990 spec->cur_adc_format = format;
3991 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
3992 return 0;
3993}
3994
3995static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3996 struct hda_codec *codec,
3997 struct snd_pcm_substream *substream)
3998{
3999 struct alc_spec *spec = codec->spec;
4000 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
4001 spec->cur_adc = 0;
4002 return 0;
4003}
4004
4005static struct hda_pcm_stream dualmic_pcm_analog_capture = {
4006 .substreams = 1,
4007 .channels_min = 2,
4008 .channels_max = 2,
4009 .nid = 0, /* fill later */
4010 .ops = {
4011 .prepare = dualmic_capture_pcm_prepare,
4012 .cleanup = dualmic_capture_pcm_cleanup
4013 },
4014};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004015
4016/*
4017 */
4018static struct hda_pcm_stream alc880_pcm_analog_playback = {
4019 .substreams = 1,
4020 .channels_min = 2,
4021 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004022 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004023 .ops = {
4024 .open = alc880_playback_pcm_open,
4025 .prepare = alc880_playback_pcm_prepare,
4026 .cleanup = alc880_playback_pcm_cleanup
4027 },
4028};
4029
4030static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01004031 .substreams = 1,
4032 .channels_min = 2,
4033 .channels_max = 2,
4034 /* NID is set in alc_build_pcms */
4035};
4036
4037static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
4038 .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_capture = {
4045 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004046 .channels_min = 2,
4047 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004048 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004049 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01004050 .prepare = alc880_alt_capture_pcm_prepare,
4051 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004052 },
4053};
4054
4055static struct hda_pcm_stream alc880_pcm_digital_playback = {
4056 .substreams = 1,
4057 .channels_min = 2,
4058 .channels_max = 2,
4059 /* NID is set in alc_build_pcms */
4060 .ops = {
4061 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02004062 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01004063 .prepare = alc880_dig_playback_pcm_prepare,
4064 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004065 },
4066};
4067
4068static struct hda_pcm_stream alc880_pcm_digital_capture = {
4069 .substreams = 1,
4070 .channels_min = 2,
4071 .channels_max = 2,
4072 /* NID is set in alc_build_pcms */
4073};
4074
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004075/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01004076static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004077 .substreams = 0,
4078 .channels_min = 0,
4079 .channels_max = 0,
4080};
4081
Linus Torvalds1da177e2005-04-16 15:20:36 -07004082static int alc_build_pcms(struct hda_codec *codec)
4083{
4084 struct alc_spec *spec = codec->spec;
4085 struct hda_pcm *info = spec->pcm_rec;
4086 int i;
4087
4088 codec->num_pcms = 1;
4089 codec->pcm_info = info;
4090
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004091 if (spec->no_analog)
4092 goto skip_analog;
4093
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004094 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
4095 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004096 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01004097
Takashi Iwai4a471b72005-12-07 13:56:29 +01004098 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004099 if (snd_BUG_ON(!spec->multiout.dac_nids))
4100 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004101 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
4102 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
4103 }
4104 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004105 if (snd_BUG_ON(!spec->adc_nids))
4106 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004107 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
4108 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
4109 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004110
Takashi Iwai4a471b72005-12-07 13:56:29 +01004111 if (spec->channel_mode) {
4112 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
4113 for (i = 0; i < spec->num_channel_mode; i++) {
4114 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
4115 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
4116 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004117 }
4118 }
4119
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004120 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02004121 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004122 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004123 snprintf(spec->stream_name_digital,
4124 sizeof(spec->stream_name_digital),
4125 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02004126 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08004127 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004128 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004129 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01004130 if (spec->dig_out_type)
4131 info->pcm_type = spec->dig_out_type;
4132 else
4133 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004134 if (spec->multiout.dig_out_nid &&
4135 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004136 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
4137 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
4138 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004139 if (spec->dig_in_nid &&
4140 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004141 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
4142 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
4143 }
Takashi Iwai963f8032008-08-11 10:04:40 +02004144 /* FIXME: do we need this for all Realtek codec models? */
4145 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004146 }
4147
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004148 if (spec->no_analog)
4149 return 0;
4150
Takashi Iwaie08a0072006-09-07 17:52:14 +02004151 /* If the use of more than one ADC is requested for the current
4152 * model, configure a second analog capture-only PCM.
4153 */
4154 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01004155 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
4156 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02004157 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004158 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004159 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01004160 if (spec->alt_dac_nid) {
4161 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4162 *spec->stream_analog_alt_playback;
4163 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
4164 spec->alt_dac_nid;
4165 } else {
4166 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4167 alc_pcm_null_stream;
4168 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
4169 }
4170 if (spec->num_adc_nids > 1) {
4171 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4172 *spec->stream_analog_alt_capture;
4173 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
4174 spec->adc_nids[1];
4175 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
4176 spec->num_adc_nids - 1;
4177 } else {
4178 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4179 alc_pcm_null_stream;
4180 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004181 }
4182 }
4183
Linus Torvalds1da177e2005-04-16 15:20:36 -07004184 return 0;
4185}
4186
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004187static inline void alc_shutup(struct hda_codec *codec)
4188{
4189 snd_hda_shutup_pins(codec);
4190}
4191
Takashi Iwai603c4012008-07-30 15:01:44 +02004192static void alc_free_kctls(struct hda_codec *codec)
4193{
4194 struct alc_spec *spec = codec->spec;
4195
4196 if (spec->kctls.list) {
4197 struct snd_kcontrol_new *kctl = spec->kctls.list;
4198 int i;
4199 for (i = 0; i < spec->kctls.used; i++)
4200 kfree(kctl[i].name);
4201 }
4202 snd_array_free(&spec->kctls);
4203}
4204
Linus Torvalds1da177e2005-04-16 15:20:36 -07004205static void alc_free(struct hda_codec *codec)
4206{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004207 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004208
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004209 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004210 return;
4211
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004212 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02004213 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004214 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004215 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004216}
4217
Hector Martinf5de24b2009-12-20 22:51:31 +01004218#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05004219static void alc_power_eapd(struct hda_codec *codec)
4220{
4221 /* We currently only handle front, HP */
4222 switch (codec->vendor_id) {
4223 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004224 set_eapd(codec, 0x0f, 0);
4225 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004226 break;
4227 case 0x10ec0262:
4228 case 0x10ec0267:
4229 case 0x10ec0268:
4230 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004231 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05004232 case 0x10ec0272:
4233 case 0x10ec0660:
4234 case 0x10ec0662:
4235 case 0x10ec0663:
4236 case 0x10ec0862:
4237 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004238 set_eapd(codec, 0x14, 0);
4239 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004240 break;
4241 }
4242}
4243
Hector Martinf5de24b2009-12-20 22:51:31 +01004244static int alc_suspend(struct hda_codec *codec, pm_message_t state)
4245{
4246 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004247 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004248 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05004249 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004250 return 0;
4251}
4252#endif
4253
Takashi Iwaie044c392008-10-27 16:56:24 +01004254#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01004255static int alc_resume(struct hda_codec *codec)
4256{
Takashi Iwaie044c392008-10-27 16:56:24 +01004257 codec->patch_ops.init(codec);
4258 snd_hda_codec_resume_amp(codec);
4259 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +02004260 hda_call_check_power_status(codec, 0x01);
Takashi Iwaie044c392008-10-27 16:56:24 +01004261 return 0;
4262}
Takashi Iwaie044c392008-10-27 16:56:24 +01004263#endif
4264
Linus Torvalds1da177e2005-04-16 15:20:36 -07004265/*
4266 */
4267static struct hda_codec_ops alc_patch_ops = {
4268 .build_controls = alc_build_controls,
4269 .build_pcms = alc_build_pcms,
4270 .init = alc_init,
4271 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004272 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004273#ifdef SND_HDA_NEEDS_RESUME
4274 .resume = alc_resume,
4275#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004276#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004277 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004278 .check_power_status = alc_check_power_status,
4279#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004280 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004281};
4282
Kailang Yangc027ddc2010-03-19 11:33:06 +01004283/* replace the codec chip_name with the given string */
4284static int alc_codec_rename(struct hda_codec *codec, const char *name)
4285{
4286 kfree(codec->chip_name);
4287 codec->chip_name = kstrdup(name, GFP_KERNEL);
4288 if (!codec->chip_name) {
4289 alc_free(codec);
4290 return -ENOMEM;
4291 }
4292 return 0;
4293}
4294
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004295/*
4296 * Test configuration for debugging
4297 *
4298 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4299 * enum controls.
4300 */
4301#ifdef CONFIG_SND_DEBUG
4302static hda_nid_t alc880_test_dac_nids[4] = {
4303 0x02, 0x03, 0x04, 0x05
4304};
4305
4306static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004307 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004308 .items = {
4309 { "In-1", 0x0 },
4310 { "In-2", 0x1 },
4311 { "In-3", 0x2 },
4312 { "In-4", 0x3 },
4313 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004314 { "Front", 0x5 },
4315 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004316 },
4317};
4318
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004319static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004320 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004321 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004322 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004323 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004324};
4325
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004326static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4327 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004328{
4329 static char *texts[] = {
4330 "N/A", "Line Out", "HP Out",
4331 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4332 };
4333 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4334 uinfo->count = 1;
4335 uinfo->value.enumerated.items = 8;
4336 if (uinfo->value.enumerated.item >= 8)
4337 uinfo->value.enumerated.item = 7;
4338 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4339 return 0;
4340}
4341
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004342static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4343 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004344{
4345 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4346 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4347 unsigned int pin_ctl, item = 0;
4348
4349 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4350 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4351 if (pin_ctl & AC_PINCTL_OUT_EN) {
4352 if (pin_ctl & AC_PINCTL_HP_EN)
4353 item = 2;
4354 else
4355 item = 1;
4356 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4357 switch (pin_ctl & AC_PINCTL_VREFEN) {
4358 case AC_PINCTL_VREF_HIZ: item = 3; break;
4359 case AC_PINCTL_VREF_50: item = 4; break;
4360 case AC_PINCTL_VREF_GRD: item = 5; break;
4361 case AC_PINCTL_VREF_80: item = 6; break;
4362 case AC_PINCTL_VREF_100: item = 7; break;
4363 }
4364 }
4365 ucontrol->value.enumerated.item[0] = item;
4366 return 0;
4367}
4368
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004369static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
4370 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004371{
4372 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4373 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4374 static unsigned int ctls[] = {
4375 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4376 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4377 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4378 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4379 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4380 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4381 };
4382 unsigned int old_ctl, new_ctl;
4383
4384 old_ctl = snd_hda_codec_read(codec, nid, 0,
4385 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4386 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4387 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004388 int val;
4389 snd_hda_codec_write_cache(codec, nid, 0,
4390 AC_VERB_SET_PIN_WIDGET_CONTROL,
4391 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004392 val = ucontrol->value.enumerated.item[0] >= 3 ?
4393 HDA_AMP_MUTE : 0;
4394 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4395 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004396 return 1;
4397 }
4398 return 0;
4399}
4400
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004401static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4402 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004403{
4404 static char *texts[] = {
4405 "Front", "Surround", "CLFE", "Side"
4406 };
4407 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4408 uinfo->count = 1;
4409 uinfo->value.enumerated.items = 4;
4410 if (uinfo->value.enumerated.item >= 4)
4411 uinfo->value.enumerated.item = 3;
4412 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4413 return 0;
4414}
4415
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004416static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4417 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004418{
4419 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4420 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4421 unsigned int sel;
4422
4423 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4424 ucontrol->value.enumerated.item[0] = sel & 3;
4425 return 0;
4426}
4427
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004428static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4429 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004430{
4431 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4432 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4433 unsigned int sel;
4434
4435 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4436 if (ucontrol->value.enumerated.item[0] != sel) {
4437 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004438 snd_hda_codec_write_cache(codec, nid, 0,
4439 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004440 return 1;
4441 }
4442 return 0;
4443}
4444
4445#define PIN_CTL_TEST(xname,nid) { \
4446 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4447 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004448 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004449 .info = alc_test_pin_ctl_info, \
4450 .get = alc_test_pin_ctl_get, \
4451 .put = alc_test_pin_ctl_put, \
4452 .private_value = nid \
4453 }
4454
4455#define PIN_SRC_TEST(xname,nid) { \
4456 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4457 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004458 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004459 .info = alc_test_pin_src_info, \
4460 .get = alc_test_pin_src_get, \
4461 .put = alc_test_pin_src_put, \
4462 .private_value = nid \
4463 }
4464
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004465static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004466 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4467 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4468 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4469 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004470 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4471 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4472 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4473 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004474 PIN_CTL_TEST("Front Pin Mode", 0x14),
4475 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4476 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4477 PIN_CTL_TEST("Side Pin Mode", 0x17),
4478 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4479 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4480 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4481 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4482 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4483 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4484 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4485 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4486 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4487 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4488 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4489 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4490 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4491 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4492 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4493 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4494 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4495 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004496 {
4497 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4498 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004499 .info = alc_ch_mode_info,
4500 .get = alc_ch_mode_get,
4501 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004502 },
4503 { } /* end */
4504};
4505
4506static struct hda_verb alc880_test_init_verbs[] = {
4507 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004508 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4509 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4510 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4511 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4512 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4513 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4514 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4515 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004516 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004517 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4518 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4519 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4520 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004521 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004522 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4523 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4524 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4525 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004526 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004527 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4528 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4529 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4530 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004531 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004532 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4533 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004534 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4535 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4536 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004537 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004538 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4539 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4540 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4541 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004542 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004543 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004544 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004545 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004546 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004547 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004548 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004549 /* Analog input/passthru */
4550 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4551 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4552 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4553 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4554 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004555 { }
4556};
4557#endif
4558
Linus Torvalds1da177e2005-04-16 15:20:36 -07004559/*
4560 */
4561
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004562static const char *alc880_models[ALC880_MODEL_LAST] = {
4563 [ALC880_3ST] = "3stack",
4564 [ALC880_TCL_S700] = "tcl",
4565 [ALC880_3ST_DIG] = "3stack-digout",
4566 [ALC880_CLEVO] = "clevo",
4567 [ALC880_5ST] = "5stack",
4568 [ALC880_5ST_DIG] = "5stack-digout",
4569 [ALC880_W810] = "w810",
4570 [ALC880_Z71V] = "z71v",
4571 [ALC880_6ST] = "6stack",
4572 [ALC880_6ST_DIG] = "6stack-digout",
4573 [ALC880_ASUS] = "asus",
4574 [ALC880_ASUS_W1V] = "asus-w1v",
4575 [ALC880_ASUS_DIG] = "asus-dig",
4576 [ALC880_ASUS_DIG2] = "asus-dig2",
4577 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004578 [ALC880_UNIWILL_P53] = "uniwill-p53",
4579 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004580 [ALC880_F1734] = "F1734",
4581 [ALC880_LG] = "lg",
4582 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004583 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004584#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004585 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004586#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004587 [ALC880_AUTO] = "auto",
4588};
4589
4590static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004591 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004592 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4593 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4594 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4595 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4596 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4597 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4598 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4599 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004600 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4601 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004602 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4603 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4604 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4605 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4606 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4607 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4608 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4609 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4610 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4611 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004612 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004613 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4614 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4615 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004616 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004617 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004618 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4619 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004620 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4621 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004622 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4623 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4624 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4625 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004626 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4627 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004628 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004629 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004630 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004631 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004632 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4633 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004634 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004635 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004636 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004637 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004638 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004639 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004640 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004641 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004642 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004643 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
Daniel T Chen77c4d5c2010-12-02 22:45:45 -05004644 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004645 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004646 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004647 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4648 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4649 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4650 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004651 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4652 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004653 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004654 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004655 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4656 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004657 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4658 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4659 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004660 /* default Intel */
4661 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004662 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4663 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004664 {}
4665};
4666
Takashi Iwai16ded522005-06-10 19:58:24 +02004667/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004668 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004669 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004670static struct alc_config_preset alc880_presets[] = {
4671 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004672 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004673 .init_verbs = { alc880_volume_init_verbs,
4674 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004675 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004676 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004677 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4678 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004679 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004680 .input_mux = &alc880_capture_source,
4681 },
4682 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004683 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004684 .init_verbs = { alc880_volume_init_verbs,
4685 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004686 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004687 .dac_nids = alc880_dac_nids,
4688 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004689 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4690 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004691 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004692 .input_mux = &alc880_capture_source,
4693 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004694 [ALC880_TCL_S700] = {
4695 .mixers = { alc880_tcl_s700_mixer },
4696 .init_verbs = { alc880_volume_init_verbs,
4697 alc880_pin_tcl_S700_init_verbs,
4698 alc880_gpio2_init_verbs },
4699 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4700 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004701 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4702 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004703 .hp_nid = 0x03,
4704 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4705 .channel_mode = alc880_2_jack_modes,
4706 .input_mux = &alc880_capture_source,
4707 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004708 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004709 .mixers = { alc880_three_stack_mixer,
4710 alc880_five_stack_mixer},
4711 .init_verbs = { alc880_volume_init_verbs,
4712 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004713 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4714 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004715 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4716 .channel_mode = alc880_fivestack_modes,
4717 .input_mux = &alc880_capture_source,
4718 },
4719 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004720 .mixers = { alc880_three_stack_mixer,
4721 alc880_five_stack_mixer },
4722 .init_verbs = { alc880_volume_init_verbs,
4723 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004724 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4725 .dac_nids = alc880_dac_nids,
4726 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004727 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4728 .channel_mode = alc880_fivestack_modes,
4729 .input_mux = &alc880_capture_source,
4730 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004731 [ALC880_6ST] = {
4732 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004733 .init_verbs = { alc880_volume_init_verbs,
4734 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004735 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4736 .dac_nids = alc880_6st_dac_nids,
4737 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4738 .channel_mode = alc880_sixstack_modes,
4739 .input_mux = &alc880_6stack_capture_source,
4740 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004741 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004742 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004743 .init_verbs = { alc880_volume_init_verbs,
4744 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004745 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4746 .dac_nids = alc880_6st_dac_nids,
4747 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004748 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4749 .channel_mode = alc880_sixstack_modes,
4750 .input_mux = &alc880_6stack_capture_source,
4751 },
4752 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004753 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004754 .init_verbs = { alc880_volume_init_verbs,
4755 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004756 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004757 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4758 .dac_nids = alc880_w810_dac_nids,
4759 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004760 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4761 .channel_mode = alc880_w810_modes,
4762 .input_mux = &alc880_capture_source,
4763 },
4764 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004765 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004766 .init_verbs = { alc880_volume_init_verbs,
4767 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004768 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4769 .dac_nids = alc880_z71v_dac_nids,
4770 .dig_out_nid = ALC880_DIGOUT_NID,
4771 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004772 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4773 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004774 .input_mux = &alc880_capture_source,
4775 },
4776 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004777 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004778 .init_verbs = { alc880_volume_init_verbs,
4779 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004780 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4781 .dac_nids = alc880_f1734_dac_nids,
4782 .hp_nid = 0x02,
4783 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4784 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004785 .input_mux = &alc880_f1734_capture_source,
4786 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004787 .setup = alc880_uniwill_p53_setup,
4788 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004789 },
4790 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004791 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004792 .init_verbs = { alc880_volume_init_verbs,
4793 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004794 alc880_gpio1_init_verbs },
4795 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4796 .dac_nids = alc880_asus_dac_nids,
4797 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4798 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004799 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004800 .input_mux = &alc880_capture_source,
4801 },
4802 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004803 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004804 .init_verbs = { alc880_volume_init_verbs,
4805 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004806 alc880_gpio1_init_verbs },
4807 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4808 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004809 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004810 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4811 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004812 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004813 .input_mux = &alc880_capture_source,
4814 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004815 [ALC880_ASUS_DIG2] = {
4816 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004817 .init_verbs = { alc880_volume_init_verbs,
4818 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004819 alc880_gpio2_init_verbs }, /* use GPIO2 */
4820 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4821 .dac_nids = alc880_asus_dac_nids,
4822 .dig_out_nid = ALC880_DIGOUT_NID,
4823 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4824 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004825 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004826 .input_mux = &alc880_capture_source,
4827 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004828 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004829 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004830 .init_verbs = { alc880_volume_init_verbs,
4831 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004832 alc880_gpio1_init_verbs },
4833 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4834 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004835 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004836 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4837 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004838 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004839 .input_mux = &alc880_capture_source,
4840 },
4841 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004842 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004843 .init_verbs = { alc880_volume_init_verbs,
4844 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004845 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4846 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004847 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004848 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4849 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004850 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004851 .input_mux = &alc880_capture_source,
4852 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004853 [ALC880_UNIWILL] = {
4854 .mixers = { alc880_uniwill_mixer },
4855 .init_verbs = { alc880_volume_init_verbs,
4856 alc880_uniwill_init_verbs },
4857 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4858 .dac_nids = alc880_asus_dac_nids,
4859 .dig_out_nid = ALC880_DIGOUT_NID,
4860 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4861 .channel_mode = alc880_threestack_modes,
4862 .need_dac_fix = 1,
4863 .input_mux = &alc880_capture_source,
4864 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004865 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004866 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004867 },
4868 [ALC880_UNIWILL_P53] = {
4869 .mixers = { alc880_uniwill_p53_mixer },
4870 .init_verbs = { alc880_volume_init_verbs,
4871 alc880_uniwill_p53_init_verbs },
4872 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4873 .dac_nids = alc880_asus_dac_nids,
4874 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004875 .channel_mode = alc880_threestack_modes,
4876 .input_mux = &alc880_capture_source,
4877 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004878 .setup = alc880_uniwill_p53_setup,
4879 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004880 },
4881 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004882 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004883 .init_verbs = { alc880_volume_init_verbs,
4884 alc880_uniwill_p53_init_verbs,
4885 alc880_beep_init_verbs },
4886 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4887 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004888 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004889 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4890 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004891 .input_mux = &alc880_capture_source,
4892 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004893 .setup = alc880_uniwill_p53_setup,
4894 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004895 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004896 [ALC880_CLEVO] = {
4897 .mixers = { alc880_three_stack_mixer },
4898 .init_verbs = { alc880_volume_init_verbs,
4899 alc880_pin_clevo_init_verbs },
4900 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4901 .dac_nids = alc880_dac_nids,
4902 .hp_nid = 0x03,
4903 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4904 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004905 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004906 .input_mux = &alc880_capture_source,
4907 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004908 [ALC880_LG] = {
4909 .mixers = { alc880_lg_mixer },
4910 .init_verbs = { alc880_volume_init_verbs,
4911 alc880_lg_init_verbs },
4912 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4913 .dac_nids = alc880_lg_dac_nids,
4914 .dig_out_nid = ALC880_DIGOUT_NID,
4915 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4916 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004917 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004918 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004919 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004920 .setup = alc880_lg_setup,
4921 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004922#ifdef CONFIG_SND_HDA_POWER_SAVE
4923 .loopbacks = alc880_lg_loopbacks,
4924#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004925 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004926 [ALC880_LG_LW] = {
4927 .mixers = { alc880_lg_lw_mixer },
4928 .init_verbs = { alc880_volume_init_verbs,
4929 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004930 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004931 .dac_nids = alc880_dac_nids,
4932 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004933 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4934 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004935 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004936 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004937 .setup = alc880_lg_lw_setup,
4938 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004939 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004940 [ALC880_MEDION_RIM] = {
4941 .mixers = { alc880_medion_rim_mixer },
4942 .init_verbs = { alc880_volume_init_verbs,
4943 alc880_medion_rim_init_verbs,
4944 alc_gpio2_init_verbs },
4945 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4946 .dac_nids = alc880_dac_nids,
4947 .dig_out_nid = ALC880_DIGOUT_NID,
4948 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4949 .channel_mode = alc880_2_jack_modes,
4950 .input_mux = &alc880_medion_rim_capture_source,
4951 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004952 .setup = alc880_medion_rim_setup,
4953 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004954 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004955#ifdef CONFIG_SND_DEBUG
4956 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004957 .mixers = { alc880_test_mixer },
4958 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004959 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4960 .dac_nids = alc880_test_dac_nids,
4961 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004962 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4963 .channel_mode = alc880_test_modes,
4964 .input_mux = &alc880_test_capture_source,
4965 },
4966#endif
4967};
4968
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004969/*
4970 * Automatic parse of I/O pins from the BIOS configuration
4971 */
4972
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004973enum {
4974 ALC_CTL_WIDGET_VOL,
4975 ALC_CTL_WIDGET_MUTE,
4976 ALC_CTL_BIND_MUTE,
4977};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004978static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004979 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4980 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004981 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004982};
4983
4984/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004985static int add_control(struct alc_spec *spec, int type, const char *name,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004986 int cidx, unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004987{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004988 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004989
Takashi Iwai603c4012008-07-30 15:01:44 +02004990 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4991 knew = snd_array_new(&spec->kctls);
4992 if (!knew)
4993 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004994 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004995 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004996 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004997 return -ENOMEM;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004998 knew->index = cidx;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004999 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01005000 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005001 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005002 return 0;
5003}
5004
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005005static int add_control_with_pfx(struct alc_spec *spec, int type,
5006 const char *pfx, const char *dir,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005007 const char *sfx, int cidx, unsigned long val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005008{
5009 char name[32];
5010 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005011 return add_control(spec, type, name, cidx, val);
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005012}
5013
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005014#define add_pb_vol_ctrl(spec, type, pfx, val) \
5015 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
5016#define add_pb_sw_ctrl(spec, type, pfx, val) \
5017 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
5018#define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
5019 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
5020#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
5021 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005022
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005023#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
5024#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
5025#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
5026#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005027#define alc880_idx_to_dac(nid) ((nid) + 0x02)
5028#define alc880_dac_to_idx(nid) ((nid) - 0x02)
5029#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
5030#define alc880_idx_to_selector(nid) ((nid) + 0x10)
5031#define ALC880_PIN_CD_NID 0x1c
5032
5033/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005034static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
5035 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005036{
5037 hda_nid_t nid;
5038 int assigned[4];
5039 int i, j;
5040
5041 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02005042 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005043
5044 /* check the pins hardwired to audio widget */
5045 for (i = 0; i < cfg->line_outs; i++) {
5046 nid = cfg->line_out_pins[i];
5047 if (alc880_is_fixed_pin(nid)) {
5048 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01005049 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005050 assigned[idx] = 1;
5051 }
5052 }
5053 /* left pins can be connect to any 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 continue;
5058 /* search for an empty channel */
5059 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005060 if (!assigned[j]) {
5061 spec->multiout.dac_nids[i] =
5062 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005063 assigned[j] = 1;
5064 break;
5065 }
5066 }
5067 }
5068 spec->multiout.num_dacs = cfg->line_outs;
5069 return 0;
5070}
5071
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005072static const char *alc_get_line_out_pfx(const struct auto_pin_cfg *cfg,
5073 bool can_be_master)
5074{
5075 if (!cfg->hp_outs && !cfg->speaker_outs && can_be_master)
5076 return "Master";
5077
5078 switch (cfg->line_out_type) {
5079 case AUTO_PIN_SPEAKER_OUT:
5080 return "Speaker";
5081 case AUTO_PIN_HP_OUT:
5082 return "Headphone";
5083 default:
5084 if (cfg->line_outs == 1)
5085 return "PCM";
5086 break;
5087 }
5088 return NULL;
5089}
5090
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005091/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01005092static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
5093 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005094{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005095 static const char *chname[4] = {
5096 "Front", "Surround", NULL /*CLFE*/, "Side"
5097 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005098 const char *pfx = alc_get_line_out_pfx(cfg, false);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005099 hda_nid_t nid;
5100 int i, err;
5101
5102 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005103 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005104 continue;
5105 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005106 if (!pfx && i == 2) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005107 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005108 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5109 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005110 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
5111 HDA_OUTPUT));
5112 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005113 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005114 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5115 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005116 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
5117 HDA_OUTPUT));
5118 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005119 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005120 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5121 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005122 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
5123 HDA_INPUT));
5124 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005125 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005126 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5127 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005128 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
5129 HDA_INPUT));
5130 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005131 return err;
5132 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005133 const char *name = pfx;
5134 if (!name)
5135 name = chname[i];
5136 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5137 name, i,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005138 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
5139 HDA_OUTPUT));
5140 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005141 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005142 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5143 name, i,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005144 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
5145 HDA_INPUT));
5146 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005147 return err;
5148 }
5149 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005150 return 0;
5151}
5152
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005153/* add playback controls for speaker and HP outputs */
5154static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
5155 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005156{
5157 hda_nid_t nid;
5158 int err;
5159
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005160 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005161 return 0;
5162
5163 if (alc880_is_fixed_pin(pin)) {
5164 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01005165 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005166 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005167 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005168 else
5169 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005170 /* control HP volume/switch on the output mixer amp */
5171 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005172 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005173 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
5174 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005175 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005176 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005177 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
5178 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005179 return err;
5180 } else if (alc880_is_multi_pin(pin)) {
5181 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005182 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005183 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005184 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
5185 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005186 return err;
5187 }
5188 return 0;
5189}
5190
5191/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005192static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005193 const char *ctlname, int ctlidx,
Kailang Yangdf694da2005-12-05 19:42:22 +01005194 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005195{
Kailang Yangdf694da2005-12-05 19:42:22 +01005196 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005197
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005198 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005199 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5200 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005201 return err;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005202 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005203 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5204 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005205 return err;
5206 return 0;
5207}
5208
Takashi Iwai05f5f472009-08-25 13:10:18 +02005209static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005210{
Takashi Iwai05f5f472009-08-25 13:10:18 +02005211 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
5212 return (pincap & AC_PINCAP_IN) != 0;
5213}
5214
5215/* create playback/capture controls for input pins */
5216static int alc_auto_create_input_ctls(struct hda_codec *codec,
5217 const struct auto_pin_cfg *cfg,
5218 hda_nid_t mixer,
5219 hda_nid_t cap1, hda_nid_t cap2)
5220{
5221 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005222 struct hda_input_mux *imux = &spec->private_imux[0];
David Henningsson5322bf22011-01-05 11:03:56 +01005223 int i, err, idx, type_idx = 0;
5224 const char *prev_label = NULL;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005225
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005226 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02005227 hda_nid_t pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005228 const char *label;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005229
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005230 pin = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005231 if (!alc_is_input_pin(codec, pin))
5232 continue;
5233
David Henningsson5322bf22011-01-05 11:03:56 +01005234 label = hda_get_autocfg_input_label(codec, cfg, i);
5235 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005236 type_idx++;
5237 else
5238 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +01005239 prev_label = label;
5240
Takashi Iwai05f5f472009-08-25 13:10:18 +02005241 if (mixer) {
5242 idx = get_connection_index(codec, mixer, pin);
5243 if (idx >= 0) {
5244 err = new_analog_input(spec, pin,
Takashi Iwai10a20af2010-09-09 16:28:02 +02005245 label, type_idx,
5246 idx, mixer);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005247 if (err < 0)
5248 return err;
5249 }
5250 }
5251
5252 if (!cap1)
5253 continue;
5254 idx = get_connection_index(codec, cap1, pin);
5255 if (idx < 0 && cap2)
5256 idx = get_connection_index(codec, cap2, pin);
Takashi Iwai10a20af2010-09-09 16:28:02 +02005257 if (idx >= 0)
5258 snd_hda_add_imux_item(imux, label, idx, NULL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005259 }
5260 return 0;
5261}
5262
Takashi Iwai05f5f472009-08-25 13:10:18 +02005263static int alc880_auto_create_input_ctls(struct hda_codec *codec,
5264 const struct auto_pin_cfg *cfg)
5265{
5266 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
5267}
5268
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005269static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
5270 unsigned int pin_type)
5271{
5272 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5273 pin_type);
5274 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01005275 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5276 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005277}
5278
Kailang Yangdf694da2005-12-05 19:42:22 +01005279static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
5280 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005281 int dac_idx)
5282{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005283 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005284 /* need the manual connection? */
5285 if (alc880_is_multi_pin(nid)) {
5286 struct alc_spec *spec = codec->spec;
5287 int idx = alc880_multi_pin_idx(nid);
5288 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
5289 AC_VERB_SET_CONNECT_SEL,
5290 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
5291 }
5292}
5293
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005294static int get_pin_type(int line_out_type)
5295{
5296 if (line_out_type == AUTO_PIN_HP_OUT)
5297 return PIN_HP;
5298 else
5299 return PIN_OUT;
5300}
5301
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005302static void alc880_auto_init_multi_out(struct hda_codec *codec)
5303{
5304 struct alc_spec *spec = codec->spec;
5305 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005306
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005307 for (i = 0; i < spec->autocfg.line_outs; i++) {
5308 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005309 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5310 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005311 }
5312}
5313
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005314static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005315{
5316 struct alc_spec *spec = codec->spec;
5317 hda_nid_t pin;
5318
Takashi Iwai82bc9552006-03-21 11:24:42 +01005319 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005320 if (pin) /* connect to front */
5321 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005322 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005323 if (pin) /* connect to front */
5324 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5325}
5326
5327static void alc880_auto_init_analog_input(struct hda_codec *codec)
5328{
5329 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005330 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005331 int i;
5332
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005333 for (i = 0; i < cfg->num_inputs; i++) {
5334 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005335 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02005336 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005337 if (nid != ALC880_PIN_CD_NID &&
5338 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005339 snd_hda_codec_write(codec, nid, 0,
5340 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005341 AMP_OUT_MUTE);
5342 }
5343 }
5344}
5345
Takashi Iwai7f311a42010-04-09 17:32:23 +02005346static void alc880_auto_init_input_src(struct hda_codec *codec)
5347{
5348 struct alc_spec *spec = codec->spec;
5349 int c;
5350
5351 for (c = 0; c < spec->num_adc_nids; c++) {
5352 unsigned int mux_idx;
5353 const struct hda_input_mux *imux;
5354 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5355 imux = &spec->input_mux[mux_idx];
5356 if (!imux->num_items && mux_idx > 0)
5357 imux = &spec->input_mux[0];
5358 if (imux)
5359 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5360 AC_VERB_SET_CONNECT_SEL,
5361 imux->items[0].index);
5362 }
5363}
5364
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005365/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005366/* return 1 if successful, 0 if the proper config is not found,
5367 * or a negative error code
5368 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005369static int alc880_parse_auto_config(struct hda_codec *codec)
5370{
5371 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005372 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005373 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005374
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005375 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5376 alc880_ignore);
5377 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005378 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005379 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005380 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005381
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005382 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5383 if (err < 0)
5384 return err;
5385 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5386 if (err < 0)
5387 return err;
5388 err = alc880_auto_create_extra_out(spec,
5389 spec->autocfg.speaker_pins[0],
5390 "Speaker");
5391 if (err < 0)
5392 return err;
5393 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5394 "Headphone");
5395 if (err < 0)
5396 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005397 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005398 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005399 return err;
5400
5401 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5402
Takashi Iwai757899a2010-07-30 10:48:14 +02005403 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005404
Takashi Iwai603c4012008-07-30 15:01:44 +02005405 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005406 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005407
Takashi Iwaid88897e2008-10-31 15:01:37 +01005408 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005409
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005410 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005411 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005412
Kailang Yang6227cdc2010-02-25 08:36:52 +01005413 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005414
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005415 return 1;
5416}
5417
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005418/* additional initialization for auto-configuration model */
5419static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005420{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005421 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005422 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005423 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005424 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005425 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005426 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005427 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005428 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005429}
5430
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005431/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5432 * one of two digital mic pins, e.g. on ALC272
5433 */
5434static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005435{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005436 struct alc_spec *spec = codec->spec;
5437 int i;
5438
5439 for (i = 0; i < spec->num_adc_nids; i++) {
5440 hda_nid_t cap = spec->capsrc_nids ?
5441 spec->capsrc_nids[i] : spec->adc_nids[i];
5442 int iidx, eidx;
5443
5444 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5445 if (iidx < 0)
5446 continue;
5447 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5448 if (eidx < 0)
5449 continue;
5450 spec->int_mic.mux_idx = iidx;
5451 spec->ext_mic.mux_idx = eidx;
5452 if (spec->capsrc_nids)
5453 spec->capsrc_nids += i;
5454 spec->adc_nids += i;
5455 spec->num_adc_nids = 1;
5456 return;
5457 }
5458 snd_printd(KERN_INFO "hda_codec: %s: "
5459 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5460 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5461 spec->auto_mic = 0; /* disable auto-mic to be sure */
5462}
5463
Takashi Iwai748cce42010-08-04 07:37:39 +02005464/* select or unmute the given capsrc route */
5465static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5466 int idx)
5467{
5468 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5469 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5470 HDA_AMP_MUTE, 0);
5471 } else {
5472 snd_hda_codec_write_cache(codec, cap, 0,
5473 AC_VERB_SET_CONNECT_SEL, idx);
5474 }
5475}
5476
Takashi Iwai840b64c2010-07-13 22:49:01 +02005477/* set the default connection to that pin */
5478static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5479{
5480 struct alc_spec *spec = codec->spec;
5481 int i;
5482
5483 for (i = 0; i < spec->num_adc_nids; i++) {
5484 hda_nid_t cap = spec->capsrc_nids ?
5485 spec->capsrc_nids[i] : spec->adc_nids[i];
5486 int idx;
5487
5488 idx = get_connection_index(codec, cap, pin);
5489 if (idx < 0)
5490 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005491 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005492 return i; /* return the found index */
5493 }
5494 return -1; /* not found */
5495}
5496
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005497/* choose the ADC/MUX containing the input pin and initialize the setup */
5498static void fixup_single_adc(struct hda_codec *codec)
5499{
5500 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005501 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005502 int i;
5503
5504 /* search for the input pin; there must be only one */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005505 if (cfg->num_inputs != 1)
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005506 return;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005507 i = init_capsrc_for_pin(codec, cfg->inputs[0].pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005508 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005509 /* use only this ADC */
5510 if (spec->capsrc_nids)
5511 spec->capsrc_nids += i;
5512 spec->adc_nids += i;
5513 spec->num_adc_nids = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005514 }
5515}
5516
Takashi Iwai840b64c2010-07-13 22:49:01 +02005517/* initialize dual adcs */
5518static void fixup_dual_adc_switch(struct hda_codec *codec)
5519{
5520 struct alc_spec *spec = codec->spec;
5521 init_capsrc_for_pin(codec, spec->ext_mic.pin);
5522 init_capsrc_for_pin(codec, spec->int_mic.pin);
5523}
5524
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005525static void set_capture_mixer(struct hda_codec *codec)
5526{
5527 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005528 static struct snd_kcontrol_new *caps[2][3] = {
5529 { alc_capture_mixer_nosrc1,
5530 alc_capture_mixer_nosrc2,
5531 alc_capture_mixer_nosrc3 },
5532 { alc_capture_mixer1,
5533 alc_capture_mixer2,
5534 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005535 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005536 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005537 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005538 int num_adcs = spec->num_adc_nids;
5539 if (spec->dual_adc_switch)
5540 fixup_dual_adc_switch(codec);
5541 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005542 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005543 else if (spec->input_mux) {
5544 if (spec->input_mux->num_items > 1)
5545 mux = 1;
5546 else if (spec->input_mux->num_items == 1)
5547 fixup_single_adc(codec);
5548 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005549 if (spec->dual_adc_switch)
5550 num_adcs = 1;
5551 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005552 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005553}
5554
Takashi Iwai66946352010-03-29 17:21:45 +02005555/* fill adc_nids (and capsrc_nids) containing all active input pins */
5556static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5557 int num_nids)
5558{
5559 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005560 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai66946352010-03-29 17:21:45 +02005561 int n;
5562 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5563
5564 for (n = 0; n < num_nids; n++) {
5565 hda_nid_t adc, cap;
5566 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5567 int nconns, i, j;
5568
5569 adc = nids[n];
5570 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5571 continue;
5572 cap = adc;
5573 nconns = snd_hda_get_connections(codec, cap, conn,
5574 ARRAY_SIZE(conn));
5575 if (nconns == 1) {
5576 cap = conn[0];
5577 nconns = snd_hda_get_connections(codec, cap, conn,
5578 ARRAY_SIZE(conn));
5579 }
5580 if (nconns <= 0)
5581 continue;
5582 if (!fallback_adc) {
5583 fallback_adc = adc;
5584 fallback_cap = cap;
5585 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005586 for (i = 0; i < cfg->num_inputs; i++) {
5587 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai66946352010-03-29 17:21:45 +02005588 for (j = 0; j < nconns; j++) {
5589 if (conn[j] == nid)
5590 break;
5591 }
5592 if (j >= nconns)
5593 break;
5594 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005595 if (i >= cfg->num_inputs) {
Takashi Iwai66946352010-03-29 17:21:45 +02005596 int num_adcs = spec->num_adc_nids;
5597 spec->private_adc_nids[num_adcs] = adc;
5598 spec->private_capsrc_nids[num_adcs] = cap;
5599 spec->num_adc_nids++;
5600 spec->adc_nids = spec->private_adc_nids;
5601 if (adc != cap)
5602 spec->capsrc_nids = spec->private_capsrc_nids;
5603 }
5604 }
5605 if (!spec->num_adc_nids) {
5606 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005607 " using fallback 0x%x\n",
5608 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005609 spec->private_adc_nids[0] = fallback_adc;
5610 spec->adc_nids = spec->private_adc_nids;
5611 if (fallback_adc != fallback_cap) {
5612 spec->private_capsrc_nids[0] = fallback_cap;
5613 spec->capsrc_nids = spec->private_adc_nids;
5614 }
5615 }
5616}
5617
Takashi Iwai67d634c2009-11-16 15:35:59 +01005618#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005619#define set_beep_amp(spec, nid, idx, dir) \
5620 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005621
5622static struct snd_pci_quirk beep_white_list[] = {
5623 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005624 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005625 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005626 {}
5627};
5628
5629static inline int has_cdefine_beep(struct hda_codec *codec)
5630{
5631 struct alc_spec *spec = codec->spec;
5632 const struct snd_pci_quirk *q;
5633 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5634 if (q)
5635 return q->value;
5636 return spec->cdefine.enable_pcbeep;
5637}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005638#else
5639#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005640#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005641#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005642
5643/*
5644 * OK, here we have finally the patch for ALC880
5645 */
5646
Linus Torvalds1da177e2005-04-16 15:20:36 -07005647static int patch_alc880(struct hda_codec *codec)
5648{
5649 struct alc_spec *spec;
5650 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005651 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005652
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005653 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005654 if (spec == NULL)
5655 return -ENOMEM;
5656
5657 codec->spec = spec;
5658
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005659 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5660 alc880_models,
5661 alc880_cfg_tbl);
5662 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005663 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5664 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005665 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005666 }
5667
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005668 if (board_config == ALC880_AUTO) {
5669 /* automatic parse from the BIOS config */
5670 err = alc880_parse_auto_config(codec);
5671 if (err < 0) {
5672 alc_free(codec);
5673 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005674 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005675 printk(KERN_INFO
5676 "hda_codec: Cannot set up configuration "
5677 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005678 board_config = ALC880_3ST;
5679 }
5680 }
5681
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005682 err = snd_hda_attach_beep_device(codec, 0x1);
5683 if (err < 0) {
5684 alc_free(codec);
5685 return err;
5686 }
5687
Kailang Yangdf694da2005-12-05 19:42:22 +01005688 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005689 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005690
Linus Torvalds1da177e2005-04-16 15:20:36 -07005691 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5692 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005693 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005694
Linus Torvalds1da177e2005-04-16 15:20:36 -07005695 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5696 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5697
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005698 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005699 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005700 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005701 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005702 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005703 if (wcap != AC_WID_AUD_IN) {
5704 spec->adc_nids = alc880_adc_nids_alt;
5705 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005706 } else {
5707 spec->adc_nids = alc880_adc_nids;
5708 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005709 }
5710 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005711 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005712 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005713
Takashi Iwai2134ea42008-01-10 16:53:55 +01005714 spec->vmaster_nid = 0x0c;
5715
Linus Torvalds1da177e2005-04-16 15:20:36 -07005716 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005717 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005718 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005719#ifdef CONFIG_SND_HDA_POWER_SAVE
5720 if (!spec->loopback.amplist)
5721 spec->loopback.amplist = alc880_loopbacks;
5722#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005723
5724 return 0;
5725}
5726
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005727
Linus Torvalds1da177e2005-04-16 15:20:36 -07005728/*
5729 * ALC260 support
5730 */
5731
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005732static hda_nid_t alc260_dac_nids[1] = {
5733 /* front */
5734 0x02,
5735};
5736
5737static hda_nid_t alc260_adc_nids[1] = {
5738 /* ADC0 */
5739 0x04,
5740};
5741
Kailang Yangdf694da2005-12-05 19:42:22 +01005742static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005743 /* ADC1 */
5744 0x05,
5745};
5746
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005747/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5748 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5749 */
5750static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005751 /* ADC0, ADC1 */
5752 0x04, 0x05
5753};
5754
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005755#define ALC260_DIGOUT_NID 0x03
5756#define ALC260_DIGIN_NID 0x06
5757
5758static struct hda_input_mux alc260_capture_source = {
5759 .num_items = 4,
5760 .items = {
5761 { "Mic", 0x0 },
5762 { "Front Mic", 0x1 },
5763 { "Line", 0x2 },
5764 { "CD", 0x4 },
5765 },
5766};
5767
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005768/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005769 * headphone jack and the internal CD lines since these are the only pins at
5770 * which audio can appear. For flexibility, also allow the option of
5771 * recording the mixer output on the second ADC (ADC0 doesn't have a
5772 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005773 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005774static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5775 {
5776 .num_items = 3,
5777 .items = {
5778 { "Mic/Line", 0x0 },
5779 { "CD", 0x4 },
5780 { "Headphone", 0x2 },
5781 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005782 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005783 {
5784 .num_items = 4,
5785 .items = {
5786 { "Mic/Line", 0x0 },
5787 { "CD", 0x4 },
5788 { "Headphone", 0x2 },
5789 { "Mixer", 0x5 },
5790 },
5791 },
5792
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005793};
5794
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005795/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5796 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005797 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005798static struct hda_input_mux alc260_acer_capture_sources[2] = {
5799 {
5800 .num_items = 4,
5801 .items = {
5802 { "Mic", 0x0 },
5803 { "Line", 0x2 },
5804 { "CD", 0x4 },
5805 { "Headphone", 0x5 },
5806 },
5807 },
5808 {
5809 .num_items = 5,
5810 .items = {
5811 { "Mic", 0x0 },
5812 { "Line", 0x2 },
5813 { "CD", 0x4 },
5814 { "Headphone", 0x6 },
5815 { "Mixer", 0x5 },
5816 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005817 },
5818};
Michael Schwingencc959482009-02-22 18:58:45 +01005819
5820/* Maxdata Favorit 100XS */
5821static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5822 {
5823 .num_items = 2,
5824 .items = {
5825 { "Line/Mic", 0x0 },
5826 { "CD", 0x4 },
5827 },
5828 },
5829 {
5830 .num_items = 3,
5831 .items = {
5832 { "Line/Mic", 0x0 },
5833 { "CD", 0x4 },
5834 { "Mixer", 0x5 },
5835 },
5836 },
5837};
5838
Linus Torvalds1da177e2005-04-16 15:20:36 -07005839/*
5840 * This is just place-holder, so there's something for alc_build_pcms to look
5841 * at when it calculates the maximum number of channels. ALC260 has no mixer
5842 * element which allows changing the channel mode, so the verb list is
5843 * never used.
5844 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005845static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005846 { 2, NULL },
5847};
5848
Kailang Yangdf694da2005-12-05 19:42:22 +01005849
5850/* Mixer combinations
5851 *
5852 * basic: base_output + input + pc_beep + capture
5853 * HP: base_output + input + capture_alt
5854 * HP_3013: hp_3013 + input + capture
5855 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005856 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005857 */
5858
5859static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005860 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005861 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005862 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5863 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5864 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5865 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5866 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005867};
Kailang Yangdf694da2005-12-05 19:42:22 +01005868
5869static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005870 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5871 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5872 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5873 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5874 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5875 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5876 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5877 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005878 { } /* end */
5879};
5880
Takashi Iwaibec15c32008-01-28 18:16:30 +01005881/* update HP, line and mono out pins according to the master switch */
5882static void alc260_hp_master_update(struct hda_codec *codec,
5883 hda_nid_t hp, hda_nid_t line,
5884 hda_nid_t mono)
5885{
5886 struct alc_spec *spec = codec->spec;
5887 unsigned int val = spec->master_sw ? PIN_HP : 0;
5888 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005889 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005890 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005891 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005892 val);
5893 /* mono (speaker) depending on the HP jack sense */
5894 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005895 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005896 val);
5897}
5898
5899static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5900 struct snd_ctl_elem_value *ucontrol)
5901{
5902 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5903 struct alc_spec *spec = codec->spec;
5904 *ucontrol->value.integer.value = spec->master_sw;
5905 return 0;
5906}
5907
5908static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5909 struct snd_ctl_elem_value *ucontrol)
5910{
5911 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5912 struct alc_spec *spec = codec->spec;
5913 int val = !!*ucontrol->value.integer.value;
5914 hda_nid_t hp, line, mono;
5915
5916 if (val == spec->master_sw)
5917 return 0;
5918 spec->master_sw = val;
5919 hp = (kcontrol->private_value >> 16) & 0xff;
5920 line = (kcontrol->private_value >> 8) & 0xff;
5921 mono = kcontrol->private_value & 0xff;
5922 alc260_hp_master_update(codec, hp, line, mono);
5923 return 1;
5924}
5925
5926static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5927 {
5928 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5929 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005930 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005931 .info = snd_ctl_boolean_mono_info,
5932 .get = alc260_hp_master_sw_get,
5933 .put = alc260_hp_master_sw_put,
5934 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5935 },
5936 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5937 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5938 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5939 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5940 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5941 HDA_OUTPUT),
5942 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5943 { } /* end */
5944};
5945
5946static struct hda_verb alc260_hp_unsol_verbs[] = {
5947 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5948 {},
5949};
5950
5951static void alc260_hp_automute(struct hda_codec *codec)
5952{
5953 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005954
Wu Fengguang864f92b2009-11-18 12:38:02 +08005955 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005956 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5957}
5958
5959static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5960{
5961 if ((res >> 26) == ALC880_HP_EVENT)
5962 alc260_hp_automute(codec);
5963}
5964
Kailang Yangdf694da2005-12-05 19:42:22 +01005965static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005966 {
5967 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5968 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005969 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005970 .info = snd_ctl_boolean_mono_info,
5971 .get = alc260_hp_master_sw_get,
5972 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005973 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005974 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005975 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5976 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5977 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5978 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5979 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5980 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005981 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5982 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005983 { } /* end */
5984};
5985
Kailang Yang3f878302008-08-26 13:02:23 +02005986static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5987 .ops = &snd_hda_bind_vol,
5988 .values = {
5989 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5990 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5991 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5992 0
5993 },
5994};
5995
5996static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5997 .ops = &snd_hda_bind_sw,
5998 .values = {
5999 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
6000 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
6001 0
6002 },
6003};
6004
6005static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
6006 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
6007 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
6008 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
6009 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
6010 { } /* end */
6011};
6012
Takashi Iwaibec15c32008-01-28 18:16:30 +01006013static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
6014 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6015 {},
6016};
6017
6018static void alc260_hp_3013_automute(struct hda_codec *codec)
6019{
6020 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006021
Wu Fengguang864f92b2009-11-18 12:38:02 +08006022 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01006023 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01006024}
6025
6026static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
6027 unsigned int res)
6028{
6029 if ((res >> 26) == ALC880_HP_EVENT)
6030 alc260_hp_3013_automute(codec);
6031}
6032
Kailang Yang3f878302008-08-26 13:02:23 +02006033static void alc260_hp_3012_automute(struct hda_codec *codec)
6034{
Wu Fengguang864f92b2009-11-18 12:38:02 +08006035 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02006036
Kailang Yang3f878302008-08-26 13:02:23 +02006037 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6038 bits);
6039 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6040 bits);
6041 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6042 bits);
6043}
6044
6045static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
6046 unsigned int res)
6047{
6048 if ((res >> 26) == ALC880_HP_EVENT)
6049 alc260_hp_3012_automute(codec);
6050}
6051
6052/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006053 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
6054 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006055static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006056 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006057 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006058 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006059 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6060 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6061 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
6062 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006063 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006064 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6065 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006066 { } /* end */
6067};
6068
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006069/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
6070 * versions of the ALC260 don't act on requests to enable mic bias from NID
6071 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
6072 * datasheet doesn't mention this restriction. At this stage it's not clear
6073 * whether this behaviour is intentional or is a hardware bug in chip
6074 * revisions available in early 2006. Therefore for now allow the
6075 * "Headphone Jack Mode" control to span all choices, but if it turns out
6076 * that the lack of mic bias for this NID is intentional we could change the
6077 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6078 *
6079 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
6080 * don't appear to make the mic bias available from the "line" jack, even
6081 * though the NID used for this jack (0x14) can supply it. The theory is
6082 * that perhaps Acer have included blocking capacitors between the ALC260
6083 * and the output jack. If this turns out to be the case for all such
6084 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
6085 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01006086 *
6087 * The C20x Tablet series have a mono internal speaker which is controlled
6088 * via the chip's Mono sum widget and pin complex, so include the necessary
6089 * controls for such models. On models without a "mono speaker" the control
6090 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006091 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006092static struct snd_kcontrol_new alc260_acer_mixer[] = {
6093 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6094 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006095 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006096 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01006097 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006098 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01006099 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006100 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6101 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6102 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6103 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6104 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6105 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6106 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6107 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006108 { } /* end */
6109};
6110
Michael Schwingencc959482009-02-22 18:58:45 +01006111/* Maxdata Favorit 100XS: one output and one input (0x12) jack
6112 */
6113static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
6114 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6115 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
6116 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
6117 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6118 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6119 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6120 { } /* end */
6121};
6122
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006123/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
6124 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
6125 */
6126static struct snd_kcontrol_new alc260_will_mixer[] = {
6127 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6128 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6129 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6130 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6131 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6132 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6133 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6134 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6135 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6136 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006137 { } /* end */
6138};
6139
6140/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
6141 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
6142 */
6143static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
6144 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6145 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6146 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6147 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6148 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6149 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
6150 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
6151 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6152 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6153 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6154 { } /* end */
6155};
6156
Kailang Yangdf694da2005-12-05 19:42:22 +01006157/*
6158 * initialization verbs
6159 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006160static struct hda_verb alc260_init_verbs[] = {
6161 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006162 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006163 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006164 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006165 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006166 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006167 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006168 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006169 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02006170 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006171 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01006172 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006173 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02006174 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006175 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02006176 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006177 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02006178 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6179 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02006180 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006181 /* set connection select to line in (default select for this ADC) */
6182 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02006183 /* mute capture amp left and right */
6184 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6185 /* set connection select to line in (default select for this ADC) */
6186 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02006187 /* set vol=0 Line-Out mixer amp left and right */
6188 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6189 /* unmute pin widget amp left and right (no gain on this amp) */
6190 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6191 /* set vol=0 HP mixer amp left and right */
6192 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6193 /* unmute pin widget amp left and right (no gain on this amp) */
6194 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6195 /* set vol=0 Mono mixer amp left and right */
6196 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6197 /* unmute pin widget amp left and right (no gain on this amp) */
6198 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6199 /* unmute LINE-2 out pin */
6200 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006201 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6202 * Line In 2 = 0x03
6203 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006204 /* mute analog inputs */
6205 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6206 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6207 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6208 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6209 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006210 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006211 /* mute Front out path */
6212 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6213 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6214 /* mute Headphone out path */
6215 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6216 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6217 /* mute Mono out path */
6218 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6219 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006220 { }
6221};
6222
Takashi Iwai474167d2006-05-17 17:17:43 +02006223#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01006224static struct hda_verb alc260_hp_init_verbs[] = {
6225 /* Headphone and output */
6226 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6227 /* mono output */
6228 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6229 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6230 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6231 /* Mic2 (front panel) pin widget for input and vref at 80% */
6232 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6233 /* Line In pin widget for input */
6234 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6235 /* Line-2 pin widget for output */
6236 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6237 /* CD pin widget for input */
6238 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6239 /* unmute amp left and right */
6240 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6241 /* set connection select to line in (default select for this ADC) */
6242 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6243 /* unmute Line-Out mixer amp left and right (volume = 0) */
6244 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6245 /* mute pin widget amp left and right (no gain on this amp) */
6246 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6247 /* unmute HP mixer amp left and right (volume = 0) */
6248 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6249 /* mute pin widget amp left and right (no gain on this amp) */
6250 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006251 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6252 * Line In 2 = 0x03
6253 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006254 /* mute analog inputs */
6255 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6256 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6257 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6258 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6259 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006260 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6261 /* Unmute Front out path */
6262 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6263 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6264 /* Unmute Headphone out path */
6265 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6266 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6267 /* Unmute Mono out path */
6268 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6269 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6270 { }
6271};
Takashi Iwai474167d2006-05-17 17:17:43 +02006272#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006273
6274static struct hda_verb alc260_hp_3013_init_verbs[] = {
6275 /* Line out and output */
6276 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6277 /* mono output */
6278 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6279 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6280 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6281 /* Mic2 (front panel) pin widget for input and vref at 80% */
6282 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6283 /* Line In pin widget for input */
6284 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6285 /* Headphone pin widget for output */
6286 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6287 /* CD pin widget for input */
6288 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6289 /* unmute amp left and right */
6290 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6291 /* set connection select to line in (default select for this ADC) */
6292 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6293 /* unmute Line-Out mixer amp left and right (volume = 0) */
6294 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6295 /* mute pin widget amp left and right (no gain on this amp) */
6296 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6297 /* unmute HP mixer amp left and right (volume = 0) */
6298 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6299 /* mute pin widget amp left and right (no gain on this amp) */
6300 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006301 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6302 * Line In 2 = 0x03
6303 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006304 /* mute analog inputs */
6305 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6306 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6307 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6308 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6309 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006310 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6311 /* Unmute Front out path */
6312 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6313 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6314 /* Unmute Headphone out path */
6315 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6316 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6317 /* Unmute Mono out path */
6318 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6319 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6320 { }
6321};
6322
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006323/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006324 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6325 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006326 */
6327static struct hda_verb alc260_fujitsu_init_verbs[] = {
6328 /* Disable all GPIOs */
6329 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6330 /* Internal speaker is connected to headphone pin */
6331 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6332 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6333 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006334 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6335 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6336 /* Ensure all other unused pins are disabled and muted. */
6337 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6338 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006339 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006340 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006341 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006342 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6343 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6344 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006345
Jonathan Woithef7ace402006-02-28 11:46:14 +01006346 /* Disable digital (SPDIF) pins */
6347 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6348 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006349
Kailang Yangea1fb292008-08-26 12:58:38 +02006350 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006351 * when acting as an output.
6352 */
6353 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6354
6355 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006356 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6357 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6358 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6359 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6360 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6361 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6362 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6363 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6364 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006365
Jonathan Woithef7ace402006-02-28 11:46:14 +01006366 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6367 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6368 /* Unmute Line1 pin widget output buffer since it starts as an output.
6369 * If the pin mode is changed by the user the pin mode control will
6370 * take care of enabling the pin's input/output buffers as needed.
6371 * Therefore there's no need to enable the input buffer at this
6372 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006373 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006374 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006375 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006376 * mixer ctrl)
6377 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006378 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006379
Jonathan Woithef7ace402006-02-28 11:46:14 +01006380 /* Mute capture amp left and right */
6381 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006382 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006383 * in (on mic1 pin)
6384 */
6385 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006386
Jonathan Woithef7ace402006-02-28 11:46:14 +01006387 /* Do the same for the second ADC: mute capture input amp and
6388 * set ADC connection to line in (on mic1 pin)
6389 */
6390 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6391 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006392
Jonathan Woithef7ace402006-02-28 11:46:14 +01006393 /* Mute all inputs to mixer widget (even unconnected ones) */
6394 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6395 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6396 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6397 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6398 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6399 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6400 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6401 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006402
6403 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006404};
6405
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006406/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6407 * similar laptops (adapted from Fujitsu init verbs).
6408 */
6409static struct hda_verb alc260_acer_init_verbs[] = {
6410 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6411 * the headphone jack. Turn this on and rely on the standard mute
6412 * methods whenever the user wants to turn these outputs off.
6413 */
6414 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6415 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6416 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6417 /* Internal speaker/Headphone jack is connected to Line-out pin */
6418 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6419 /* Internal microphone/Mic jack is connected to Mic1 pin */
6420 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6421 /* Line In jack is connected to Line1 pin */
6422 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006423 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6424 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006425 /* Ensure all other unused pins are disabled and muted. */
6426 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6427 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006428 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6429 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6430 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6431 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6432 /* Disable digital (SPDIF) pins */
6433 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6434 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6435
Kailang Yangea1fb292008-08-26 12:58:38 +02006436 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006437 * bus when acting as outputs.
6438 */
6439 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6440 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6441
6442 /* Start with output sum widgets muted and their output gains at min */
6443 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6444 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6445 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6446 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6447 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6448 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6449 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6450 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6451 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6452
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006453 /* Unmute Line-out pin widget amp left and right
6454 * (no equiv mixer ctrl)
6455 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006456 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006457 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6458 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006459 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6460 * inputs. If the pin mode is changed by the user the pin mode control
6461 * will take care of enabling the pin's input/output buffers as needed.
6462 * Therefore there's no need to enable the input buffer at this
6463 * stage.
6464 */
6465 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6466 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6467
6468 /* Mute capture amp left and right */
6469 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6470 /* Set ADC connection select to match default mixer setting - mic
6471 * (on mic1 pin)
6472 */
6473 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6474
6475 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006476 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006477 */
6478 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006479 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006480
6481 /* Mute all inputs to mixer widget (even unconnected ones) */
6482 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6483 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6484 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6485 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6486 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6487 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6488 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6489 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6490
6491 { }
6492};
6493
Michael Schwingencc959482009-02-22 18:58:45 +01006494/* Initialisation sequence for Maxdata Favorit 100XS
6495 * (adapted from Acer init verbs).
6496 */
6497static struct hda_verb alc260_favorit100_init_verbs[] = {
6498 /* GPIO 0 enables the output jack.
6499 * Turn this on and rely on the standard mute
6500 * methods whenever the user wants to turn these outputs off.
6501 */
6502 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6503 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6504 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6505 /* Line/Mic input jack is connected to Mic1 pin */
6506 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6507 /* Ensure all other unused pins are disabled and muted. */
6508 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6509 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6510 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6511 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6512 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6513 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6514 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6515 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6516 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6517 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6518 /* Disable digital (SPDIF) pins */
6519 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6520 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6521
6522 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6523 * bus when acting as outputs.
6524 */
6525 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6526 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6527
6528 /* Start with output sum widgets muted and their output gains at min */
6529 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6530 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6531 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6532 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6533 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6534 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6535 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6536 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6537 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6538
6539 /* Unmute Line-out pin widget amp left and right
6540 * (no equiv mixer ctrl)
6541 */
6542 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6543 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6544 * inputs. If the pin mode is changed by the user the pin mode control
6545 * will take care of enabling the pin's input/output buffers as needed.
6546 * Therefore there's no need to enable the input buffer at this
6547 * stage.
6548 */
6549 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6550
6551 /* Mute capture amp left and right */
6552 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6553 /* Set ADC connection select to match default mixer setting - mic
6554 * (on mic1 pin)
6555 */
6556 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6557
6558 /* Do similar with the second ADC: mute capture input amp and
6559 * set ADC connection to mic to match ALSA's default state.
6560 */
6561 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6562 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6563
6564 /* Mute all inputs to mixer widget (even unconnected ones) */
6565 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6566 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6567 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6568 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6569 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6570 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6571 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6572 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6573
6574 { }
6575};
6576
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006577static struct hda_verb alc260_will_verbs[] = {
6578 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6579 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6580 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6581 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6582 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6583 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6584 {}
6585};
6586
6587static struct hda_verb alc260_replacer_672v_verbs[] = {
6588 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6589 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6590 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6591
6592 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6593 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6594 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6595
6596 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6597 {}
6598};
6599
6600/* toggle speaker-output according to the hp-jack state */
6601static void alc260_replacer_672v_automute(struct hda_codec *codec)
6602{
6603 unsigned int present;
6604
6605 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006606 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006607 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006608 snd_hda_codec_write_cache(codec, 0x01, 0,
6609 AC_VERB_SET_GPIO_DATA, 1);
6610 snd_hda_codec_write_cache(codec, 0x0f, 0,
6611 AC_VERB_SET_PIN_WIDGET_CONTROL,
6612 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006613 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006614 snd_hda_codec_write_cache(codec, 0x01, 0,
6615 AC_VERB_SET_GPIO_DATA, 0);
6616 snd_hda_codec_write_cache(codec, 0x0f, 0,
6617 AC_VERB_SET_PIN_WIDGET_CONTROL,
6618 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006619 }
6620}
6621
6622static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6623 unsigned int res)
6624{
6625 if ((res >> 26) == ALC880_HP_EVENT)
6626 alc260_replacer_672v_automute(codec);
6627}
6628
Kailang Yang3f878302008-08-26 13:02:23 +02006629static struct hda_verb alc260_hp_dc7600_verbs[] = {
6630 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6631 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6632 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6633 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6634 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6635 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6636 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6637 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6638 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6639 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6640 {}
6641};
6642
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006643/* Test configuration for debugging, modelled after the ALC880 test
6644 * configuration.
6645 */
6646#ifdef CONFIG_SND_DEBUG
6647static hda_nid_t alc260_test_dac_nids[1] = {
6648 0x02,
6649};
6650static hda_nid_t alc260_test_adc_nids[2] = {
6651 0x04, 0x05,
6652};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006653/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006654 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006655 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006656 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006657static struct hda_input_mux alc260_test_capture_sources[2] = {
6658 {
6659 .num_items = 7,
6660 .items = {
6661 { "MIC1 pin", 0x0 },
6662 { "MIC2 pin", 0x1 },
6663 { "LINE1 pin", 0x2 },
6664 { "LINE2 pin", 0x3 },
6665 { "CD pin", 0x4 },
6666 { "LINE-OUT pin", 0x5 },
6667 { "HP-OUT pin", 0x6 },
6668 },
6669 },
6670 {
6671 .num_items = 8,
6672 .items = {
6673 { "MIC1 pin", 0x0 },
6674 { "MIC2 pin", 0x1 },
6675 { "LINE1 pin", 0x2 },
6676 { "LINE2 pin", 0x3 },
6677 { "CD pin", 0x4 },
6678 { "Mixer", 0x5 },
6679 { "LINE-OUT pin", 0x6 },
6680 { "HP-OUT pin", 0x7 },
6681 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006682 },
6683};
6684static struct snd_kcontrol_new alc260_test_mixer[] = {
6685 /* Output driver widgets */
6686 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6687 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6688 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6689 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6690 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6691 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6692
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006693 /* Modes for retasking pin widgets
6694 * Note: the ALC260 doesn't seem to act on requests to enable mic
6695 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6696 * mention this restriction. At this stage it's not clear whether
6697 * this behaviour is intentional or is a hardware bug in chip
6698 * revisions available at least up until early 2006. Therefore for
6699 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6700 * choices, but if it turns out that the lack of mic bias for these
6701 * NIDs is intentional we could change their modes from
6702 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6703 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006704 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6705 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6706 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6707 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6708 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6709 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6710
6711 /* Loopback mixer controls */
6712 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6713 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6714 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6715 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6716 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6717 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6718 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6719 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6720 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6721 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006722 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6723 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6724 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6725 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006726
6727 /* Controls for GPIO pins, assuming they are configured as outputs */
6728 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6729 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6730 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6731 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6732
Jonathan Woithe92621f12006-02-28 11:47:47 +01006733 /* Switches to allow the digital IO pins to be enabled. The datasheet
6734 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006735 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006736 */
6737 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6738 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6739
Jonathan Woithef8225f62008-01-08 12:16:54 +01006740 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6741 * this output to turn on an external amplifier.
6742 */
6743 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6744 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6745
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006746 { } /* end */
6747};
6748static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006749 /* Enable all GPIOs as outputs with an initial value of 0 */
6750 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6751 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6752 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6753
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006754 /* Enable retasking pins as output, initially without power amp */
6755 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6756 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6757 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6758 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6759 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6760 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6761
Jonathan Woithe92621f12006-02-28 11:47:47 +01006762 /* Disable digital (SPDIF) pins initially, but users can enable
6763 * them via a mixer switch. In the case of SPDIF-out, this initverb
6764 * payload also sets the generation to 0, output to be in "consumer"
6765 * PCM format, copyright asserted, no pre-emphasis and no validity
6766 * control.
6767 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006768 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6769 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6770
Kailang Yangea1fb292008-08-26 12:58:38 +02006771 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006772 * OUT1 sum bus when acting as an output.
6773 */
6774 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6775 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6776 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6777 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6778
6779 /* Start with output sum widgets muted and their output gains at min */
6780 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6781 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6782 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6783 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6784 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6785 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6786 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6787 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6788 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6789
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006790 /* Unmute retasking pin widget output buffers since the default
6791 * state appears to be output. As the pin mode is changed by the
6792 * user the pin mode control will take care of enabling the pin's
6793 * input/output buffers as needed.
6794 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006795 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6796 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6797 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6798 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6799 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6800 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6801 /* Also unmute the mono-out pin widget */
6802 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6803
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006804 /* Mute capture amp left and right */
6805 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006806 /* Set ADC connection select to match default mixer setting (mic1
6807 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006808 */
6809 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6810
6811 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006812 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006813 */
6814 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6815 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6816
6817 /* Mute all inputs to mixer widget (even unconnected ones) */
6818 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6819 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6820 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6821 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6822 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6823 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6824 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6825 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6826
6827 { }
6828};
6829#endif
6830
Takashi Iwai63300792008-01-24 15:31:36 +01006831#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6832#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006833
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006834#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6835#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6836
Kailang Yangdf694da2005-12-05 19:42:22 +01006837/*
6838 * for BIOS auto-configuration
6839 */
6840
6841static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006842 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006843{
6844 hda_nid_t nid_vol;
6845 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006846 int err;
6847
6848 if (nid >= 0x0f && nid < 0x11) {
6849 nid_vol = nid - 0x7;
6850 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6851 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6852 } else if (nid == 0x11) {
6853 nid_vol = nid - 0x7;
6854 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6855 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6856 } else if (nid >= 0x12 && nid <= 0x15) {
6857 nid_vol = 0x08;
6858 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6859 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6860 } else
6861 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006862
Takashi Iwai863b4512008-10-21 17:01:47 +02006863 if (!(*vol_bits & (1 << nid_vol))) {
6864 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006865 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006866 if (err < 0)
6867 return err;
6868 *vol_bits |= (1 << nid_vol);
6869 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006870 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006871 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006872 return err;
6873 return 1;
6874}
6875
6876/* add playback controls from the parsed DAC table */
6877static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6878 const struct auto_pin_cfg *cfg)
6879{
6880 hda_nid_t nid;
6881 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006882 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006883
6884 spec->multiout.num_dacs = 1;
6885 spec->multiout.dac_nids = spec->private_dac_nids;
6886 spec->multiout.dac_nids[0] = 0x02;
6887
6888 nid = cfg->line_out_pins[0];
6889 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006890 const char *pfx;
6891 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6892 pfx = "Master";
6893 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6894 pfx = "Speaker";
6895 else
6896 pfx = "Front";
6897 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006898 if (err < 0)
6899 return err;
6900 }
6901
Takashi Iwai82bc9552006-03-21 11:24:42 +01006902 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006903 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006904 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006905 if (err < 0)
6906 return err;
6907 }
6908
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006909 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006910 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006911 err = alc260_add_playback_controls(spec, nid, "Headphone",
6912 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006913 if (err < 0)
6914 return err;
6915 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006916 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006917}
6918
6919/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006920static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006921 const struct auto_pin_cfg *cfg)
6922{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006923 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006924}
6925
6926static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6927 hda_nid_t nid, int pin_type,
6928 int sel_idx)
6929{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006930 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006931 /* need the manual connection? */
6932 if (nid >= 0x12) {
6933 int idx = nid - 0x12;
6934 snd_hda_codec_write(codec, idx + 0x0b, 0,
6935 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006936 }
6937}
6938
6939static void alc260_auto_init_multi_out(struct hda_codec *codec)
6940{
6941 struct alc_spec *spec = codec->spec;
6942 hda_nid_t nid;
6943
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006944 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006945 if (nid) {
6946 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6947 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6948 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006949
Takashi Iwai82bc9552006-03-21 11:24:42 +01006950 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006951 if (nid)
6952 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6953
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006954 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006955 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006956 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006957}
Kailang Yangdf694da2005-12-05 19:42:22 +01006958
6959#define ALC260_PIN_CD_NID 0x16
6960static void alc260_auto_init_analog_input(struct hda_codec *codec)
6961{
6962 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006963 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +01006964 int i;
6965
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006966 for (i = 0; i < cfg->num_inputs; i++) {
6967 hda_nid_t nid = cfg->inputs[i].pin;
Kailang Yangdf694da2005-12-05 19:42:22 +01006968 if (nid >= 0x12) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02006969 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006970 if (nid != ALC260_PIN_CD_NID &&
6971 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006972 snd_hda_codec_write(codec, nid, 0,
6973 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006974 AMP_OUT_MUTE);
6975 }
6976 }
6977}
6978
Takashi Iwai7f311a42010-04-09 17:32:23 +02006979#define alc260_auto_init_input_src alc880_auto_init_input_src
6980
Kailang Yangdf694da2005-12-05 19:42:22 +01006981/*
6982 * generic initialization of ADC, input mixers and output mixers
6983 */
6984static struct hda_verb alc260_volume_init_verbs[] = {
6985 /*
6986 * Unmute ADC0-1 and set the default input to mic-in
6987 */
6988 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6989 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6990 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6991 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006992
Kailang Yangdf694da2005-12-05 19:42:22 +01006993 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6994 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006995 * Note: PASD motherboards uses the Line In 2 as the input for
6996 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006997 */
6998 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006999 /* mute analog inputs */
7000 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7001 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7002 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7003 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7004 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007005
7006 /*
7007 * Set up output mixers (0x08 - 0x0a)
7008 */
7009 /* set vol=0 to output mixers */
7010 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7011 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7012 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7013 /* set up input amps for analog loopback */
7014 /* Amp Indices: DAC = 0, mixer = 1 */
7015 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7016 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7017 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7018 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7019 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7020 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02007021
Kailang Yangdf694da2005-12-05 19:42:22 +01007022 { }
7023};
7024
7025static int alc260_parse_auto_config(struct hda_codec *codec)
7026{
7027 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007028 int err;
7029 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
7030
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007031 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7032 alc260_ignore);
7033 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007034 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007035 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
7036 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01007037 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02007038 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01007039 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02007040 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007041 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007042 return err;
7043
7044 spec->multiout.max_channels = 2;
7045
Takashi Iwai0852d7a2009-02-11 11:35:15 +01007046 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007047 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02007048 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01007049 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01007050
Takashi Iwaid88897e2008-10-31 15:01:37 +01007051 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01007052
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007053 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007054 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007055
Kailang Yang6227cdc2010-02-25 08:36:52 +01007056 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02007057
Kailang Yangdf694da2005-12-05 19:42:22 +01007058 return 1;
7059}
7060
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007061/* additional initialization for auto-configuration model */
7062static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007063{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007064 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007065 alc260_auto_init_multi_out(codec);
7066 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02007067 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02007068 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007069 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007070 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007071}
7072
Takashi Iwaicb53c622007-08-10 17:21:45 +02007073#ifdef CONFIG_SND_HDA_POWER_SAVE
7074static struct hda_amp_list alc260_loopbacks[] = {
7075 { 0x07, HDA_INPUT, 0 },
7076 { 0x07, HDA_INPUT, 1 },
7077 { 0x07, HDA_INPUT, 2 },
7078 { 0x07, HDA_INPUT, 3 },
7079 { 0x07, HDA_INPUT, 4 },
7080 { } /* end */
7081};
7082#endif
7083
Kailang Yangdf694da2005-12-05 19:42:22 +01007084/*
Takashi Iwaifc091762010-08-04 23:53:36 +02007085 * Pin config fixes
7086 */
7087enum {
7088 PINFIX_HP_DC5750,
7089};
7090
Takashi Iwaifc091762010-08-04 23:53:36 +02007091static const struct alc_fixup alc260_fixups[] = {
7092 [PINFIX_HP_DC5750] = {
Takashi Iwai73413b12010-08-30 09:39:57 +02007093 .pins = (const struct alc_pincfg[]) {
7094 { 0x11, 0x90130110 }, /* speaker */
7095 { }
7096 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007097 },
7098};
7099
7100static struct snd_pci_quirk alc260_fixup_tbl[] = {
7101 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
7102 {}
7103};
7104
7105/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007106 * ALC260 configurations
7107 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007108static const char *alc260_models[ALC260_MODEL_LAST] = {
7109 [ALC260_BASIC] = "basic",
7110 [ALC260_HP] = "hp",
7111 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02007112 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007113 [ALC260_FUJITSU_S702X] = "fujitsu",
7114 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007115 [ALC260_WILL] = "will",
7116 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01007117 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007118#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007119 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007120#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007121 [ALC260_AUTO] = "auto",
7122};
7123
7124static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01007125 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05007126 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007127 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01007128 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01007129 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01007130 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007131 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02007132 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02007133 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007134 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
7135 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
7136 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
7137 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
7138 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
7139 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
7140 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
7141 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
7142 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007143 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007144 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02007145 {}
7146};
7147
Kailang Yangdf694da2005-12-05 19:42:22 +01007148static struct alc_config_preset alc260_presets[] = {
7149 [ALC260_BASIC] = {
7150 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007151 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007152 .init_verbs = { alc260_init_verbs },
7153 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7154 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007155 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01007156 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007157 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7158 .channel_mode = alc260_modes,
7159 .input_mux = &alc260_capture_source,
7160 },
7161 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01007162 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007163 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007164 .init_verbs = { alc260_init_verbs,
7165 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007166 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7167 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007168 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7169 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007170 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7171 .channel_mode = alc260_modes,
7172 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007173 .unsol_event = alc260_hp_unsol_event,
7174 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007175 },
Kailang Yang3f878302008-08-26 13:02:23 +02007176 [ALC260_HP_DC7600] = {
7177 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007178 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02007179 .init_verbs = { alc260_init_verbs,
7180 alc260_hp_dc7600_verbs },
7181 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7182 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007183 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7184 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02007185 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7186 .channel_mode = alc260_modes,
7187 .input_mux = &alc260_capture_source,
7188 .unsol_event = alc260_hp_3012_unsol_event,
7189 .init_hook = alc260_hp_3012_automute,
7190 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007191 [ALC260_HP_3013] = {
7192 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007193 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007194 .init_verbs = { alc260_hp_3013_init_verbs,
7195 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007196 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7197 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007198 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7199 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007200 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7201 .channel_mode = alc260_modes,
7202 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007203 .unsol_event = alc260_hp_3013_unsol_event,
7204 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007205 },
7206 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007207 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007208 .init_verbs = { alc260_fujitsu_init_verbs },
7209 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7210 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01007211 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7212 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007213 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7214 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007215 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
7216 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01007217 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007218 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007219 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007220 .init_verbs = { alc260_acer_init_verbs },
7221 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7222 .dac_nids = alc260_dac_nids,
7223 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7224 .adc_nids = alc260_dual_adc_nids,
7225 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7226 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007227 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
7228 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007229 },
Michael Schwingencc959482009-02-22 18:58:45 +01007230 [ALC260_FAVORIT100] = {
7231 .mixers = { alc260_favorit100_mixer },
7232 .init_verbs = { alc260_favorit100_init_verbs },
7233 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7234 .dac_nids = alc260_dac_nids,
7235 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7236 .adc_nids = alc260_dual_adc_nids,
7237 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7238 .channel_mode = alc260_modes,
7239 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
7240 .input_mux = alc260_favorit100_capture_sources,
7241 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007242 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007243 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007244 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
7245 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7246 .dac_nids = alc260_dac_nids,
7247 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7248 .adc_nids = alc260_adc_nids,
7249 .dig_out_nid = ALC260_DIGOUT_NID,
7250 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7251 .channel_mode = alc260_modes,
7252 .input_mux = &alc260_capture_source,
7253 },
7254 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007255 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007256 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
7257 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7258 .dac_nids = alc260_dac_nids,
7259 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7260 .adc_nids = alc260_adc_nids,
7261 .dig_out_nid = ALC260_DIGOUT_NID,
7262 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7263 .channel_mode = alc260_modes,
7264 .input_mux = &alc260_capture_source,
7265 .unsol_event = alc260_replacer_672v_unsol_event,
7266 .init_hook = alc260_replacer_672v_automute,
7267 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007268#ifdef CONFIG_SND_DEBUG
7269 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007270 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007271 .init_verbs = { alc260_test_init_verbs },
7272 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
7273 .dac_nids = alc260_test_dac_nids,
7274 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
7275 .adc_nids = alc260_test_adc_nids,
7276 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7277 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007278 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7279 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007280 },
7281#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007282};
7283
Linus Torvalds1da177e2005-04-16 15:20:36 -07007284static int patch_alc260(struct hda_codec *codec)
7285{
7286 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007287 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007288
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007289 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007290 if (spec == NULL)
7291 return -ENOMEM;
7292
7293 codec->spec = spec;
7294
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007295 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7296 alc260_models,
7297 alc260_cfg_tbl);
7298 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007299 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007300 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007301 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007302 }
7303
Takashi Iwaifc091762010-08-04 23:53:36 +02007304 if (board_config == ALC260_AUTO)
7305 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 1);
7306
Kailang Yangdf694da2005-12-05 19:42:22 +01007307 if (board_config == ALC260_AUTO) {
7308 /* automatic parse from the BIOS config */
7309 err = alc260_parse_auto_config(codec);
7310 if (err < 0) {
7311 alc_free(codec);
7312 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007313 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007314 printk(KERN_INFO
7315 "hda_codec: Cannot set up configuration "
7316 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007317 board_config = ALC260_BASIC;
7318 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007319 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007320
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007321 err = snd_hda_attach_beep_device(codec, 0x1);
7322 if (err < 0) {
7323 alc_free(codec);
7324 return err;
7325 }
7326
Kailang Yangdf694da2005-12-05 19:42:22 +01007327 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007328 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007329
Linus Torvalds1da177e2005-04-16 15:20:36 -07007330 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7331 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307332 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007333
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007334 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7335 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7336
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007337 if (!spec->adc_nids && spec->input_mux) {
7338 /* check whether NID 0x04 is valid */
7339 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007340 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007341 /* get type */
7342 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7343 spec->adc_nids = alc260_adc_nids_alt;
7344 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7345 } else {
7346 spec->adc_nids = alc260_adc_nids;
7347 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7348 }
7349 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007350 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007351 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007352
Takashi Iwaifc091762010-08-04 23:53:36 +02007353 if (board_config == ALC260_AUTO)
7354 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 0);
7355
Takashi Iwai2134ea42008-01-10 16:53:55 +01007356 spec->vmaster_nid = 0x08;
7357
Linus Torvalds1da177e2005-04-16 15:20:36 -07007358 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007359 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007360 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007361#ifdef CONFIG_SND_HDA_POWER_SAVE
7362 if (!spec->loopback.amplist)
7363 spec->loopback.amplist = alc260_loopbacks;
7364#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007365
7366 return 0;
7367}
7368
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007369
Linus Torvalds1da177e2005-04-16 15:20:36 -07007370/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007371 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007372 *
7373 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7374 * configuration. Each pin widget can choose any input DACs and a mixer.
7375 * Each ADC is connected from a mixer of all inputs. This makes possible
7376 * 6-channel independent captures.
7377 *
7378 * In addition, an independent DAC for the multi-playback (not used in this
7379 * driver yet).
7380 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007381#define ALC882_DIGOUT_NID 0x06
7382#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007383#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7384#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7385#define ALC1200_DIGOUT_NID 0x10
7386
Linus Torvalds1da177e2005-04-16 15:20:36 -07007387
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007388static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007389 { 8, NULL }
7390};
7391
Takashi Iwai4953550a2009-06-30 15:28:30 +02007392/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007393static hda_nid_t alc882_dac_nids[4] = {
7394 /* front, rear, clfe, rear_surr */
7395 0x02, 0x03, 0x04, 0x05
7396};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007397#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007398
Takashi Iwai4953550a2009-06-30 15:28:30 +02007399/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007400#define alc882_adc_nids alc880_adc_nids
7401#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007402#define alc883_adc_nids alc882_adc_nids_alt
7403static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7404static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7405#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007406
Takashi Iwaie1406342008-02-11 18:32:32 +01007407static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7408static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007409#define alc883_capsrc_nids alc882_capsrc_nids_alt
7410static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7411#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007412
Linus Torvalds1da177e2005-04-16 15:20:36 -07007413/* input MUX */
7414/* FIXME: should be a matrix-type input source selection */
7415
7416static struct hda_input_mux alc882_capture_source = {
7417 .num_items = 4,
7418 .items = {
7419 { "Mic", 0x0 },
7420 { "Front Mic", 0x1 },
7421 { "Line", 0x2 },
7422 { "CD", 0x4 },
7423 },
7424};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007425
Takashi Iwai4953550a2009-06-30 15:28:30 +02007426#define alc883_capture_source alc882_capture_source
7427
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007428static struct hda_input_mux alc889_capture_source = {
7429 .num_items = 3,
7430 .items = {
7431 { "Front Mic", 0x0 },
7432 { "Mic", 0x3 },
7433 { "Line", 0x2 },
7434 },
7435};
7436
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007437static struct hda_input_mux mb5_capture_source = {
7438 .num_items = 3,
7439 .items = {
7440 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307441 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007442 { "CD", 0x4 },
7443 },
7444};
7445
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007446static struct hda_input_mux macmini3_capture_source = {
7447 .num_items = 2,
7448 .items = {
7449 { "Line", 0x2 },
7450 { "CD", 0x4 },
7451 },
7452};
7453
Takashi Iwai4953550a2009-06-30 15:28:30 +02007454static struct hda_input_mux alc883_3stack_6ch_intel = {
7455 .num_items = 4,
7456 .items = {
7457 { "Mic", 0x1 },
7458 { "Front Mic", 0x0 },
7459 { "Line", 0x2 },
7460 { "CD", 0x4 },
7461 },
7462};
7463
7464static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7465 .num_items = 2,
7466 .items = {
7467 { "Mic", 0x1 },
7468 { "Line", 0x2 },
7469 },
7470};
7471
7472static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7473 .num_items = 4,
7474 .items = {
7475 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007476 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007477 { "Line", 0x2 },
7478 { "CD", 0x4 },
7479 },
7480};
7481
7482static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7483 .num_items = 2,
7484 .items = {
7485 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007486 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007487 },
7488};
7489
7490static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7491 .num_items = 3,
7492 .items = {
7493 { "Mic", 0x0 },
7494 { "Front Mic", 0x1 },
7495 { "Line", 0x4 },
7496 },
7497};
7498
7499static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7500 .num_items = 2,
7501 .items = {
7502 { "Mic", 0x0 },
7503 { "Line", 0x2 },
7504 },
7505};
7506
7507static struct hda_input_mux alc889A_mb31_capture_source = {
7508 .num_items = 2,
7509 .items = {
7510 { "Mic", 0x0 },
7511 /* Front Mic (0x01) unused */
7512 { "Line", 0x2 },
7513 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007514 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007515 },
7516};
7517
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007518static struct hda_input_mux alc889A_imac91_capture_source = {
7519 .num_items = 2,
7520 .items = {
7521 { "Mic", 0x01 },
7522 { "Line", 0x2 }, /* Not sure! */
7523 },
7524};
7525
Takashi Iwai4953550a2009-06-30 15:28:30 +02007526/*
7527 * 2ch mode
7528 */
7529static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7530 { 2, NULL }
7531};
7532
Kailang Yangdf694da2005-12-05 19:42:22 +01007533/*
Kailang Yang272a5272007-05-14 11:00:38 +02007534 * 2ch mode
7535 */
7536static struct hda_verb alc882_3ST_ch2_init[] = {
7537 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7538 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7539 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7540 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7541 { } /* end */
7542};
7543
7544/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007545 * 4ch mode
7546 */
7547static struct hda_verb alc882_3ST_ch4_init[] = {
7548 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7549 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7550 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7551 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7552 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7553 { } /* end */
7554};
7555
7556/*
Kailang Yang272a5272007-05-14 11:00:38 +02007557 * 6ch mode
7558 */
7559static struct hda_verb alc882_3ST_ch6_init[] = {
7560 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7561 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7562 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7563 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7564 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7565 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7566 { } /* end */
7567};
7568
Takashi Iwai4953550a2009-06-30 15:28:30 +02007569static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007570 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007571 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007572 { 6, alc882_3ST_ch6_init },
7573};
7574
Takashi Iwai4953550a2009-06-30 15:28:30 +02007575#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7576
Kailang Yang272a5272007-05-14 11:00:38 +02007577/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307578 * 2ch mode
7579 */
7580static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7581 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7582 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7583 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7584 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7585 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7586 { } /* end */
7587};
7588
7589/*
7590 * 4ch mode
7591 */
7592static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7593 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7594 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7595 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7596 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7597 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7598 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7599 { } /* end */
7600};
7601
7602/*
7603 * 6ch mode
7604 */
7605static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7606 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7607 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7608 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7609 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7610 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7611 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7612 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7613 { } /* end */
7614};
7615
7616static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7617 { 2, alc883_3ST_ch2_clevo_init },
7618 { 4, alc883_3ST_ch4_clevo_init },
7619 { 6, alc883_3ST_ch6_clevo_init },
7620};
7621
7622
7623/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007624 * 6ch mode
7625 */
7626static struct hda_verb alc882_sixstack_ch6_init[] = {
7627 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7628 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7629 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7630 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7631 { } /* end */
7632};
7633
7634/*
7635 * 8ch mode
7636 */
7637static struct hda_verb alc882_sixstack_ch8_init[] = {
7638 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7639 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7640 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7641 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7642 { } /* end */
7643};
7644
7645static struct hda_channel_mode alc882_sixstack_modes[2] = {
7646 { 6, alc882_sixstack_ch6_init },
7647 { 8, alc882_sixstack_ch8_init },
7648};
7649
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007650
7651/* Macbook Air 2,1 */
7652
7653static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7654 { 2, NULL },
7655};
7656
Takashi Iwai87350ad2007-08-16 18:19:38 +02007657/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007658 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007659 */
7660
7661/*
7662 * 2ch mode
7663 */
7664static struct hda_verb alc885_mbp_ch2_init[] = {
7665 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7666 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7667 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7668 { } /* end */
7669};
7670
7671/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007672 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007673 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007674static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007675 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7676 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7677 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7678 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7679 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7680 { } /* end */
7681};
7682
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007683static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007684 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007685 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007686};
7687
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007688/*
7689 * 2ch
7690 * Speakers/Woofer/HP = Front
7691 * LineIn = Input
7692 */
7693static struct hda_verb alc885_mb5_ch2_init[] = {
7694 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7695 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7696 { } /* end */
7697};
7698
7699/*
7700 * 6ch mode
7701 * Speakers/HP = Front
7702 * Woofer = LFE
7703 * LineIn = Surround
7704 */
7705static struct hda_verb alc885_mb5_ch6_init[] = {
7706 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7707 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7708 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7709 { } /* end */
7710};
7711
7712static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7713 { 2, alc885_mb5_ch2_init },
7714 { 6, alc885_mb5_ch6_init },
7715};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007716
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007717#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007718
7719/*
7720 * 2ch mode
7721 */
7722static struct hda_verb alc883_4ST_ch2_init[] = {
7723 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7724 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7725 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7726 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7727 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7728 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7729 { } /* end */
7730};
7731
7732/*
7733 * 4ch mode
7734 */
7735static struct hda_verb alc883_4ST_ch4_init[] = {
7736 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7737 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7738 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7739 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7740 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7741 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7742 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7743 { } /* end */
7744};
7745
7746/*
7747 * 6ch mode
7748 */
7749static struct hda_verb alc883_4ST_ch6_init[] = {
7750 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7751 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7752 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7753 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7754 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7755 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7756 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7757 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7758 { } /* end */
7759};
7760
7761/*
7762 * 8ch mode
7763 */
7764static struct hda_verb alc883_4ST_ch8_init[] = {
7765 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7766 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7767 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7768 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7769 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7770 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7771 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7772 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7773 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7774 { } /* end */
7775};
7776
7777static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7778 { 2, alc883_4ST_ch2_init },
7779 { 4, alc883_4ST_ch4_init },
7780 { 6, alc883_4ST_ch6_init },
7781 { 8, alc883_4ST_ch8_init },
7782};
7783
7784
7785/*
7786 * 2ch mode
7787 */
7788static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7789 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7790 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7791 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7792 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7793 { } /* end */
7794};
7795
7796/*
7797 * 4ch mode
7798 */
7799static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7800 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7801 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7802 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7803 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7804 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7805 { } /* end */
7806};
7807
7808/*
7809 * 6ch mode
7810 */
7811static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7812 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7813 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7814 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7815 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7816 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7817 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7818 { } /* end */
7819};
7820
7821static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7822 { 2, alc883_3ST_ch2_intel_init },
7823 { 4, alc883_3ST_ch4_intel_init },
7824 { 6, alc883_3ST_ch6_intel_init },
7825};
7826
7827/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007828 * 2ch mode
7829 */
7830static struct hda_verb alc889_ch2_intel_init[] = {
7831 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7832 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7833 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7834 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7835 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7836 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7837 { } /* end */
7838};
7839
7840/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007841 * 6ch mode
7842 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007843static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007844 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7845 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7846 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7847 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7848 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007849 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7850 { } /* end */
7851};
7852
7853/*
7854 * 8ch mode
7855 */
7856static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007857 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7858 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7859 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7860 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7861 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007862 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7863 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007864 { } /* end */
7865};
7866
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007867static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7868 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007869 { 6, alc889_ch6_intel_init },
7870 { 8, alc889_ch8_intel_init },
7871};
7872
7873/*
7874 * 6ch mode
7875 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007876static struct hda_verb alc883_sixstack_ch6_init[] = {
7877 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7878 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7879 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7880 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7881 { } /* end */
7882};
7883
7884/*
7885 * 8ch mode
7886 */
7887static struct hda_verb alc883_sixstack_ch8_init[] = {
7888 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7889 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7890 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7891 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7892 { } /* end */
7893};
7894
7895static struct hda_channel_mode alc883_sixstack_modes[2] = {
7896 { 6, alc883_sixstack_ch6_init },
7897 { 8, alc883_sixstack_ch8_init },
7898};
7899
7900
Linus Torvalds1da177e2005-04-16 15:20:36 -07007901/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7902 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7903 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007904static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007905 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007906 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007907 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007908 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007909 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7910 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007911 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7912 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007913 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007914 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007915 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7916 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7917 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7918 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7919 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7920 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007921 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007922 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7923 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007924 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007925 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007926 { } /* end */
7927};
7928
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007929/* Macbook Air 2,1 same control for HP and internal Speaker */
7930
7931static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7932 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7933 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7934 { }
7935};
7936
7937
Takashi Iwai87350ad2007-08-16 18:19:38 +02007938static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007939 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7940 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7941 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7942 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7943 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007944 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7945 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007946 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7947 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007948 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
7949 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007950 { } /* end */
7951};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007952
7953static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007954 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7955 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7956 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7957 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7958 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7959 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307960 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7961 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09307962 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7963 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007964 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7965 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007966 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
7967 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0x00, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007968 { } /* end */
7969};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007970
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007971static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7972 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7973 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7974 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7975 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7976 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7977 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7978 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7979 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7980 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7981 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007982 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007983 { } /* end */
7984};
7985
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007986static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007987 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7988 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007989 { } /* end */
7990};
7991
7992
Kailang Yangbdd148a2007-05-08 15:19:08 +02007993static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7994 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7995 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7996 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7997 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7998 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7999 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8000 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008001 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008002 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008003 { } /* end */
8004};
8005
Kailang Yang272a5272007-05-14 11:00:38 +02008006static struct snd_kcontrol_new alc882_targa_mixer[] = {
8007 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8008 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8009 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8010 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8011 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8012 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8013 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8014 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8015 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008016 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008017 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8018 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008019 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008020 { } /* end */
8021};
8022
8023/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
8024 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
8025 */
8026static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
8027 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8028 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8029 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8030 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8031 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8032 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8033 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8034 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8035 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
8036 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
8037 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8038 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008039 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008040 { } /* end */
8041};
8042
Takashi Iwai914759b2007-09-06 14:52:04 +02008043static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
8044 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8045 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8046 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8047 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8048 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8049 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8050 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8051 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008052 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008053 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008054 { } /* end */
8055};
8056
Kailang Yangdf694da2005-12-05 19:42:22 +01008057static struct snd_kcontrol_new alc882_chmode_mixer[] = {
8058 {
8059 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8060 .name = "Channel Mode",
8061 .info = alc_ch_mode_info,
8062 .get = alc_ch_mode_get,
8063 .put = alc_ch_mode_put,
8064 },
8065 { } /* end */
8066};
8067
Takashi Iwai4953550a2009-06-30 15:28:30 +02008068static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07008069 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008070 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8071 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008072 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008073 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8074 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008075 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008076 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8077 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008078 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008079 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8080 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008081
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008082 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008083 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008084 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008085 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008086 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008087 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008088 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008089 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008090 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008091 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008092 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008093 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008094 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008095 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008096 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008097 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008098 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008099 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008100 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8101 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008102 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008103 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8104 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008105 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008106 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8107 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8108 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8109 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8110 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008111 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008112 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008113
8114 /* FIXME: use matrix-type input source selection */
8115 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008116 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008117 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008118 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008119 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02008120 /* ADC2: mute amp left and right */
8121 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008122 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02008123 /* ADC3: mute amp left and right */
8124 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008125 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008126
8127 { }
8128};
8129
Takashi Iwai4953550a2009-06-30 15:28:30 +02008130static struct hda_verb alc882_adc1_init_verbs[] = {
8131 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8132 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8133 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8134 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8135 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8136 /* ADC1: mute amp left and right */
8137 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8138 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8139 { }
8140};
8141
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008142static struct hda_verb alc882_eapd_verbs[] = {
8143 /* change to EAPD mode */
8144 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008145 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008146 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008147};
8148
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008149static struct hda_verb alc889_eapd_verbs[] = {
8150 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8151 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8152 { }
8153};
8154
Wu Fengguang6732bd02009-07-30 09:19:14 +02008155static struct hda_verb alc_hp15_unsol_verbs[] = {
8156 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8157 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8158 {}
8159};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008160
8161static struct hda_verb alc885_init_verbs[] = {
8162 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01008163 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8164 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008165 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008166 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8167 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008168 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008169 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8170 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008171 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008172 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8173 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008174
8175 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02008176 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008177 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8178 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8179 /* Front Pin: output 0 (0x0c) */
8180 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8181 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8182 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8183 /* Rear Pin: output 1 (0x0d) */
8184 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8185 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8186 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
8187 /* CLFE Pin: output 2 (0x0e) */
8188 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8189 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8190 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8191 /* Side Pin: output 3 (0x0f) */
8192 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8193 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8194 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8195 /* Mic (rear) pin: input vref at 80% */
8196 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8197 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8198 /* Front Mic pin: input vref at 80% */
8199 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8200 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8201 /* Line In pin: input */
8202 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8203 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8204
8205 /* Mixer elements: 0x18, , 0x1a, 0x1b */
8206 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01008207 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008208 /* Input mixer2 */
8209 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008210 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008211 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008212 /* ADC2: mute amp left and right */
8213 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8214 /* ADC3: mute amp left and right */
8215 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8216
8217 { }
8218};
8219
8220static struct hda_verb alc885_init_input_verbs[] = {
8221 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8222 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8223 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8224 { }
8225};
8226
8227
8228/* Unmute Selector 24h and set the default input to front mic */
8229static struct hda_verb alc889_init_input_verbs[] = {
8230 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8231 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8232 { }
8233};
8234
8235
Takashi Iwai4953550a2009-06-30 15:28:30 +02008236#define alc883_init_verbs alc882_base_init_verbs
8237
Tobin Davis9102cd12006-12-15 10:02:12 +01008238/* Mac Pro test */
8239static struct snd_kcontrol_new alc882_macpro_mixer[] = {
8240 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8241 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8242 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
8243 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8244 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008245 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01008246 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
8247 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008248 */
Tobin Davis9102cd12006-12-15 10:02:12 +01008249 { } /* end */
8250};
8251
8252static struct hda_verb alc882_macpro_init_verbs[] = {
8253 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8254 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8255 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8256 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8257 /* Front Pin: output 0 (0x0c) */
8258 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8259 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8260 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8261 /* Front Mic pin: input vref at 80% */
8262 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8263 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8264 /* Speaker: output */
8265 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8266 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8267 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
8268 /* Headphone output (output 0 - 0x0c) */
8269 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8270 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8271 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8272
8273 /* FIXME: use matrix-type input source selection */
8274 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8275 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8276 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8277 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8278 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8279 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8280 /* Input mixer2 */
8281 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8282 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8283 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8284 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8285 /* Input mixer3 */
8286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8288 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8289 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8290 /* ADC1: mute amp left and right */
8291 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8292 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8293 /* ADC2: mute amp left and right */
8294 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8295 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8296 /* ADC3: mute amp left and right */
8297 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8298 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8299
8300 { }
8301};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008302
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008303/* Macbook 5,1 */
8304static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008305 /* DACs */
8306 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8307 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8308 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8309 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008310 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008311 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8312 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8313 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008314 /* Surround mixer */
8315 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8316 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8317 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8318 /* LFE mixer */
8319 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8320 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8321 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8322 /* HP mixer */
8323 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8324 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8325 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8326 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008327 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8328 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008329 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8330 /* LFE Pin (0x0e) */
8331 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8332 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8333 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8334 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008335 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8336 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008337 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308338 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008339 /* Front Mic pin: input vref at 80% */
8340 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8341 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8342 /* Line In pin */
8343 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8344 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8345
Alex Murrayb8f171e2010-06-14 12:08:43 +09308346 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8347 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8348 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008349 { }
8350};
8351
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008352/* Macmini 3,1 */
8353static struct hda_verb alc885_macmini3_init_verbs[] = {
8354 /* DACs */
8355 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8356 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8357 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8358 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8359 /* Front mixer */
8360 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8361 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8362 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8363 /* Surround mixer */
8364 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8365 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8366 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8367 /* LFE mixer */
8368 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8369 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8370 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8371 /* HP mixer */
8372 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8373 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8374 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8375 /* Front Pin (0x0c) */
8376 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8377 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8378 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8379 /* LFE Pin (0x0e) */
8380 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8381 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8382 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8383 /* HP Pin (0x0f) */
8384 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8385 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8386 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8387 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8388 /* Line In pin */
8389 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8390 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8391
8392 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8393 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8394 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8395 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8396 { }
8397};
8398
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008399
8400static struct hda_verb alc885_mba21_init_verbs[] = {
8401 /*Internal and HP Speaker Mixer*/
8402 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8403 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8404 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8405 /*Internal Speaker Pin (0x0c)*/
8406 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8407 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8408 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8409 /* HP Pin: output 0 (0x0e) */
8410 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8411 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8412 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8413 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8414 /* Line in (is hp when jack connected)*/
8415 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8416 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8417
8418 { }
8419 };
8420
8421
Takashi Iwai87350ad2007-08-16 18:19:38 +02008422/* Macbook Pro rev3 */
8423static struct hda_verb alc885_mbp3_init_verbs[] = {
8424 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8425 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8426 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8427 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8428 /* Rear mixer */
8429 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8430 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8431 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008432 /* HP mixer */
8433 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8434 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8435 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008436 /* Front Pin: output 0 (0x0c) */
8437 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8438 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8439 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008440 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008441 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008442 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8443 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008444 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8445 /* Mic (rear) pin: input vref at 80% */
8446 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8447 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8448 /* Front Mic pin: input vref at 80% */
8449 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8450 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8451 /* Line In pin: use output 1 when in LineOut mode */
8452 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8453 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8454 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8455
8456 /* FIXME: use matrix-type input source selection */
8457 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8458 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8459 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8460 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8461 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8462 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8463 /* Input mixer2 */
8464 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8465 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8466 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8467 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8468 /* Input mixer3 */
8469 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8470 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8471 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8472 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8473 /* ADC1: mute amp left and right */
8474 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8475 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8476 /* ADC2: mute amp left and right */
8477 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8478 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8479 /* ADC3: mute amp left and right */
8480 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8481 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8482
8483 { }
8484};
8485
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008486/* iMac 9,1 */
8487static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008488 /* Internal Speaker Pin (0x0c) */
8489 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8490 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8491 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8492 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8493 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8494 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8495 /* HP Pin: Rear */
8496 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8497 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8498 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8499 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8500 /* Line in Rear */
8501 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8502 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8503 /* Front Mic pin: input vref at 80% */
8504 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8505 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008506 /* Rear mixer */
8507 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8508 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8509 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008510 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8511 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8512 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8513 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8514 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008515 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8516 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8517 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8518 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008519 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008520 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8521 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8522 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8523 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008524 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008525 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8526 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8527 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8528 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008529 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008530 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8531 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008532 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008533 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8534 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008535 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008536 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8537 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008538 { }
8539};
8540
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008541/* iMac 24 mixer. */
8542static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8543 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8544 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8545 { } /* end */
8546};
8547
8548/* iMac 24 init verbs. */
8549static struct hda_verb alc885_imac24_init_verbs[] = {
8550 /* Internal speakers: output 0 (0x0c) */
8551 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8552 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8553 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8554 /* Internal speakers: output 0 (0x0c) */
8555 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8556 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8557 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8558 /* Headphone: output 0 (0x0c) */
8559 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8560 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8561 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8562 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8563 /* Front Mic: input vref at 80% */
8564 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8565 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8566 { }
8567};
8568
8569/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008570static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008571{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008572 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008573
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008574 spec->autocfg.hp_pins[0] = 0x14;
8575 spec->autocfg.speaker_pins[0] = 0x18;
8576 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008577}
8578
Takashi Iwai9d54f082010-02-22 08:34:40 +01008579#define alc885_mb5_setup alc885_imac24_setup
8580#define alc885_macmini3_setup alc885_imac24_setup
8581
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008582/* Macbook Air 2,1 */
8583static void alc885_mba21_setup(struct hda_codec *codec)
8584{
8585 struct alc_spec *spec = codec->spec;
8586
8587 spec->autocfg.hp_pins[0] = 0x14;
8588 spec->autocfg.speaker_pins[0] = 0x18;
8589}
8590
8591
8592
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008593static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008594{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008595 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008596
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008597 spec->autocfg.hp_pins[0] = 0x15;
8598 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008599}
8600
Takashi Iwai9d54f082010-02-22 08:34:40 +01008601static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308602{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008603 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308604
Takashi Iwai9d54f082010-02-22 08:34:40 +01008605 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008606 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008607 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008608}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008609
Kailang Yang272a5272007-05-14 11:00:38 +02008610static struct hda_verb alc882_targa_verbs[] = {
8611 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8612 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8613
8614 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8615 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008616
Kailang Yang272a5272007-05-14 11:00:38 +02008617 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8618 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8619 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8620
8621 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008622 { } /* end */
8623};
8624
8625/* toggle speaker-output according to the hp-jack state */
8626static void alc882_targa_automute(struct hda_codec *codec)
8627{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008628 struct alc_spec *spec = codec->spec;
8629 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008630 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008631 spec->jack_present ? 1 : 3);
8632}
8633
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008634static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008635{
8636 struct alc_spec *spec = codec->spec;
8637
8638 spec->autocfg.hp_pins[0] = 0x14;
8639 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008640}
8641
8642static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8643{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008644 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008645 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008646}
8647
8648static struct hda_verb alc882_asus_a7j_verbs[] = {
8649 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8650 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8651
8652 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8653 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8654 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008655
Kailang Yang272a5272007-05-14 11:00:38 +02008656 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8657 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8658 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8659
8660 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8661 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8662 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8663 { } /* end */
8664};
8665
Takashi Iwai914759b2007-09-06 14:52:04 +02008666static struct hda_verb alc882_asus_a7m_verbs[] = {
8667 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8668 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8669
8670 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8671 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8672 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008673
Takashi Iwai914759b2007-09-06 14:52:04 +02008674 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8675 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8676 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8677
8678 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8679 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8680 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8681 { } /* end */
8682};
8683
Tobin Davis9102cd12006-12-15 10:02:12 +01008684static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8685{
8686 unsigned int gpiostate, gpiomask, gpiodir;
8687
8688 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8689 AC_VERB_GET_GPIO_DATA, 0);
8690
8691 if (!muted)
8692 gpiostate |= (1 << pin);
8693 else
8694 gpiostate &= ~(1 << pin);
8695
8696 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8697 AC_VERB_GET_GPIO_MASK, 0);
8698 gpiomask |= (1 << pin);
8699
8700 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8701 AC_VERB_GET_GPIO_DIRECTION, 0);
8702 gpiodir |= (1 << pin);
8703
8704
8705 snd_hda_codec_write(codec, codec->afg, 0,
8706 AC_VERB_SET_GPIO_MASK, gpiomask);
8707 snd_hda_codec_write(codec, codec->afg, 0,
8708 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8709
8710 msleep(1);
8711
8712 snd_hda_codec_write(codec, codec->afg, 0,
8713 AC_VERB_SET_GPIO_DATA, gpiostate);
8714}
8715
Takashi Iwai7debbe52007-08-16 15:01:03 +02008716/* set up GPIO at initialization */
8717static void alc885_macpro_init_hook(struct hda_codec *codec)
8718{
8719 alc882_gpio_mute(codec, 0, 0);
8720 alc882_gpio_mute(codec, 1, 0);
8721}
8722
8723/* set up GPIO and update auto-muting at initialization */
8724static void alc885_imac24_init_hook(struct hda_codec *codec)
8725{
8726 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008727 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008728}
8729
Kailang Yangdf694da2005-12-05 19:42:22 +01008730/*
8731 * generic initialization of ADC, input mixers and output mixers
8732 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008733static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008734 /*
8735 * Unmute ADC0-2 and set the default input to mic-in
8736 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008737 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8738 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8739 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8740 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8741
Kailang Yangdf694da2005-12-05 19:42:22 +01008742 /*
8743 * Set up output mixers (0x0c - 0x0f)
8744 */
8745 /* set vol=0 to output mixers */
8746 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8747 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8748 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8749 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8750 /* set up input amps for analog loopback */
8751 /* Amp Indices: DAC = 0, mixer = 1 */
8752 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8753 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8754 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8755 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8756 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8757 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8758 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8759 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8760 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8761 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8762
8763 /* FIXME: use matrix-type input source selection */
8764 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008765 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008766 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008767 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008768 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008769 { }
8770};
8771
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008772/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8773static struct hda_verb alc889A_mb31_ch2_init[] = {
8774 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8775 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8776 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8777 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8778 { } /* end */
8779};
8780
8781/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8782static struct hda_verb alc889A_mb31_ch4_init[] = {
8783 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8784 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8785 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8786 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8787 { } /* end */
8788};
8789
8790/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8791static struct hda_verb alc889A_mb31_ch5_init[] = {
8792 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8793 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8794 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8795 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8796 { } /* end */
8797};
8798
8799/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8800static struct hda_verb alc889A_mb31_ch6_init[] = {
8801 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8802 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8803 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8804 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8805 { } /* end */
8806};
8807
8808static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8809 { 2, alc889A_mb31_ch2_init },
8810 { 4, alc889A_mb31_ch4_init },
8811 { 5, alc889A_mb31_ch5_init },
8812 { 6, alc889A_mb31_ch6_init },
8813};
8814
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008815static struct hda_verb alc883_medion_eapd_verbs[] = {
8816 /* eanable EAPD on medion laptop */
8817 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8818 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8819 { }
8820};
8821
Takashi Iwai4953550a2009-06-30 15:28:30 +02008822#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008823
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008824static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8825 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8826 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8827 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8828 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8829 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8830 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8831 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8832 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008833 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008834 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8835 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008836 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008837 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008838 { } /* end */
8839};
8840
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008841static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008842 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8843 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8844 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8845 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8846 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008847 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008848 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008849 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008850 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008851 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008852 { } /* end */
8853};
8854
Jiang zhefb97dc62008-03-06 11:07:11 +01008855static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8856 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8857 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8858 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8859 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8860 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008861 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008862 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008863 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008864 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008865 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008866 { } /* end */
8867};
8868
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008869static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8870 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8871 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8872 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8873 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8874 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8875 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8876 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8877 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008878 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008879 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8880 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008881 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008882 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008883 { } /* end */
8884};
8885
8886static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8887 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8888 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8889 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8890 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8891 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8892 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8893 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8894 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8895 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8896 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8897 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8898 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8899 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8900 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008901 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008902 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8903 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008904 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008905 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008906 { } /* end */
8907};
8908
Jiang zhe17bba1b2008-06-04 12:11:07 +02008909static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8910 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8911 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8912 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8913 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8914 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8915 HDA_OUTPUT),
8916 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8917 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8918 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8919 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8920 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8921 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8922 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8923 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8924 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008925 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008926 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8927 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008928 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008929 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008930 { } /* end */
8931};
8932
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008933static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8934 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8935 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8936 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8937 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8938 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8939 HDA_OUTPUT),
8940 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8941 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8942 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8943 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8944 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8945 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8946 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8947 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8948 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008949 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008950 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8951 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008952 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008953 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8954 { } /* end */
8955};
8956
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008957static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008958 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008959 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008960 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008961 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008962 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8963 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008964 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8965 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008966 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8967 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8968 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8969 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8970 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8971 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008972 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008973 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8974 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008975 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008976 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008977 { } /* end */
8978};
8979
Sasha Alexandrc2592492009-06-16 14:52:54 -04008980static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008981 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008982 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008983 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008984 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008985 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8986 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8987 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),
8989 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),
8991 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8992 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8993 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8994 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8995 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008996 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008997 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008998 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008999};
Kailang Yangccc656c2006-10-17 12:32:26 +02009000
Sasha Alexandrc2592492009-06-16 14:52:54 -04009001static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009002 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009003 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009004 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009005 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009006 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9007 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9008 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009009 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009010 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009011 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009012 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009013 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009014 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009015};
Kailang Yangccc656c2006-10-17 12:32:26 +02009016
Takashi Iwaib99dba32009-09-17 18:23:00 +02009017static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
9018 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9019 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009020 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009021 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009022 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009023 { } /* end */
9024};
9025
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009026static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
9027 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9028 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009029 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9030 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009031 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9032 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009033 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009034 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009035 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009036};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009037
Kailang Yang272a5272007-05-14 11:00:38 +02009038static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
9039 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9040 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
9041 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9042 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9043 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9044 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9045 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009046 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9047 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02009048 { } /* end */
9049};
9050
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009051static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
9052 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9053 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9054 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9055 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
9056 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
9057 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
9058 { } /* end */
9059};
9060
9061static struct hda_verb alc883_medion_wim2160_verbs[] = {
9062 /* Unmute front mixer */
9063 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9064 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9065
9066 /* Set speaker pin to front mixer */
9067 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9068
9069 /* Init headphone pin */
9070 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9071 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9072 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9073 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9074
9075 { } /* end */
9076};
9077
9078/* toggle speaker-output according to the hp-jack state */
9079static void alc883_medion_wim2160_setup(struct hda_codec *codec)
9080{
9081 struct alc_spec *spec = codec->spec;
9082
9083 spec->autocfg.hp_pins[0] = 0x1a;
9084 spec->autocfg.speaker_pins[0] = 0x15;
9085}
9086
Tobin Davis2880a862007-08-07 11:50:26 +02009087static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02009088 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9089 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009090 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009091 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9092 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009093 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009094 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009095 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009096 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02009097};
Tobin Davis2880a862007-08-07 11:50:26 +02009098
Tony Vroond2fd4b02009-06-21 00:40:10 +01009099static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
9100 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009101 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01009102 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9103 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009104 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9105 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9106 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009107 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009108 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9109 { } /* end */
9110};
9111
Kailang Yange2757d52008-08-26 13:17:46 +02009112static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
9113 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9114 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9115 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9116 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
9117 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
9118 0x0d, 1, 0x0, HDA_OUTPUT),
9119 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
9120 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
9121 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
9122 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9123 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009124 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9125 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9126 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9127 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9128 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009129 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009130 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9131 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009132 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009133 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009134 { } /* end */
9135};
9136
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009137static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
9138 /* Output mixers */
9139 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
9140 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
9141 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
9142 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
9143 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
9144 HDA_OUTPUT),
9145 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
9146 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
9147 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
9148 /* Output switches */
9149 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
9150 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
9151 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
9152 /* Boost mixers */
David Henningsson5f99f862011-01-04 15:24:24 +01009153 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
9154 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009155 /* Input mixers */
9156 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
9157 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
9158 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9159 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9160 { } /* end */
9161};
9162
Guido Günther3e1647c2009-06-05 00:47:26 +02009163static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
9164 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9165 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9166 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9167 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009168 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Guido Günther3e1647c2009-06-05 00:47:26 +02009169 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9170 { } /* end */
9171};
9172
Kailang Yange2757d52008-08-26 13:17:46 +02009173static struct hda_bind_ctls alc883_bind_cap_vol = {
9174 .ops = &snd_hda_bind_vol,
9175 .values = {
9176 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9177 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9178 0
9179 },
9180};
9181
9182static struct hda_bind_ctls alc883_bind_cap_switch = {
9183 .ops = &snd_hda_bind_sw,
9184 .values = {
9185 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9186 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9187 0
9188 },
9189};
9190
9191static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
9192 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9193 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9194 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9195 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9196 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9197 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009198 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009199 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009200 { } /* end */
9201};
9202
9203static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009204 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
9205 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
9206 {
9207 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9208 /* .name = "Capture Source", */
9209 .name = "Input Source",
9210 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009211 .info = alc_mux_enum_info,
9212 .get = alc_mux_enum_get,
9213 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02009214 },
9215 { } /* end */
9216};
9217
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009218static struct snd_kcontrol_new alc883_chmode_mixer[] = {
9219 {
9220 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9221 .name = "Channel Mode",
9222 .info = alc_ch_mode_info,
9223 .get = alc_ch_mode_get,
9224 .put = alc_ch_mode_put,
9225 },
9226 { } /* end */
9227};
9228
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009229/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009230static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009231{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009232 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009233
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009234 spec->autocfg.hp_pins[0] = 0x15;
9235 spec->autocfg.speaker_pins[0] = 0x14;
9236 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009237}
9238
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009239static struct hda_verb alc883_mitac_verbs[] = {
9240 /* HP */
9241 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9242 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9243 /* Subwoofer */
9244 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9245 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9246
9247 /* enable unsolicited event */
9248 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9249 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
9250
9251 { } /* end */
9252};
9253
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309254static struct hda_verb alc883_clevo_m540r_verbs[] = {
9255 /* HP */
9256 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9257 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9258 /* Int speaker */
9259 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9260
9261 /* enable unsolicited event */
9262 /*
9263 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9264 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9265 */
9266
9267 { } /* end */
9268};
9269
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009270static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009271 /* HP */
9272 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9273 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9274 /* Int speaker */
9275 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9276 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9277
9278 /* enable unsolicited event */
9279 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009280 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009281
9282 { } /* end */
9283};
9284
Jiang zhefb97dc62008-03-06 11:07:11 +01009285static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9286 /* HP */
9287 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9288 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9289 /* Subwoofer */
9290 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9291 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9292
9293 /* enable unsolicited event */
9294 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9295
9296 { } /* end */
9297};
9298
Sasha Alexandrc2592492009-06-16 14:52:54 -04009299static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009300 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9301 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9302
9303 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9304 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009305
David Heidelberger64a8be72009-06-08 16:15:18 +02009306/* Connect Line-Out side jack (SPDIF) to Side */
9307 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9308 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9309 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9310/* Connect Mic jack to CLFE */
9311 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9312 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9313 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9314/* Connect Line-in jack to Surround */
9315 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9316 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9317 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9318/* Connect HP out jack to Front */
9319 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9320 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9321 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009322
9323 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009324
9325 { } /* end */
9326};
9327
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009328static struct hda_verb alc883_lenovo_101e_verbs[] = {
9329 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9330 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9331 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9332 { } /* end */
9333};
9334
Kailang Yang272a5272007-05-14 11:00:38 +02009335static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9336 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9337 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9338 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9339 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9340 { } /* end */
9341};
9342
9343static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
9344 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9345 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9346 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9347 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9348 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9349 { } /* end */
9350};
9351
Kailang Yang189609a2007-08-20 11:31:23 +02009352static struct hda_verb alc883_haier_w66_verbs[] = {
9353 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9354 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9355
9356 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9357
9358 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9359 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9360 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9361 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9362 { } /* end */
9363};
9364
Kailang Yange2757d52008-08-26 13:17:46 +02009365static struct hda_verb alc888_lenovo_sky_verbs[] = {
9366 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9367 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9368 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9369 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9370 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9371 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9372 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9373 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9374 { } /* end */
9375};
9376
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009377static struct hda_verb alc888_6st_dell_verbs[] = {
9378 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9379 { }
9380};
9381
Guido Günther3e1647c2009-06-05 00:47:26 +02009382static struct hda_verb alc883_vaiott_verbs[] = {
9383 /* HP */
9384 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9385 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9386
9387 /* enable unsolicited event */
9388 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9389
9390 { } /* end */
9391};
9392
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009393static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009394{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009395 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009396
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009397 spec->autocfg.hp_pins[0] = 0x1b;
9398 spec->autocfg.speaker_pins[0] = 0x14;
9399 spec->autocfg.speaker_pins[1] = 0x16;
9400 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009401}
9402
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009403static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009404 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009405 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9406 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009407 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009408 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009409};
9410
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009411/*
9412 * 2ch mode
9413 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009414static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009415 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9416 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9417 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9418 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009419 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009420};
9421
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009422/*
9423 * 4ch mode
9424 */
9425static struct hda_verb alc888_3st_hp_4ch_init[] = {
9426 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9427 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9428 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9429 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9430 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9431 { } /* end */
9432};
9433
9434/*
9435 * 6ch mode
9436 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009437static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009438 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9439 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009440 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009441 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9442 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009443 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9444 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009445};
9446
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009447static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009448 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009449 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009450 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009451};
9452
Kailang Yang272a5272007-05-14 11:00:38 +02009453/* toggle front-jack and RCA according to the hp-jack state */
9454static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9455{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009456 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02009457
Takashi Iwai47fd8302007-08-10 17:11:07 +02009458 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9459 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9460 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9461 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009462}
9463
9464/* toggle RCA according to the front-jack state */
9465static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9466{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009467 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009468
Takashi Iwai47fd8302007-08-10 17:11:07 +02009469 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9470 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009471}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009472
Kailang Yang272a5272007-05-14 11:00:38 +02009473static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9474 unsigned int res)
9475{
9476 if ((res >> 26) == ALC880_HP_EVENT)
9477 alc888_lenovo_ms7195_front_automute(codec);
9478 if ((res >> 26) == ALC880_FRONT_EVENT)
9479 alc888_lenovo_ms7195_rca_automute(codec);
9480}
9481
Kailang Yang272a5272007-05-14 11:00:38 +02009482/* toggle speaker-output according to the hp-jack state */
Takashi Iwaidc4271702010-11-29 07:42:59 +01009483static void alc883_lenovo_nb0763_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009484{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009485 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009486
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009487 spec->autocfg.hp_pins[0] = 0x14;
9488 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009489}
9490
Kailang Yangccc656c2006-10-17 12:32:26 +02009491/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009492#define alc883_targa_init_hook alc882_targa_init_hook
9493#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009494
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009495static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009496{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009497 struct alc_spec *spec = codec->spec;
9498
9499 spec->autocfg.hp_pins[0] = 0x15;
9500 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009501}
9502
9503static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9504{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009505 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01009506 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009507}
9508
9509static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009510 unsigned int res)
9511{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009512 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009513 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01009514 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009515 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009516 default:
9517 alc_automute_amp_unsol_event(codec, res);
9518 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009519 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009520}
9521
Jiang zhefb97dc62008-03-06 11:07:11 +01009522/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009523static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009524{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009525 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009526
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009527 spec->autocfg.hp_pins[0] = 0x14;
9528 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009529}
9530
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009531static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009532{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009533 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009534
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009535 spec->autocfg.hp_pins[0] = 0x1b;
9536 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009537}
9538
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009539static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9540{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009541 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009542
Takashi Iwai47fd8302007-08-10 17:11:07 +02009543 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9544 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009545}
9546
9547static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9548{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009549 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009550
Takashi Iwai47fd8302007-08-10 17:11:07 +02009551 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9552 HDA_AMP_MUTE, bits);
9553 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9554 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009555}
9556
9557static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9558 unsigned int res)
9559{
9560 if ((res >> 26) == ALC880_HP_EVENT)
9561 alc883_lenovo_101e_all_automute(codec);
9562 if ((res >> 26) == ALC880_FRONT_EVENT)
9563 alc883_lenovo_101e_ispeaker_automute(codec);
9564}
9565
Takashi Iwai676a9b52007-08-16 15:23:35 +02009566/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009567static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009568{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009569 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009570
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009571 spec->autocfg.hp_pins[0] = 0x14;
9572 spec->autocfg.speaker_pins[0] = 0x15;
9573 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009574}
9575
Kailang Yangd1a991a2007-08-15 16:21:59 +02009576static struct hda_verb alc883_acer_eapd_verbs[] = {
9577 /* HP Pin: output 0 (0x0c) */
9578 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9579 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9580 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9581 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009582 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9583 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009584 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009585 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9586 /* eanable EAPD on medion laptop */
9587 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9588 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009589 /* enable unsolicited event */
9590 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009591 { }
9592};
9593
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009594static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009595{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009596 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009597
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009598 spec->autocfg.hp_pins[0] = 0x1b;
9599 spec->autocfg.speaker_pins[0] = 0x14;
9600 spec->autocfg.speaker_pins[1] = 0x15;
9601 spec->autocfg.speaker_pins[2] = 0x16;
9602 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009603}
9604
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009605static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009606{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009607 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009608
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009609 spec->autocfg.hp_pins[0] = 0x1b;
9610 spec->autocfg.speaker_pins[0] = 0x14;
9611 spec->autocfg.speaker_pins[1] = 0x15;
9612 spec->autocfg.speaker_pins[2] = 0x16;
9613 spec->autocfg.speaker_pins[3] = 0x17;
9614 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009615}
9616
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009617static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009618{
9619 struct alc_spec *spec = codec->spec;
9620
9621 spec->autocfg.hp_pins[0] = 0x15;
9622 spec->autocfg.speaker_pins[0] = 0x14;
9623 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009624}
9625
Kailang Yange2757d52008-08-26 13:17:46 +02009626static struct hda_verb alc888_asus_m90v_verbs[] = {
9627 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9628 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9629 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9630 /* enable unsolicited event */
9631 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9632 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9633 { } /* end */
9634};
9635
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009636static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009637{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009638 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009639
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009640 spec->autocfg.hp_pins[0] = 0x1b;
9641 spec->autocfg.speaker_pins[0] = 0x14;
9642 spec->autocfg.speaker_pins[1] = 0x15;
9643 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009644 spec->ext_mic.pin = 0x18;
9645 spec->int_mic.pin = 0x19;
9646 spec->ext_mic.mux_idx = 0;
9647 spec->int_mic.mux_idx = 1;
9648 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009649}
9650
9651static struct hda_verb alc888_asus_eee1601_verbs[] = {
9652 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9653 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9654 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9655 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9656 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9657 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9658 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9659 /* enable unsolicited event */
9660 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9661 { } /* end */
9662};
9663
Kailang Yange2757d52008-08-26 13:17:46 +02009664static void alc883_eee1601_inithook(struct hda_codec *codec)
9665{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009666 struct alc_spec *spec = codec->spec;
9667
9668 spec->autocfg.hp_pins[0] = 0x14;
9669 spec->autocfg.speaker_pins[0] = 0x1b;
9670 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009671}
9672
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009673static struct hda_verb alc889A_mb31_verbs[] = {
9674 /* Init rear pin (used as headphone output) */
9675 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9676 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9677 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9678 /* Init line pin (used as output in 4ch and 6ch mode) */
9679 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9680 /* Init line 2 pin (used as headphone out by default) */
9681 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9682 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9683 { } /* end */
9684};
9685
9686/* Mute speakers according to the headphone jack state */
9687static void alc889A_mb31_automute(struct hda_codec *codec)
9688{
9689 unsigned int present;
9690
9691 /* Mute only in 2ch or 4ch mode */
9692 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9693 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009694 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009695 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9696 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9697 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9698 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9699 }
9700}
9701
9702static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9703{
9704 if ((res >> 26) == ALC880_HP_EVENT)
9705 alc889A_mb31_automute(codec);
9706}
9707
Takashi Iwai4953550a2009-06-30 15:28:30 +02009708
Takashi Iwaicb53c622007-08-10 17:21:45 +02009709#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009710#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009711#endif
9712
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009713/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009714#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9715#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9716#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9717#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9718
9719static hda_nid_t alc883_slave_dig_outs[] = {
9720 ALC1200_DIGOUT_NID, 0,
9721};
9722
9723static hda_nid_t alc1200_slave_dig_outs[] = {
9724 ALC883_DIGOUT_NID, 0,
9725};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009726
9727/*
9728 * configuration and preset
9729 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009730static const char *alc882_models[ALC882_MODEL_LAST] = {
9731 [ALC882_3ST_DIG] = "3stack-dig",
9732 [ALC882_6ST_DIG] = "6stack-dig",
9733 [ALC882_ARIMA] = "arima",
9734 [ALC882_W2JC] = "w2jc",
9735 [ALC882_TARGA] = "targa",
9736 [ALC882_ASUS_A7J] = "asus-a7j",
9737 [ALC882_ASUS_A7M] = "asus-a7m",
9738 [ALC885_MACPRO] = "macpro",
9739 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009740 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009741 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009742 [ALC885_MBP3] = "mbp3",
9743 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009744 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009745 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009746 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9747 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009748 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009749 [ALC883_TARGA_DIG] = "targa-dig",
9750 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009751 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009752 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009753 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009754 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009755 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009756 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009757 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009758 [ALC883_MEDION] = "medion",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009759 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009760 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009761 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009762 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9763 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009764 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009765 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009766 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009767 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009768 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309769 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009770 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009771 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009772 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009773 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009774 [ALC889A_INTEL] = "intel-alc889a",
9775 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009776 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009777 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009778 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009779 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009780};
9781
Takashi Iwai4953550a2009-06-30 15:28:30 +02009782static struct snd_pci_quirk alc882_cfg_tbl[] = {
9783 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9784
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009785 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009786 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009787 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009788 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9789 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009790 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009791 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9792 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009793 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009794 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009795 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9796 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009797 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9798 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009799 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9800 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009801 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009802 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009803 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009804 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009805 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9806 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009807 /* default Acer -- disabled as it causes more problems.
9808 * model=auto should work fine now
9809 */
9810 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009811
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009812 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009813
Tobin Davisfebe3372007-06-12 11:27:46 +02009814 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009815 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9816 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009817 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009818 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009819 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009820
9821 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9822 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9823 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009824 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009825 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9826 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9827 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009828 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009829 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009830 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009831 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009832
9833 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009834 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009835 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009836 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009837 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9838 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009839 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009840 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009841 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9842
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009843 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9844 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9845 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009846 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009847 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009848 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009849 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009850 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009851 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9852 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9853 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9854 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9855 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9856 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009857 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009858 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9859 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9860 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009861 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009862 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009863 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9864 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009865 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009866 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009867 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009868 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009869 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009870 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009871 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009872 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009873 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009874
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009875 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009876 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009877 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9878 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309879 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009880 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009881 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009882 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009883 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009884 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009885 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009886 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009887 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009888 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009889 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009890 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9891 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009892 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Takashi Iwai959973b2008-11-05 11:30:56 +01009893 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009894 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009895 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009896
Jiang zhe17bba1b2008-06-04 12:11:07 +02009897 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9898 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009899 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009900 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9901 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9902 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009903 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009904
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009905 {}
9906};
9907
Takashi Iwai4953550a2009-06-30 15:28:30 +02009908/* codec SSID table for Intel Mac */
9909static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9910 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9911 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9912 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9913 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9914 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9915 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9916 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009917 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009918 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009919 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009920 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009921 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9922 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9923 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009924 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009925 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +10009926 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009927 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9928 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009929 */
9930 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009931 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009932 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009933 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009934};
9935
Takashi Iwai4953550a2009-06-30 15:28:30 +02009936static struct alc_config_preset alc882_presets[] = {
9937 [ALC882_3ST_DIG] = {
9938 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009939 .init_verbs = { alc882_base_init_verbs,
9940 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009941 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9942 .dac_nids = alc882_dac_nids,
9943 .dig_out_nid = ALC882_DIGOUT_NID,
9944 .dig_in_nid = ALC882_DIGIN_NID,
9945 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9946 .channel_mode = alc882_ch_modes,
9947 .need_dac_fix = 1,
9948 .input_mux = &alc882_capture_source,
9949 },
9950 [ALC882_6ST_DIG] = {
9951 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009952 .init_verbs = { alc882_base_init_verbs,
9953 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009954 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9955 .dac_nids = alc882_dac_nids,
9956 .dig_out_nid = ALC882_DIGOUT_NID,
9957 .dig_in_nid = ALC882_DIGIN_NID,
9958 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9959 .channel_mode = alc882_sixstack_modes,
9960 .input_mux = &alc882_capture_source,
9961 },
9962 [ALC882_ARIMA] = {
9963 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009964 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9965 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009966 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9967 .dac_nids = alc882_dac_nids,
9968 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9969 .channel_mode = alc882_sixstack_modes,
9970 .input_mux = &alc882_capture_source,
9971 },
9972 [ALC882_W2JC] = {
9973 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009974 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9975 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009976 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9977 .dac_nids = alc882_dac_nids,
9978 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9979 .channel_mode = alc880_threestack_modes,
9980 .need_dac_fix = 1,
9981 .input_mux = &alc882_capture_source,
9982 .dig_out_nid = ALC882_DIGOUT_NID,
9983 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009984 [ALC885_MBA21] = {
9985 .mixers = { alc885_mba21_mixer },
9986 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9987 .num_dacs = 2,
9988 .dac_nids = alc882_dac_nids,
9989 .channel_mode = alc885_mba21_ch_modes,
9990 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9991 .input_mux = &alc882_capture_source,
9992 .unsol_event = alc_automute_amp_unsol_event,
9993 .setup = alc885_mba21_setup,
9994 .init_hook = alc_automute_amp,
9995 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009996 [ALC885_MBP3] = {
9997 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9998 .init_verbs = { alc885_mbp3_init_verbs,
9999 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010000 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010001 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010002 .hp_nid = 0x04,
10003 .channel_mode = alc885_mbp_4ch_modes,
10004 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010005 .input_mux = &alc882_capture_source,
10006 .dig_out_nid = ALC882_DIGOUT_NID,
10007 .dig_in_nid = ALC882_DIGIN_NID,
10008 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010009 .setup = alc885_mbp3_setup,
10010 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010011 },
10012 [ALC885_MB5] = {
10013 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
10014 .init_verbs = { alc885_mb5_init_verbs,
10015 alc880_gpio1_init_verbs },
10016 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10017 .dac_nids = alc882_dac_nids,
10018 .channel_mode = alc885_mb5_6ch_modes,
10019 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
10020 .input_mux = &mb5_capture_source,
10021 .dig_out_nid = ALC882_DIGOUT_NID,
10022 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010023 .unsol_event = alc_automute_amp_unsol_event,
10024 .setup = alc885_mb5_setup,
10025 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010026 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010027 [ALC885_MACMINI3] = {
10028 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
10029 .init_verbs = { alc885_macmini3_init_verbs,
10030 alc880_gpio1_init_verbs },
10031 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10032 .dac_nids = alc882_dac_nids,
10033 .channel_mode = alc885_macmini3_6ch_modes,
10034 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
10035 .input_mux = &macmini3_capture_source,
10036 .dig_out_nid = ALC882_DIGOUT_NID,
10037 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010038 .unsol_event = alc_automute_amp_unsol_event,
10039 .setup = alc885_macmini3_setup,
10040 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010041 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010042 [ALC885_MACPRO] = {
10043 .mixers = { alc882_macpro_mixer },
10044 .init_verbs = { alc882_macpro_init_verbs },
10045 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10046 .dac_nids = alc882_dac_nids,
10047 .dig_out_nid = ALC882_DIGOUT_NID,
10048 .dig_in_nid = ALC882_DIGIN_NID,
10049 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10050 .channel_mode = alc882_ch_modes,
10051 .input_mux = &alc882_capture_source,
10052 .init_hook = alc885_macpro_init_hook,
10053 },
10054 [ALC885_IMAC24] = {
10055 .mixers = { alc885_imac24_mixer },
10056 .init_verbs = { alc885_imac24_init_verbs },
10057 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10058 .dac_nids = alc882_dac_nids,
10059 .dig_out_nid = ALC882_DIGOUT_NID,
10060 .dig_in_nid = ALC882_DIGIN_NID,
10061 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10062 .channel_mode = alc882_ch_modes,
10063 .input_mux = &alc882_capture_source,
10064 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010065 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010066 .init_hook = alc885_imac24_init_hook,
10067 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010068 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010069 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010070 .init_verbs = { alc885_imac91_init_verbs,
10071 alc880_gpio1_init_verbs },
10072 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10073 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010074 .channel_mode = alc885_mba21_ch_modes,
10075 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10076 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010077 .dig_out_nid = ALC882_DIGOUT_NID,
10078 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010079 .unsol_event = alc_automute_amp_unsol_event,
10080 .setup = alc885_imac91_setup,
10081 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010082 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010083 [ALC882_TARGA] = {
10084 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010085 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +020010086 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010087 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10088 .dac_nids = alc882_dac_nids,
10089 .dig_out_nid = ALC882_DIGOUT_NID,
10090 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10091 .adc_nids = alc882_adc_nids,
10092 .capsrc_nids = alc882_capsrc_nids,
10093 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10094 .channel_mode = alc882_3ST_6ch_modes,
10095 .need_dac_fix = 1,
10096 .input_mux = &alc882_capture_source,
10097 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010098 .setup = alc882_targa_setup,
10099 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010100 },
10101 [ALC882_ASUS_A7J] = {
10102 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010103 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10104 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010105 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10106 .dac_nids = alc882_dac_nids,
10107 .dig_out_nid = ALC882_DIGOUT_NID,
10108 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10109 .adc_nids = alc882_adc_nids,
10110 .capsrc_nids = alc882_capsrc_nids,
10111 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10112 .channel_mode = alc882_3ST_6ch_modes,
10113 .need_dac_fix = 1,
10114 .input_mux = &alc882_capture_source,
10115 },
10116 [ALC882_ASUS_A7M] = {
10117 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010118 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10119 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010120 alc882_asus_a7m_verbs },
10121 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10122 .dac_nids = alc882_dac_nids,
10123 .dig_out_nid = ALC882_DIGOUT_NID,
10124 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10125 .channel_mode = alc880_threestack_modes,
10126 .need_dac_fix = 1,
10127 .input_mux = &alc882_capture_source,
10128 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010129 [ALC883_3ST_2ch_DIG] = {
10130 .mixers = { alc883_3ST_2ch_mixer },
10131 .init_verbs = { alc883_init_verbs },
10132 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10133 .dac_nids = alc883_dac_nids,
10134 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010135 .dig_in_nid = ALC883_DIGIN_NID,
10136 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10137 .channel_mode = alc883_3ST_2ch_modes,
10138 .input_mux = &alc883_capture_source,
10139 },
10140 [ALC883_3ST_6ch_DIG] = {
10141 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10142 .init_verbs = { alc883_init_verbs },
10143 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10144 .dac_nids = alc883_dac_nids,
10145 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010146 .dig_in_nid = ALC883_DIGIN_NID,
10147 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10148 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010149 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010150 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010151 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010152 [ALC883_3ST_6ch] = {
10153 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10154 .init_verbs = { alc883_init_verbs },
10155 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10156 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010157 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10158 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010159 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010160 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010161 },
Jiang zhe17bba1b2008-06-04 12:11:07 +020010162 [ALC883_3ST_6ch_INTEL] = {
10163 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
10164 .init_verbs = { alc883_init_verbs },
10165 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10166 .dac_nids = alc883_dac_nids,
10167 .dig_out_nid = ALC883_DIGOUT_NID,
10168 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010169 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +020010170 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
10171 .channel_mode = alc883_3ST_6ch_intel_modes,
10172 .need_dac_fix = 1,
10173 .input_mux = &alc883_3stack_6ch_intel,
10174 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010175 [ALC889A_INTEL] = {
10176 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020010177 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
10178 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010179 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10180 .dac_nids = alc883_dac_nids,
10181 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10182 .adc_nids = alc889_adc_nids,
10183 .dig_out_nid = ALC883_DIGOUT_NID,
10184 .dig_in_nid = ALC883_DIGIN_NID,
10185 .slave_dig_outs = alc883_slave_dig_outs,
10186 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10187 .channel_mode = alc889_8ch_intel_modes,
10188 .capsrc_nids = alc889_capsrc_nids,
10189 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010190 .setup = alc889_automute_setup,
10191 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010192 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010193 .need_dac_fix = 1,
10194 },
10195 [ALC889_INTEL] = {
10196 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
10197 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010198 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010199 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10200 .dac_nids = alc883_dac_nids,
10201 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10202 .adc_nids = alc889_adc_nids,
10203 .dig_out_nid = ALC883_DIGOUT_NID,
10204 .dig_in_nid = ALC883_DIGIN_NID,
10205 .slave_dig_outs = alc883_slave_dig_outs,
10206 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10207 .channel_mode = alc889_8ch_intel_modes,
10208 .capsrc_nids = alc889_capsrc_nids,
10209 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010210 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010211 .init_hook = alc889_intel_init_hook,
10212 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010213 .need_dac_fix = 1,
10214 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010215 [ALC883_6ST_DIG] = {
10216 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10217 .init_verbs = { alc883_init_verbs },
10218 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10219 .dac_nids = alc883_dac_nids,
10220 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010221 .dig_in_nid = ALC883_DIGIN_NID,
10222 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10223 .channel_mode = alc883_sixstack_modes,
10224 .input_mux = &alc883_capture_source,
10225 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010226 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010227 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010228 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10229 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010230 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10231 .dac_nids = alc883_dac_nids,
10232 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010233 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10234 .channel_mode = alc883_3ST_6ch_modes,
10235 .need_dac_fix = 1,
10236 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010237 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010238 .setup = alc882_targa_setup,
10239 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010240 },
10241 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010242 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010243 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10244 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010245 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10246 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010247 .adc_nids = alc883_adc_nids_alt,
10248 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010249 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010250 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010251 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10252 .channel_mode = alc883_3ST_2ch_modes,
10253 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010254 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010255 .setup = alc882_targa_setup,
10256 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010257 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010258 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010259 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10260 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010261 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010262 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010263 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10264 .dac_nids = alc883_dac_nids,
10265 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10266 .adc_nids = alc883_adc_nids_rev,
10267 .capsrc_nids = alc883_capsrc_nids_rev,
10268 .dig_out_nid = ALC883_DIGOUT_NID,
10269 .dig_in_nid = ALC883_DIGIN_NID,
10270 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10271 .channel_mode = alc883_4ST_8ch_modes,
10272 .need_dac_fix = 1,
10273 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010274 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010275 .setup = alc882_targa_setup,
10276 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010277 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010278 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010279 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010280 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10281 * and the headphone jack. Turn this on and rely on the
10282 * standard mute methods whenever the user wants to turn
10283 * these outputs off.
10284 */
10285 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10286 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10287 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010288 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10289 .channel_mode = alc883_3ST_2ch_modes,
10290 .input_mux = &alc883_capture_source,
10291 },
Tobin Davis2880a862007-08-07 11:50:26 +020010292 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010293 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010294 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010295 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10296 .dac_nids = alc883_dac_nids,
10297 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010298 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10299 .channel_mode = alc883_3ST_2ch_modes,
10300 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010301 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010302 .setup = alc883_acer_aspire_setup,
10303 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010304 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010305 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010306 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010307 alc883_chmode_mixer },
10308 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10309 alc888_acer_aspire_4930g_verbs },
10310 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10311 .dac_nids = alc883_dac_nids,
10312 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10313 .adc_nids = alc883_adc_nids_rev,
10314 .capsrc_nids = alc883_capsrc_nids_rev,
10315 .dig_out_nid = ALC883_DIGOUT_NID,
10316 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10317 .channel_mode = alc883_3ST_6ch_modes,
10318 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010319 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010320 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010321 ARRAY_SIZE(alc888_2_capture_sources),
10322 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010323 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010324 .setup = alc888_acer_aspire_4930g_setup,
10325 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010326 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010327 [ALC888_ACER_ASPIRE_6530G] = {
10328 .mixers = { alc888_acer_aspire_6530_mixer },
10329 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10330 alc888_acer_aspire_6530g_verbs },
10331 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10332 .dac_nids = alc883_dac_nids,
10333 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10334 .adc_nids = alc883_adc_nids_rev,
10335 .capsrc_nids = alc883_capsrc_nids_rev,
10336 .dig_out_nid = ALC883_DIGOUT_NID,
10337 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10338 .channel_mode = alc883_3ST_2ch_modes,
10339 .num_mux_defs =
10340 ARRAY_SIZE(alc888_2_capture_sources),
10341 .input_mux = alc888_acer_aspire_6530_sources,
10342 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010343 .setup = alc888_acer_aspire_6530g_setup,
10344 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010345 },
Hector Martin3b315d72009-06-02 10:54:19 +020010346 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010347 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010348 alc883_chmode_mixer },
10349 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010350 alc889_acer_aspire_8930g_verbs,
10351 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010352 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10353 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010354 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10355 .adc_nids = alc889_adc_nids,
10356 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010357 .dig_out_nid = ALC883_DIGOUT_NID,
10358 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10359 .channel_mode = alc883_3ST_6ch_modes,
10360 .need_dac_fix = 1,
10361 .const_channel_count = 6,
10362 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010363 ARRAY_SIZE(alc889_capture_sources),
10364 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +020010365 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010366 .setup = alc889_acer_aspire_8930g_setup,
10367 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +010010368#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010369 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010370#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010371 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010372 [ALC888_ACER_ASPIRE_7730G] = {
10373 .mixers = { alc883_3ST_6ch_mixer,
10374 alc883_chmode_mixer },
10375 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10376 alc888_acer_aspire_7730G_verbs },
10377 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10378 .dac_nids = alc883_dac_nids,
10379 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10380 .adc_nids = alc883_adc_nids_rev,
10381 .capsrc_nids = alc883_capsrc_nids_rev,
10382 .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 .input_mux = &alc883_capture_source,
10388 .unsol_event = alc_automute_amp_unsol_event,
Denis Kuplyakovd9477202010-11-24 06:01:09 +010010389 .setup = alc888_acer_aspire_7730g_setup,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010390 .init_hook = alc_automute_amp,
10391 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010392 [ALC883_MEDION] = {
10393 .mixers = { alc883_fivestack_mixer,
10394 alc883_chmode_mixer },
10395 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010396 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010397 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10398 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010399 .adc_nids = alc883_adc_nids_alt,
10400 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010401 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010402 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10403 .channel_mode = alc883_sixstack_modes,
10404 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010405 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010406 [ALC883_MEDION_WIM2160] = {
10407 .mixers = { alc883_medion_wim2160_mixer },
10408 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10409 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10410 .dac_nids = alc883_dac_nids,
10411 .dig_out_nid = ALC883_DIGOUT_NID,
10412 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10413 .adc_nids = alc883_adc_nids,
10414 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10415 .channel_mode = alc883_3ST_2ch_modes,
10416 .input_mux = &alc883_capture_source,
10417 .unsol_event = alc_automute_amp_unsol_event,
10418 .setup = alc883_medion_wim2160_setup,
10419 .init_hook = alc_automute_amp,
10420 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010421 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010422 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010423 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10424 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10425 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010426 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10427 .channel_mode = alc883_3ST_2ch_modes,
10428 .input_mux = &alc883_capture_source,
10429 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010430 [ALC883_CLEVO_M540R] = {
10431 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10432 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10433 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10434 .dac_nids = alc883_dac_nids,
10435 .dig_out_nid = ALC883_DIGOUT_NID,
10436 .dig_in_nid = ALC883_DIGIN_NID,
10437 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10438 .channel_mode = alc883_3ST_6ch_clevo_modes,
10439 .need_dac_fix = 1,
10440 .input_mux = &alc883_capture_source,
10441 /* This machine has the hardware HP auto-muting, thus
10442 * we need no software mute via unsol event
10443 */
10444 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010445 [ALC883_CLEVO_M720] = {
10446 .mixers = { alc883_clevo_m720_mixer },
10447 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010448 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10449 .dac_nids = alc883_dac_nids,
10450 .dig_out_nid = ALC883_DIGOUT_NID,
10451 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10452 .channel_mode = alc883_3ST_2ch_modes,
10453 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010454 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010455 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010456 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010457 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010458 [ALC883_LENOVO_101E_2ch] = {
10459 .mixers = { alc883_lenovo_101e_2ch_mixer},
10460 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10461 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10462 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010463 .adc_nids = alc883_adc_nids_alt,
10464 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010465 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010466 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10467 .channel_mode = alc883_3ST_2ch_modes,
10468 .input_mux = &alc883_lenovo_101e_capture_source,
10469 .unsol_event = alc883_lenovo_101e_unsol_event,
10470 .init_hook = alc883_lenovo_101e_all_automute,
10471 },
Kailang Yang272a5272007-05-14 11:00:38 +020010472 [ALC883_LENOVO_NB0763] = {
10473 .mixers = { alc883_lenovo_nb0763_mixer },
10474 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10475 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10476 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010477 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10478 .channel_mode = alc883_3ST_2ch_modes,
10479 .need_dac_fix = 1,
10480 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010481 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwaidc4271702010-11-29 07:42:59 +010010482 .setup = alc883_lenovo_nb0763_setup,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010483 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010484 },
10485 [ALC888_LENOVO_MS7195_DIG] = {
10486 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10487 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10488 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10489 .dac_nids = alc883_dac_nids,
10490 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010491 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10492 .channel_mode = alc883_3ST_6ch_modes,
10493 .need_dac_fix = 1,
10494 .input_mux = &alc883_capture_source,
10495 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10496 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010497 },
10498 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010499 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010500 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10501 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10502 .dac_nids = alc883_dac_nids,
10503 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010504 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10505 .channel_mode = alc883_3ST_2ch_modes,
10506 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010507 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010508 .setup = alc883_haier_w66_setup,
10509 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010510 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010511 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010512 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010513 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010514 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10515 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010516 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10517 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010518 .need_dac_fix = 1,
10519 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010520 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010521 .setup = alc888_3st_hp_setup,
10522 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010523 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010524 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010525 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010526 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10527 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10528 .dac_nids = alc883_dac_nids,
10529 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010530 .dig_in_nid = ALC883_DIGIN_NID,
10531 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10532 .channel_mode = alc883_sixstack_modes,
10533 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010534 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010535 .setup = alc888_6st_dell_setup,
10536 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010537 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010538 [ALC883_MITAC] = {
10539 .mixers = { alc883_mitac_mixer },
10540 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10541 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10542 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010543 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10544 .channel_mode = alc883_3ST_2ch_modes,
10545 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010546 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010547 .setup = alc883_mitac_setup,
10548 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010549 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010550 [ALC883_FUJITSU_PI2515] = {
10551 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10552 .init_verbs = { alc883_init_verbs,
10553 alc883_2ch_fujitsu_pi2515_verbs},
10554 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10555 .dac_nids = alc883_dac_nids,
10556 .dig_out_nid = ALC883_DIGOUT_NID,
10557 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10558 .channel_mode = alc883_3ST_2ch_modes,
10559 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010560 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010561 .setup = alc883_2ch_fujitsu_pi2515_setup,
10562 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010563 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010564 [ALC888_FUJITSU_XA3530] = {
10565 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10566 .init_verbs = { alc883_init_verbs,
10567 alc888_fujitsu_xa3530_verbs },
10568 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10569 .dac_nids = alc883_dac_nids,
10570 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10571 .adc_nids = alc883_adc_nids_rev,
10572 .capsrc_nids = alc883_capsrc_nids_rev,
10573 .dig_out_nid = ALC883_DIGOUT_NID,
10574 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10575 .channel_mode = alc888_4ST_8ch_intel_modes,
10576 .num_mux_defs =
10577 ARRAY_SIZE(alc888_2_capture_sources),
10578 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010579 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010580 .setup = alc888_fujitsu_xa3530_setup,
10581 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010582 },
Kailang Yange2757d52008-08-26 13:17:46 +020010583 [ALC888_LENOVO_SKY] = {
10584 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10585 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10586 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10587 .dac_nids = alc883_dac_nids,
10588 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010589 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10590 .channel_mode = alc883_sixstack_modes,
10591 .need_dac_fix = 1,
10592 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010593 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010594 .setup = alc888_lenovo_sky_setup,
10595 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010596 },
10597 [ALC888_ASUS_M90V] = {
10598 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10599 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10600 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10601 .dac_nids = alc883_dac_nids,
10602 .dig_out_nid = ALC883_DIGOUT_NID,
10603 .dig_in_nid = ALC883_DIGIN_NID,
10604 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10605 .channel_mode = alc883_3ST_6ch_modes,
10606 .need_dac_fix = 1,
10607 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010608 .unsol_event = alc_sku_unsol_event,
10609 .setup = alc883_mode2_setup,
10610 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010611 },
10612 [ALC888_ASUS_EEE1601] = {
10613 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010614 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010615 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10616 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10617 .dac_nids = alc883_dac_nids,
10618 .dig_out_nid = ALC883_DIGOUT_NID,
10619 .dig_in_nid = ALC883_DIGIN_NID,
10620 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10621 .channel_mode = alc883_3ST_2ch_modes,
10622 .need_dac_fix = 1,
10623 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010624 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010625 .init_hook = alc883_eee1601_inithook,
10626 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010627 [ALC1200_ASUS_P5Q] = {
10628 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10629 .init_verbs = { alc883_init_verbs },
10630 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10631 .dac_nids = alc883_dac_nids,
10632 .dig_out_nid = ALC1200_DIGOUT_NID,
10633 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010634 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010635 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10636 .channel_mode = alc883_sixstack_modes,
10637 .input_mux = &alc883_capture_source,
10638 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010639 [ALC889A_MB31] = {
10640 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10641 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10642 alc880_gpio1_init_verbs },
10643 .adc_nids = alc883_adc_nids,
10644 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010645 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010646 .dac_nids = alc883_dac_nids,
10647 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10648 .channel_mode = alc889A_mb31_6ch_modes,
10649 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10650 .input_mux = &alc889A_mb31_capture_source,
10651 .dig_out_nid = ALC883_DIGOUT_NID,
10652 .unsol_event = alc889A_mb31_unsol_event,
10653 .init_hook = alc889A_mb31_automute,
10654 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010655 [ALC883_SONY_VAIO_TT] = {
10656 .mixers = { alc883_vaiott_mixer },
10657 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10658 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10659 .dac_nids = alc883_dac_nids,
10660 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10661 .channel_mode = alc883_3ST_2ch_modes,
10662 .input_mux = &alc883_capture_source,
10663 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010664 .setup = alc883_vaiott_setup,
10665 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010666 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010667};
10668
10669
10670/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010671 * Pin config fixes
10672 */
10673enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010674 PINFIX_ABIT_AW9D_MAX,
10675 PINFIX_PB_M5210,
David Henningssonc3d226a2010-10-14 15:42:08 +020010676 PINFIX_ACER_ASPIRE_7736,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010677};
10678
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010679static const struct alc_fixup alc882_fixups[] = {
10680 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010681 .pins = (const struct alc_pincfg[]) {
10682 { 0x15, 0x01080104 }, /* side */
10683 { 0x16, 0x01011012 }, /* rear */
10684 { 0x17, 0x01016011 }, /* clfe */
10685 { }
10686 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010687 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010688 [PINFIX_PB_M5210] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010689 .verbs = (const struct hda_verb[]) {
10690 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10691 {}
10692 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020010693 },
David Henningssonc3d226a2010-10-14 15:42:08 +020010694 [PINFIX_ACER_ASPIRE_7736] = {
10695 .sku = ALC_FIXUP_SKU_IGNORE,
10696 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010697};
10698
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010699static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010700 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010701 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
David Henningssonc3d226a2010-10-14 15:42:08 +020010702 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010703 {}
10704};
10705
10706/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010707 * BIOS auto configuration
10708 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010709static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10710 const struct auto_pin_cfg *cfg)
10711{
10712 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10713}
10714
Takashi Iwai4953550a2009-06-30 15:28:30 +020010715static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010716 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010717 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010718{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010719 int idx;
10720
Takashi Iwai489008c2010-04-07 09:06:00 +020010721 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010722 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010723
Takashi Iwai489008c2010-04-07 09:06:00 +020010724 if (dac == 0x25)
10725 idx = 4;
10726 else if (dac >= 0x02 && dac <= 0x05)
10727 idx = dac - 2;
10728 else
10729 return;
10730 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010731}
10732
Takashi Iwai4953550a2009-06-30 15:28:30 +020010733static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010734{
10735 struct alc_spec *spec = codec->spec;
10736 int i;
10737
10738 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010739 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010740 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010741 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010742 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010743 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010744 }
10745}
10746
Takashi Iwai4953550a2009-06-30 15:28:30 +020010747static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010748{
10749 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010750 hda_nid_t pin, dac;
Takashi Iwai5855fb82010-09-16 18:24:02 +020010751 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010752
Takashi Iwai5855fb82010-09-16 18:24:02 +020010753 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
10754 pin = spec->autocfg.hp_pins[i];
10755 if (!pin)
10756 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010757 dac = spec->multiout.hp_nid;
10758 if (!dac)
10759 dac = spec->multiout.dac_nids[0]; /* to front */
10760 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10761 }
Takashi Iwai5855fb82010-09-16 18:24:02 +020010762 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
10763 pin = spec->autocfg.speaker_pins[i];
10764 if (!pin)
10765 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010766 dac = spec->multiout.extra_out_nid[0];
10767 if (!dac)
10768 dac = spec->multiout.dac_nids[0]; /* to front */
10769 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10770 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010771}
10772
Takashi Iwai4953550a2009-06-30 15:28:30 +020010773static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010774{
10775 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010776 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010777 int i;
10778
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010779 for (i = 0; i < cfg->num_inputs; i++) {
10780 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai30ea0982010-09-16 18:47:56 +020010781 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010782 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10783 snd_hda_codec_write(codec, nid, 0,
10784 AC_VERB_SET_AMP_GAIN_MUTE,
10785 AMP_OUT_MUTE);
10786 }
10787}
10788
10789static void alc882_auto_init_input_src(struct hda_codec *codec)
10790{
10791 struct alc_spec *spec = codec->spec;
10792 int c;
10793
10794 for (c = 0; c < spec->num_adc_nids; c++) {
10795 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10796 hda_nid_t nid = spec->capsrc_nids[c];
10797 unsigned int mux_idx;
10798 const struct hda_input_mux *imux;
10799 int conns, mute, idx, item;
10800
10801 conns = snd_hda_get_connections(codec, nid, conn_list,
10802 ARRAY_SIZE(conn_list));
10803 if (conns < 0)
10804 continue;
10805 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10806 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010807 if (!imux->num_items && mux_idx > 0)
10808 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010809 for (idx = 0; idx < conns; idx++) {
10810 /* if the current connection is the selected one,
10811 * unmute it as default - otherwise mute it
10812 */
10813 mute = AMP_IN_MUTE(idx);
10814 for (item = 0; item < imux->num_items; item++) {
10815 if (imux->items[item].index == idx) {
10816 if (spec->cur_mux[c] == item)
10817 mute = AMP_IN_UNMUTE(idx);
10818 break;
10819 }
10820 }
10821 /* check if we have a selector or mixer
10822 * we could check for the widget type instead, but
10823 * just check for Amp-In presence (in case of mixer
10824 * without amp-in there is something wrong, this
10825 * function shouldn't be used or capsrc nid is wrong)
10826 */
10827 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010828 snd_hda_codec_write(codec, nid, 0,
10829 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010830 mute);
10831 else if (mute != AMP_IN_MUTE(idx))
10832 snd_hda_codec_write(codec, nid, 0,
10833 AC_VERB_SET_CONNECT_SEL,
10834 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010835 }
10836 }
10837}
10838
Takashi Iwai4953550a2009-06-30 15:28:30 +020010839/* add mic boosts if needed */
10840static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010841{
10842 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010843 struct auto_pin_cfg *cfg = &spec->autocfg;
David Henningsson5322bf22011-01-05 11:03:56 +010010844 int i, err;
Takashi Iwai53e8c322010-12-17 15:23:41 +010010845 int type_idx = 0;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010846 hda_nid_t nid;
David Henningsson5322bf22011-01-05 11:03:56 +010010847 const char *prev_label = NULL;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010848
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010849 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020010850 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010851 break;
10852 nid = cfg->inputs[i].pin;
10853 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
David Henningsson5322bf22011-01-05 11:03:56 +010010854 const char *label;
10855 char boost_label[32];
10856
10857 label = hda_get_autocfg_input_label(codec, cfg, i);
10858 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai53e8c322010-12-17 15:23:41 +010010859 type_idx++;
10860 else
10861 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +010010862 prev_label = label;
10863
10864 snprintf(boost_label, sizeof(boost_label),
10865 "%s Boost Volume", label);
10866 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10867 boost_label, type_idx,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010868 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010869 if (err < 0)
10870 return err;
10871 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010872 }
10873 return 0;
10874}
10875
10876/* almost identical with ALC880 parser... */
10877static int alc882_parse_auto_config(struct hda_codec *codec)
10878{
10879 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010880 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020010881 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010882
Takashi Iwai05f5f472009-08-25 13:10:18 +020010883 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10884 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010885 if (err < 0)
10886 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010887 if (!spec->autocfg.line_outs)
10888 return 0; /* can't find valid BIOS pin config */
10889
10890 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10891 if (err < 0)
10892 return err;
10893 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10894 if (err < 0)
10895 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010896 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10897 "Headphone");
10898 if (err < 0)
10899 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010900 err = alc880_auto_create_extra_out(spec,
10901 spec->autocfg.speaker_pins[0],
10902 "Speaker");
10903 if (err < 0)
10904 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010905 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10906 if (err < 0)
10907 return err;
10908
10909 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10910
Takashi Iwai757899a2010-07-30 10:48:14 +020010911 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010912
10913 if (spec->kctls.list)
10914 add_mixer(spec, spec->kctls.list);
10915
10916 add_verb(spec, alc883_auto_init_verbs);
10917 /* if ADC 0x07 is available, initialize it, too */
10918 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10919 add_verb(spec, alc882_adc1_init_verbs);
10920
10921 spec->num_mux_defs = 1;
10922 spec->input_mux = &spec->private_imux[0];
10923
Kailang Yang6227cdc2010-02-25 08:36:52 +010010924 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010925
10926 err = alc_auto_add_mic_boost(codec);
10927 if (err < 0)
10928 return err;
10929
Takashi Iwai776e1842007-08-29 15:07:11 +020010930 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010931}
10932
10933/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010934static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010935{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010936 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010937 alc882_auto_init_multi_out(codec);
10938 alc882_auto_init_hp_out(codec);
10939 alc882_auto_init_analog_input(codec);
10940 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020010941 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010942 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010943 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010944}
10945
Takashi Iwai4953550a2009-06-30 15:28:30 +020010946static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010947{
10948 struct alc_spec *spec;
10949 int err, board_config;
10950
10951 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10952 if (spec == NULL)
10953 return -ENOMEM;
10954
10955 codec->spec = spec;
10956
Takashi Iwai4953550a2009-06-30 15:28:30 +020010957 switch (codec->vendor_id) {
10958 case 0x10ec0882:
10959 case 0x10ec0885:
10960 break;
10961 default:
10962 /* ALC883 and variants */
10963 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10964 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010965 }
10966
Takashi Iwai4953550a2009-06-30 15:28:30 +020010967 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10968 alc882_models,
10969 alc882_cfg_tbl);
10970
10971 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10972 board_config = snd_hda_check_board_codec_sid_config(codec,
10973 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10974
10975 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010976 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010977 codec->chip_name);
10978 board_config = ALC882_AUTO;
10979 }
10980
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010981 if (board_config == ALC882_AUTO)
10982 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 1);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010983
David Henningsson90622912010-10-14 14:50:18 +020010984 alc_auto_parse_customize_define(codec);
10985
Takashi Iwai4953550a2009-06-30 15:28:30 +020010986 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010987 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010988 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010989 if (err < 0) {
10990 alc_free(codec);
10991 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010992 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010993 printk(KERN_INFO
10994 "hda_codec: Cannot set up configuration "
10995 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010996 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010997 }
10998 }
10999
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011000 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020011001 err = snd_hda_attach_beep_device(codec, 0x1);
11002 if (err < 0) {
11003 alc_free(codec);
11004 return err;
11005 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011006 }
11007
Takashi Iwai4953550a2009-06-30 15:28:30 +020011008 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011009 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011010
Takashi Iwai4953550a2009-06-30 15:28:30 +020011011 spec->stream_analog_playback = &alc882_pcm_analog_playback;
11012 spec->stream_analog_capture = &alc882_pcm_analog_capture;
11013 /* FIXME: setup DAC5 */
11014 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
11015 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
11016
11017 spec->stream_digital_playback = &alc882_pcm_digital_playback;
11018 spec->stream_digital_capture = &alc882_pcm_digital_capture;
11019
Takashi Iwai4953550a2009-06-30 15:28:30 +020011020 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011021 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011022 spec->num_adc_nids = 0;
11023 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011024 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011025 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011026 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020011027 hda_nid_t nid = alc882_adc_nids[i];
11028 unsigned int wcap = get_wcaps(codec, nid);
11029 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011030 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020011031 if (wcap != AC_WID_AUD_IN)
11032 continue;
11033 spec->private_adc_nids[spec->num_adc_nids] = nid;
11034 err = snd_hda_get_connections(codec, nid, &cap, 1);
11035 if (err < 0)
11036 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011037 err = snd_hda_get_connections(codec, cap, items,
11038 ARRAY_SIZE(items));
11039 if (err < 0)
11040 continue;
11041 for (j = 0; j < imux->num_items; j++)
11042 if (imux->items[j].index >= err)
11043 break;
11044 if (j < imux->num_items)
11045 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011046 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
11047 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011048 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011049 spec->adc_nids = spec->private_adc_nids;
11050 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020011051 }
11052
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011053 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010011054
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011055 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010011056 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011057
Takashi Iwai7fa90e82010-04-12 08:49:00 +020011058 if (board_config == ALC882_AUTO)
11059 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 0);
11060
Takashi Iwai2134ea42008-01-10 16:53:55 +010011061 spec->vmaster_nid = 0x0c;
11062
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011063 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011064 if (board_config == ALC882_AUTO)
11065 spec->init_hook = alc882_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020011066
11067 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020011068#ifdef CONFIG_SND_HDA_POWER_SAVE
11069 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020011070 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011071#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011072
11073 return 0;
11074}
11075
Takashi Iwai4953550a2009-06-30 15:28:30 +020011076
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011077/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011078 * ALC262 support
11079 */
11080
11081#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
11082#define ALC262_DIGIN_NID ALC880_DIGIN_NID
11083
11084#define alc262_dac_nids alc260_dac_nids
11085#define alc262_adc_nids alc882_adc_nids
11086#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010011087#define alc262_capsrc_nids alc882_capsrc_nids
11088#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010011089
11090#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010011091#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010011092
Kailang Yang4e555fe2008-08-26 13:05:55 +020011093static hda_nid_t alc262_dmic_adc_nids[1] = {
11094 /* ADC0 */
11095 0x09
11096};
11097
11098static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
11099
Kailang Yangdf694da2005-12-05 19:42:22 +010011100static struct snd_kcontrol_new alc262_base_mixer[] = {
11101 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11102 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11103 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11104 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11105 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11106 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11107 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11108 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011109 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011110 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11111 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011112 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011113 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
11114 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11115 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
11116 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011117 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010011118};
11119
Takashi Iwaice875f02008-01-28 18:17:43 +010011120/* update HP, line and mono-out pins according to the master switch */
11121static void alc262_hp_master_update(struct hda_codec *codec)
11122{
11123 struct alc_spec *spec = codec->spec;
11124 int val = spec->master_sw;
11125
11126 /* HP & line-out */
11127 snd_hda_codec_write_cache(codec, 0x1b, 0,
11128 AC_VERB_SET_PIN_WIDGET_CONTROL,
11129 val ? PIN_HP : 0);
11130 snd_hda_codec_write_cache(codec, 0x15, 0,
11131 AC_VERB_SET_PIN_WIDGET_CONTROL,
11132 val ? PIN_HP : 0);
11133 /* mono (speaker) depending on the HP jack sense */
11134 val = val && !spec->jack_present;
11135 snd_hda_codec_write_cache(codec, 0x16, 0,
11136 AC_VERB_SET_PIN_WIDGET_CONTROL,
11137 val ? PIN_OUT : 0);
11138}
11139
11140static void alc262_hp_bpc_automute(struct hda_codec *codec)
11141{
11142 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011143
11144 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010011145 alc262_hp_master_update(codec);
11146}
11147
11148static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
11149{
11150 if ((res >> 26) != ALC880_HP_EVENT)
11151 return;
11152 alc262_hp_bpc_automute(codec);
11153}
11154
11155static void alc262_hp_wildwest_automute(struct hda_codec *codec)
11156{
11157 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011158
11159 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010011160 alc262_hp_master_update(codec);
11161}
11162
11163static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
11164 unsigned int res)
11165{
11166 if ((res >> 26) != ALC880_HP_EVENT)
11167 return;
11168 alc262_hp_wildwest_automute(codec);
11169}
11170
Takashi Iwaib72519b2009-05-08 14:31:55 +020011171#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010011172
11173static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
11174 struct snd_ctl_elem_value *ucontrol)
11175{
11176 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11177 struct alc_spec *spec = codec->spec;
11178 int val = !!*ucontrol->value.integer.value;
11179
11180 if (val == spec->master_sw)
11181 return 0;
11182 spec->master_sw = val;
11183 alc262_hp_master_update(codec);
11184 return 1;
11185}
11186
Takashi Iwaib72519b2009-05-08 14:31:55 +020011187#define ALC262_HP_MASTER_SWITCH \
11188 { \
11189 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11190 .name = "Master Playback Switch", \
11191 .info = snd_ctl_boolean_mono_info, \
11192 .get = alc262_hp_master_sw_get, \
11193 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011194 }, \
11195 { \
11196 .iface = NID_MAPPING, \
11197 .name = "Master Playback Switch", \
11198 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020011199 }
11200
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011201
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011202static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011203 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011204 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11205 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11206 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011207 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11208 HDA_OUTPUT),
11209 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11210 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011211 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11212 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011213 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011214 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11215 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011216 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011217 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11218 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11219 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11220 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011221 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
11222 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
11223 { } /* end */
11224};
11225
Kailang Yangcd7509a2007-01-26 18:33:17 +010011226static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011227 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010011228 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11229 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11230 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11231 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011232 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11233 HDA_OUTPUT),
11234 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11235 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011236 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11237 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011238 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011239 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11240 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11241 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11242 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011243 { } /* end */
11244};
11245
11246static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11247 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11248 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011249 HDA_CODEC_VOLUME("Rear Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011250 { } /* end */
11251};
11252
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011253/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011254static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011255{
11256 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011257
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011258 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011259 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011260}
11261
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011262static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011263 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11264 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011265 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11266 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11267 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11268 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011269 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011270 { } /* end */
11271};
11272
11273static struct hda_verb alc262_hp_t5735_verbs[] = {
11274 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11275 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11276
11277 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11278 { }
11279};
11280
Kailang Yang8c427222008-01-10 13:03:59 +010011281static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011282 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11283 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011284 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11285 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011286 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11287 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11288 { } /* end */
11289};
11290
11291static struct hda_verb alc262_hp_rp5700_verbs[] = {
11292 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11293 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11294 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11295 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11296 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11297 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11298 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11299 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11300 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11301 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11302 {}
11303};
11304
11305static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11306 .num_items = 1,
11307 .items = {
11308 { "Line", 0x1 },
11309 },
11310};
11311
Takashi Iwai42171c12009-05-08 14:11:43 +020011312/* bind hp and internal speaker mute (with plug check) as master switch */
11313static void alc262_hippo_master_update(struct hda_codec *codec)
11314{
11315 struct alc_spec *spec = codec->spec;
11316 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11317 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11318 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11319 unsigned int mute;
11320
11321 /* HP */
11322 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11323 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11324 HDA_AMP_MUTE, mute);
11325 /* mute internal speaker per jack sense */
11326 if (spec->jack_present)
11327 mute = HDA_AMP_MUTE;
11328 if (line_nid)
11329 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11330 HDA_AMP_MUTE, mute);
11331 if (speaker_nid && speaker_nid != line_nid)
11332 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11333 HDA_AMP_MUTE, mute);
11334}
11335
11336#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
11337
11338static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11339 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020011340{
11341 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020011342 struct alc_spec *spec = codec->spec;
11343 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011344
Takashi Iwai42171c12009-05-08 14:11:43 +020011345 if (val == spec->master_sw)
11346 return 0;
11347 spec->master_sw = val;
11348 alc262_hippo_master_update(codec);
11349 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011350}
Takashi Iwai5b319542007-07-26 11:49:22 +020011351
Takashi Iwai42171c12009-05-08 14:11:43 +020011352#define ALC262_HIPPO_MASTER_SWITCH \
11353 { \
11354 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11355 .name = "Master Playback Switch", \
11356 .info = snd_ctl_boolean_mono_info, \
11357 .get = alc262_hippo_master_sw_get, \
11358 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011359 }, \
11360 { \
11361 .iface = NID_MAPPING, \
11362 .name = "Master Playback Switch", \
11363 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11364 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011365 }
11366
11367static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11368 ALC262_HIPPO_MASTER_SWITCH,
11369 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11370 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11371 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11372 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11373 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11374 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11375 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011376 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011377 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11378 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011379 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011380 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11381 { } /* end */
11382};
11383
11384static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11385 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11386 ALC262_HIPPO_MASTER_SWITCH,
11387 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11388 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11389 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11390 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11391 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11392 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011393 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011394 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11395 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011396 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011397 { } /* end */
11398};
11399
11400/* mute/unmute internal speaker according to the hp jack and mute state */
11401static void alc262_hippo_automute(struct hda_codec *codec)
11402{
11403 struct alc_spec *spec = codec->spec;
11404 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020011405
Wu Fengguang864f92b2009-11-18 12:38:02 +080011406 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020011407 alc262_hippo_master_update(codec);
11408}
11409
11410static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11411{
11412 if ((res >> 26) != ALC880_HP_EVENT)
11413 return;
11414 alc262_hippo_automute(codec);
11415}
11416
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011417static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011418{
11419 struct alc_spec *spec = codec->spec;
11420
11421 spec->autocfg.hp_pins[0] = 0x15;
11422 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011423}
11424
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011425static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011426{
11427 struct alc_spec *spec = codec->spec;
11428
11429 spec->autocfg.hp_pins[0] = 0x1b;
11430 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011431}
11432
11433
Kailang Yang272a5272007-05-14 11:00:38 +020011434static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011435 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011436 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011437 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11438 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11439 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11440 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11441 { } /* end */
11442};
11443
Kailang Yang83c34212007-07-05 11:43:05 +020011444static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011445 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11446 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011447 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11448 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11449 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11450 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11451 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11452 { } /* end */
11453};
Kailang Yang272a5272007-05-14 11:00:38 +020011454
Tony Vroonba340e82009-02-02 19:01:30 +000011455static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11456 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11457 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11458 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11459 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11460 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11461 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11462 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11463 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011464 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011465 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11466 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011467 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011468 { } /* end */
11469};
11470
11471static struct hda_verb alc262_tyan_verbs[] = {
11472 /* Headphone automute */
11473 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11474 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11475 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11476
11477 /* P11 AUX_IN, white 4-pin connector */
11478 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11479 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11480 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11481 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11482
11483 {}
11484};
11485
11486/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011487static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011488{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011489 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011490
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011491 spec->autocfg.hp_pins[0] = 0x1b;
11492 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011493}
11494
Tony Vroonba340e82009-02-02 19:01:30 +000011495
Kailang Yangdf694da2005-12-05 19:42:22 +010011496#define alc262_capture_mixer alc882_capture_mixer
11497#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11498
11499/*
11500 * generic initialization of ADC, input mixers and output mixers
11501 */
11502static struct hda_verb alc262_init_verbs[] = {
11503 /*
11504 * Unmute ADC0-2 and set the default input to mic-in
11505 */
11506 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11507 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11508 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11509 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11510 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11511 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11512
Takashi Iwaicb53c622007-08-10 17:21:45 +020011513 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011514 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011515 * Note: PASD motherboards uses the Line In 2 as the input for
11516 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011517 */
11518 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011519 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11520 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11521 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11522 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11523 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011524
11525 /*
11526 * Set up output mixers (0x0c - 0x0e)
11527 */
11528 /* set vol=0 to output mixers */
11529 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11530 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11531 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11532 /* set up input amps for analog loopback */
11533 /* Amp Indices: DAC = 0, mixer = 1 */
11534 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11535 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11536 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11537 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11538 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11539 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11540
11541 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11542 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11543 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11544 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11545 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11546 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11547
11548 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11549 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11550 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11551 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11552 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011553
Kailang Yangdf694da2005-12-05 19:42:22 +010011554 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11555 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011556
Kailang Yangdf694da2005-12-05 19:42:22 +010011557 /* FIXME: use matrix-type input source selection */
11558 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11559 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11560 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11561 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11562 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11563 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11564 /* Input mixer2 */
11565 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11566 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11567 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11568 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11569 /* Input mixer3 */
11570 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11571 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11572 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011573 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011574
11575 { }
11576};
11577
Kailang Yang4e555fe2008-08-26 13:05:55 +020011578static struct hda_verb alc262_eapd_verbs[] = {
11579 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11580 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11581 { }
11582};
11583
Kailang Yangccc656c2006-10-17 12:32:26 +020011584static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11585 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11586 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11587 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11588
11589 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11590 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11591 {}
11592};
11593
Kailang Yang272a5272007-05-14 11:00:38 +020011594static struct hda_verb alc262_sony_unsol_verbs[] = {
11595 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11596 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11597 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11598
11599 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11600 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011601 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011602};
11603
Kailang Yang4e555fe2008-08-26 13:05:55 +020011604static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11605 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11606 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11607 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11608 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11609 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011610 { } /* end */
11611};
11612
11613static struct hda_verb alc262_toshiba_s06_verbs[] = {
11614 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11615 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11616 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11617 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11618 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11619 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11620 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11621 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11622 {}
11623};
11624
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011625static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011626{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011627 struct alc_spec *spec = codec->spec;
11628
11629 spec->autocfg.hp_pins[0] = 0x15;
11630 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011631 spec->ext_mic.pin = 0x18;
11632 spec->ext_mic.mux_idx = 0;
11633 spec->int_mic.pin = 0x12;
11634 spec->int_mic.mux_idx = 9;
11635 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011636}
11637
Takashi Iwai834be882006-03-01 14:16:17 +010011638/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011639 * nec model
11640 * 0x15 = headphone
11641 * 0x16 = internal speaker
11642 * 0x18 = external mic
11643 */
11644
11645static struct snd_kcontrol_new alc262_nec_mixer[] = {
11646 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11647 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11648
11649 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11650 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011651 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011652
11653 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11654 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11655 { } /* end */
11656};
11657
11658static struct hda_verb alc262_nec_verbs[] = {
11659 /* Unmute Speaker */
11660 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11661
11662 /* Headphone */
11663 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11664 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11665
11666 /* External mic to headphone */
11667 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11668 /* External mic to speaker */
11669 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11670 {}
11671};
11672
11673/*
Takashi Iwai834be882006-03-01 14:16:17 +010011674 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011675 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11676 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011677 */
11678
11679#define ALC_HP_EVENT 0x37
11680
11681static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11682 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11683 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011684 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11685 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011686 {}
11687};
11688
Jiang zhe0e31daf2008-03-20 12:12:39 +010011689static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11690 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11691 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11692 {}
11693};
11694
Daniel T Chene2595322009-12-19 18:19:02 -050011695static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11696 /* Front Mic pin: input vref at 50% */
11697 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11698 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11699 {}
11700};
11701
Takashi Iwai834be882006-03-01 14:16:17 +010011702static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011703 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011704 .items = {
11705 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010011706 { "Internal Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011707 { "CD", 0x4 },
11708 },
11709};
11710
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011711static struct hda_input_mux alc262_HP_capture_source = {
11712 .num_items = 5,
11713 .items = {
11714 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011715 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011716 { "Line", 0x2 },
11717 { "CD", 0x4 },
11718 { "AUX IN", 0x6 },
11719 },
11720};
11721
zhejiangaccbe492007-08-31 12:36:05 +020011722static struct hda_input_mux alc262_HP_D7000_capture_source = {
11723 .num_items = 4,
11724 .items = {
11725 { "Mic", 0x0 },
11726 { "Front Mic", 0x2 },
11727 { "Line", 0x1 },
11728 { "CD", 0x4 },
11729 },
11730};
11731
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011732/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011733static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11734{
11735 struct alc_spec *spec = codec->spec;
11736 unsigned int mute;
11737
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011738 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011739 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11740 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011741 spec->sense_updated = 1;
11742 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011743 /* unmute internal speaker only if both HPs are unplugged and
11744 * master switch is on
11745 */
11746 if (spec->jack_present)
11747 mute = HDA_AMP_MUTE;
11748 else
Takashi Iwai834be882006-03-01 14:16:17 +010011749 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011750 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11751 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011752}
11753
11754/* unsolicited event for HP jack sensing */
11755static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11756 unsigned int res)
11757{
11758 if ((res >> 26) != ALC_HP_EVENT)
11759 return;
11760 alc262_fujitsu_automute(codec, 1);
11761}
11762
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011763static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11764{
11765 alc262_fujitsu_automute(codec, 1);
11766}
11767
Takashi Iwai834be882006-03-01 14:16:17 +010011768/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011769static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11770 .ops = &snd_hda_bind_vol,
11771 .values = {
11772 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11773 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11774 0
11775 },
11776};
Takashi Iwai834be882006-03-01 14:16:17 +010011777
Jiang zhe0e31daf2008-03-20 12:12:39 +010011778/* mute/unmute internal speaker according to the hp jack and mute state */
11779static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11780{
11781 struct alc_spec *spec = codec->spec;
11782 unsigned int mute;
11783
11784 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011785 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011786 spec->sense_updated = 1;
11787 }
11788 if (spec->jack_present) {
11789 /* mute internal speaker */
11790 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11791 HDA_AMP_MUTE, HDA_AMP_MUTE);
11792 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11793 HDA_AMP_MUTE, HDA_AMP_MUTE);
11794 } else {
11795 /* unmute internal speaker if necessary */
11796 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11797 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11798 HDA_AMP_MUTE, mute);
11799 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11800 HDA_AMP_MUTE, mute);
11801 }
11802}
11803
11804/* unsolicited event for HP jack sensing */
11805static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11806 unsigned int res)
11807{
11808 if ((res >> 26) != ALC_HP_EVENT)
11809 return;
11810 alc262_lenovo_3000_automute(codec, 1);
11811}
11812
Takashi Iwai8de56b72009-07-24 16:51:47 +020011813static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11814 int dir, int idx, long *valp)
11815{
11816 int i, change = 0;
11817
11818 for (i = 0; i < 2; i++, valp++)
11819 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11820 HDA_AMP_MUTE,
11821 *valp ? 0 : HDA_AMP_MUTE);
11822 return change;
11823}
11824
Takashi Iwai834be882006-03-01 14:16:17 +010011825/* bind hp and internal speaker mute (with plug check) */
11826static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11827 struct snd_ctl_elem_value *ucontrol)
11828{
11829 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11830 long *valp = ucontrol->value.integer.value;
11831 int change;
11832
Takashi Iwai8de56b72009-07-24 16:51:47 +020011833 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11834 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011835 if (change)
11836 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011837 return change;
11838}
11839
11840static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011841 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011842 {
11843 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11844 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011845 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011846 .info = snd_hda_mixer_amp_switch_info,
11847 .get = snd_hda_mixer_amp_switch_get,
11848 .put = alc262_fujitsu_master_sw_put,
11849 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11850 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011851 {
11852 .iface = NID_MAPPING,
11853 .name = "Master Playback Switch",
11854 .private_value = 0x1b,
11855 },
Takashi Iwai834be882006-03-01 14:16:17 +010011856 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11857 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011858 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011859 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11860 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011861 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010011862 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11863 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011864 { } /* end */
11865};
11866
Jiang zhe0e31daf2008-03-20 12:12:39 +010011867/* bind hp and internal speaker mute (with plug check) */
11868static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11869 struct snd_ctl_elem_value *ucontrol)
11870{
11871 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11872 long *valp = ucontrol->value.integer.value;
11873 int change;
11874
Takashi Iwai8de56b72009-07-24 16:51:47 +020011875 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011876 if (change)
11877 alc262_lenovo_3000_automute(codec, 0);
11878 return change;
11879}
11880
11881static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11882 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11883 {
11884 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11885 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011886 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011887 .info = snd_hda_mixer_amp_switch_info,
11888 .get = snd_hda_mixer_amp_switch_get,
11889 .put = alc262_lenovo_3000_master_sw_put,
11890 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11891 },
11892 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11893 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011894 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011895 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11896 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011897 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010011898 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11899 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011900 { } /* end */
11901};
11902
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011903static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11904 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011905 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011906 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11907 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011908 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011909 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11910 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011911 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011912 { } /* end */
11913};
11914
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011915/* additional init verbs for Benq laptops */
11916static struct hda_verb alc262_EAPD_verbs[] = {
11917 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11918 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11919 {}
11920};
11921
Kailang Yang83c34212007-07-05 11:43:05 +020011922static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11923 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11924 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11925
11926 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11927 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11928 {}
11929};
11930
Tobin Davisf651b502007-10-26 12:40:47 +020011931/* Samsung Q1 Ultra Vista model setup */
11932static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011933 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11934 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11936 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011937 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
11938 HDA_CODEC_VOLUME("Headphone Mic Boost Volume", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011939 { } /* end */
11940};
11941
11942static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011943 /* output mixer */
11944 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11945 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11946 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11947 /* speaker */
11948 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11949 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11950 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11951 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11952 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011953 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011954 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11955 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11956 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11957 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11958 /* internal mic */
11959 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11960 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11961 /* ADC, choose mic */
11962 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11963 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11964 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11965 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11966 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11967 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11968 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11969 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11970 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11971 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011972 {}
11973};
11974
Tobin Davisf651b502007-10-26 12:40:47 +020011975/* mute/unmute internal speaker according to the hp jack and mute state */
11976static void alc262_ultra_automute(struct hda_codec *codec)
11977{
11978 struct alc_spec *spec = codec->spec;
11979 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011980
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011981 mute = 0;
11982 /* auto-mute only when HP is used as HP */
11983 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011984 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011985 if (spec->jack_present)
11986 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011987 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011988 /* mute/unmute internal speaker */
11989 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11990 HDA_AMP_MUTE, mute);
11991 /* mute/unmute HP */
11992 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11993 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011994}
11995
11996/* unsolicited event for HP jack sensing */
11997static void alc262_ultra_unsol_event(struct hda_codec *codec,
11998 unsigned int res)
11999{
12000 if ((res >> 26) != ALC880_HP_EVENT)
12001 return;
12002 alc262_ultra_automute(codec);
12003}
12004
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012005static struct hda_input_mux alc262_ultra_capture_source = {
12006 .num_items = 2,
12007 .items = {
12008 { "Mic", 0x1 },
12009 { "Headphone", 0x7 },
12010 },
12011};
12012
12013static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
12014 struct snd_ctl_elem_value *ucontrol)
12015{
12016 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12017 struct alc_spec *spec = codec->spec;
12018 int ret;
12019
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012020 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012021 if (!ret)
12022 return 0;
12023 /* reprogram the HP pin as mic or HP according to the input source */
12024 snd_hda_codec_write_cache(codec, 0x15, 0,
12025 AC_VERB_SET_PIN_WIDGET_CONTROL,
12026 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
12027 alc262_ultra_automute(codec); /* mute/unmute HP */
12028 return ret;
12029}
12030
12031static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
12032 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
12033 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
12034 {
12035 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12036 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012037 .info = alc_mux_enum_info,
12038 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012039 .put = alc262_ultra_mux_enum_put,
12040 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010012041 {
12042 .iface = NID_MAPPING,
12043 .name = "Capture Source",
12044 .private_value = 0x15,
12045 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012046 { } /* end */
12047};
12048
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012049/* We use two mixers depending on the output pin; 0x16 is a mono output
12050 * and thus it's bound with a different mixer.
12051 * This function returns which mixer amp should be used.
12052 */
12053static int alc262_check_volbit(hda_nid_t nid)
12054{
12055 if (!nid)
12056 return 0;
12057 else if (nid == 0x16)
12058 return 2;
12059 else
12060 return 1;
12061}
12062
12063static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012064 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012065{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012066 unsigned long val;
12067 int vbit;
12068
12069 vbit = alc262_check_volbit(nid);
12070 if (!vbit)
12071 return 0;
12072 if (*vbits & vbit) /* a volume control for this mixer already there */
12073 return 0;
12074 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012075 if (vbit == 2)
12076 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
12077 else
12078 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012079 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012080}
12081
12082static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012083 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012084{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012085 unsigned long val;
12086
12087 if (!nid)
12088 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012089 if (nid == 0x16)
12090 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
12091 else
12092 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012093 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012094}
12095
Kailang Yangdf694da2005-12-05 19:42:22 +010012096/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012097static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
12098 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012099{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012100 const char *pfx;
12101 int vbits;
Takashi Iwai033688a2010-09-08 15:47:09 +020012102 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010012103
12104 spec->multiout.num_dacs = 1; /* only use one dac */
12105 spec->multiout.dac_nids = spec->private_dac_nids;
12106 spec->multiout.dac_nids[0] = 2;
12107
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010012108 pfx = alc_get_line_out_pfx(cfg, true);
12109 if (!pfx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012110 pfx = "Front";
Takashi Iwai033688a2010-09-08 15:47:09 +020012111 for (i = 0; i < 2; i++) {
12112 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
12113 if (err < 0)
12114 return err;
12115 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12116 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
12117 "Speaker", i);
12118 if (err < 0)
12119 return err;
12120 }
12121 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12122 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
12123 "Headphone", i);
12124 if (err < 0)
12125 return err;
12126 }
12127 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012128
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012129 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
12130 alc262_check_volbit(cfg->speaker_pins[0]) |
12131 alc262_check_volbit(cfg->hp_pins[0]);
12132 if (vbits == 1 || vbits == 2)
12133 pfx = "Master"; /* only one mixer is used */
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012134 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020012135 for (i = 0; i < 2; i++) {
12136 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
12137 &vbits, i);
12138 if (err < 0)
12139 return err;
12140 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12141 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
12142 "Speaker", &vbits, i);
12143 if (err < 0)
12144 return err;
12145 }
12146 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12147 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
12148 "Headphone", &vbits, i);
12149 if (err < 0)
12150 return err;
12151 }
12152 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012153 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010012154}
12155
Takashi Iwai05f5f472009-08-25 13:10:18 +020012156#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010012157 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010012158
12159/*
12160 * generic initialization of ADC, input mixers and output mixers
12161 */
12162static struct hda_verb alc262_volume_init_verbs[] = {
12163 /*
12164 * Unmute ADC0-2 and set the default input to mic-in
12165 */
12166 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12167 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12168 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12169 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12170 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12171 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12172
Takashi Iwaicb53c622007-08-10 17:21:45 +020012173 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010012174 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012175 * Note: PASD motherboards uses the Line In 2 as the input for
12176 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010012177 */
12178 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012179 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12180 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12181 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12182 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12183 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012184
12185 /*
12186 * Set up output mixers (0x0c - 0x0f)
12187 */
12188 /* set vol=0 to output mixers */
12189 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12190 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12191 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020012192
Kailang Yangdf694da2005-12-05 19:42:22 +010012193 /* set up input amps for analog loopback */
12194 /* Amp Indices: DAC = 0, mixer = 1 */
12195 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12196 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12197 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12198 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12199 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12200 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12201
12202 /* FIXME: use matrix-type input source selection */
12203 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12204 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12205 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12206 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12207 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12208 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12209 /* Input mixer2 */
12210 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12211 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12212 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12213 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12214 /* Input mixer3 */
12215 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12216 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12217 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12218 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12219
12220 { }
12221};
12222
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012223static struct hda_verb alc262_HP_BPC_init_verbs[] = {
12224 /*
12225 * Unmute ADC0-2 and set the default input to mic-in
12226 */
12227 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12228 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12229 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12230 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12231 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12232 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12233
Takashi Iwaicb53c622007-08-10 17:21:45 +020012234 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012235 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012236 * Note: PASD motherboards uses the Line In 2 as the input for
12237 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012238 */
12239 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012240 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12241 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12242 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12243 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12244 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12245 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12246 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012247
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012248 /*
12249 * Set up output mixers (0x0c - 0x0e)
12250 */
12251 /* set vol=0 to output mixers */
12252 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12253 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12254 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12255
12256 /* set up input amps for analog loopback */
12257 /* Amp Indices: DAC = 0, mixer = 1 */
12258 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12259 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12260 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12261 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12262 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12263 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12264
Takashi Iwaice875f02008-01-28 18:17:43 +010012265 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012266 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12267 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12268
12269 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12270 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12271
12272 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12273 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12274
12275 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12276 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12277 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12278 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12279 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12280
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012281 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012282 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12283 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012284 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012285 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12286 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12287
12288
12289 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012290 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12291 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012292 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012293 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12294 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12295 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12296 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12297 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12298 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12299 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12300 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012301 /* Input mixer2 */
12302 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012303 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12304 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12305 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12306 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12307 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12308 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12309 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12310 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012311 /* Input mixer3 */
12312 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012313 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12315 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12316 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12317 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12318 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12319 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12320 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012321
Takashi Iwaice875f02008-01-28 18:17:43 +010012322 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12323
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012324 { }
12325};
12326
Kailang Yangcd7509a2007-01-26 18:33:17 +010012327static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12328 /*
12329 * Unmute ADC0-2 and set the default input to mic-in
12330 */
12331 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12332 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12333 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12334 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12335 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12336 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12337
Takashi Iwaicb53c622007-08-10 17:21:45 +020012338 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012339 * mixer widget
12340 * Note: PASD motherboards uses the Line In 2 as the input for front
12341 * panel mic (mic 2)
12342 */
12343 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012344 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12345 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12346 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12347 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12348 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12349 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12350 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12351 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012352 /*
12353 * Set up output mixers (0x0c - 0x0e)
12354 */
12355 /* set vol=0 to output mixers */
12356 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12357 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12358 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12359
12360 /* set up input amps for analog loopback */
12361 /* Amp Indices: DAC = 0, mixer = 1 */
12362 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12363 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12364 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12365 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12366 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12367 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12368
12369
12370 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12371 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12372 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12373 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12374 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12375 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12376 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12377
12378 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12379 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12380
12381 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12382 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12383
12384 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12385 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12386 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12387 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12388 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12389 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12390
12391 /* FIXME: use matrix-type input source selection */
12392 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12393 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12394 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12395 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12396 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12397 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12398 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12399 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12400 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12401 /* Input mixer2 */
12402 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12403 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12404 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12405 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12406 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12407 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12408 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12409 /* Input mixer3 */
12410 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12411 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12412 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12413 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12414 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12415 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12416 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12417
Takashi Iwaice875f02008-01-28 18:17:43 +010012418 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12419
Kailang Yangcd7509a2007-01-26 18:33:17 +010012420 { }
12421};
12422
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012423static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12424
12425 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12426 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12427 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12428
12429 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12430 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12431 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12432 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12433
12434 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12435 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12436 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12437 {}
12438};
12439
Takashi Iwai18675e42010-09-08 15:55:44 +020012440/*
12441 * Pin config fixes
12442 */
12443enum {
12444 PINFIX_FSC_H270,
12445};
12446
12447static const struct alc_fixup alc262_fixups[] = {
12448 [PINFIX_FSC_H270] = {
12449 .pins = (const struct alc_pincfg[]) {
12450 { 0x14, 0x99130110 }, /* speaker */
12451 { 0x15, 0x0221142f }, /* front HP */
12452 { 0x1b, 0x0121141f }, /* rear HP */
12453 { }
12454 }
12455 },
12456 [PINFIX_PB_M5210] = {
12457 .verbs = (const struct hda_verb[]) {
12458 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
12459 {}
12460 }
12461 },
12462};
12463
12464static struct snd_pci_quirk alc262_fixup_tbl[] = {
12465 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12466 {}
12467};
12468
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012469
Takashi Iwaicb53c622007-08-10 17:21:45 +020012470#ifdef CONFIG_SND_HDA_POWER_SAVE
12471#define alc262_loopbacks alc880_loopbacks
12472#endif
12473
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012474/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012475#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12476#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12477#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12478#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12479
12480/*
12481 * BIOS auto configuration
12482 */
12483static int alc262_parse_auto_config(struct hda_codec *codec)
12484{
12485 struct alc_spec *spec = codec->spec;
12486 int err;
12487 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12488
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012489 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12490 alc262_ignore);
12491 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012492 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012493 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012494 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012495 spec->multiout.max_channels = 2;
12496 spec->no_analog = 1;
12497 goto dig_only;
12498 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012499 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012500 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012501 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12502 if (err < 0)
12503 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012504 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012505 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012506 return err;
12507
12508 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12509
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012510 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012511 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012512
Takashi Iwai603c4012008-07-30 15:01:44 +020012513 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012514 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012515
Takashi Iwaid88897e2008-10-31 15:01:37 +010012516 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012517 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012518 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012519
Takashi Iwai776e1842007-08-29 15:07:11 +020012520 err = alc_auto_add_mic_boost(codec);
12521 if (err < 0)
12522 return err;
12523
Kailang Yang6227cdc2010-02-25 08:36:52 +010012524 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012525
Kailang Yangdf694da2005-12-05 19:42:22 +010012526 return 1;
12527}
12528
12529#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12530#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12531#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012532#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012533
12534
12535/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012536static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012537{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012538 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012539 alc262_auto_init_multi_out(codec);
12540 alc262_auto_init_hp_out(codec);
12541 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012542 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012543 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012544 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012545 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012546}
12547
12548/*
12549 * configuration and preset
12550 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012551static const char *alc262_models[ALC262_MODEL_LAST] = {
12552 [ALC262_BASIC] = "basic",
12553 [ALC262_HIPPO] = "hippo",
12554 [ALC262_HIPPO_1] = "hippo_1",
12555 [ALC262_FUJITSU] = "fujitsu",
12556 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012557 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012558 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012559 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012560 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012561 [ALC262_BENQ_T31] = "benq-t31",
12562 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012563 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012564 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012565 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012566 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012567 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012568 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012569 [ALC262_AUTO] = "auto",
12570};
12571
12572static struct snd_pci_quirk alc262_cfg_tbl[] = {
12573 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012574 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012575 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12576 ALC262_HP_BPC),
12577 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12578 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012579 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12580 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012581 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012582 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012583 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012584 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012585 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012586 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012587 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012588 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012589 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12590 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12591 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012592 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12593 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012594 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012595 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012596 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012597 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012598 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012599 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012600 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012601 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012602#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012603 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12604 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012605#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012606 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012607 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012608 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012609 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012610 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012611 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012612 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12613 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012614 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012615 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012616 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012617 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012618 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012619 {}
12620};
12621
12622static struct alc_config_preset alc262_presets[] = {
12623 [ALC262_BASIC] = {
12624 .mixers = { alc262_base_mixer },
12625 .init_verbs = { alc262_init_verbs },
12626 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12627 .dac_nids = alc262_dac_nids,
12628 .hp_nid = 0x03,
12629 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12630 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012631 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012632 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012633 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012634 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012635 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012636 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12637 .dac_nids = alc262_dac_nids,
12638 .hp_nid = 0x03,
12639 .dig_out_nid = ALC262_DIGOUT_NID,
12640 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12641 .channel_mode = alc262_modes,
12642 .input_mux = &alc262_capture_source,
12643 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012644 .setup = alc262_hippo_setup,
12645 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012646 },
12647 [ALC262_HIPPO_1] = {
12648 .mixers = { alc262_hippo1_mixer },
12649 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12650 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12651 .dac_nids = alc262_dac_nids,
12652 .hp_nid = 0x02,
12653 .dig_out_nid = ALC262_DIGOUT_NID,
12654 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12655 .channel_mode = alc262_modes,
12656 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012657 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012658 .setup = alc262_hippo1_setup,
12659 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012660 },
Takashi Iwai834be882006-03-01 14:16:17 +010012661 [ALC262_FUJITSU] = {
12662 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012663 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12664 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012665 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12666 .dac_nids = alc262_dac_nids,
12667 .hp_nid = 0x03,
12668 .dig_out_nid = ALC262_DIGOUT_NID,
12669 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12670 .channel_mode = alc262_modes,
12671 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012672 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012673 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012674 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012675 [ALC262_HP_BPC] = {
12676 .mixers = { alc262_HP_BPC_mixer },
12677 .init_verbs = { alc262_HP_BPC_init_verbs },
12678 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12679 .dac_nids = alc262_dac_nids,
12680 .hp_nid = 0x03,
12681 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12682 .channel_mode = alc262_modes,
12683 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012684 .unsol_event = alc262_hp_bpc_unsol_event,
12685 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012686 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012687 [ALC262_HP_BPC_D7000_WF] = {
12688 .mixers = { alc262_HP_BPC_WildWest_mixer },
12689 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12690 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12691 .dac_nids = alc262_dac_nids,
12692 .hp_nid = 0x03,
12693 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12694 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012695 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012696 .unsol_event = alc262_hp_wildwest_unsol_event,
12697 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012698 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012699 [ALC262_HP_BPC_D7000_WL] = {
12700 .mixers = { alc262_HP_BPC_WildWest_mixer,
12701 alc262_HP_BPC_WildWest_option_mixer },
12702 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12703 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12704 .dac_nids = alc262_dac_nids,
12705 .hp_nid = 0x03,
12706 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12707 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012708 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012709 .unsol_event = alc262_hp_wildwest_unsol_event,
12710 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012711 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012712 [ALC262_HP_TC_T5735] = {
12713 .mixers = { alc262_hp_t5735_mixer },
12714 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12715 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12716 .dac_nids = alc262_dac_nids,
12717 .hp_nid = 0x03,
12718 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12719 .channel_mode = alc262_modes,
12720 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012721 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012722 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012723 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012724 },
12725 [ALC262_HP_RP5700] = {
12726 .mixers = { alc262_hp_rp5700_mixer },
12727 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12728 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12729 .dac_nids = alc262_dac_nids,
12730 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12731 .channel_mode = alc262_modes,
12732 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012733 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012734 [ALC262_BENQ_ED8] = {
12735 .mixers = { alc262_base_mixer },
12736 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12737 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12738 .dac_nids = alc262_dac_nids,
12739 .hp_nid = 0x03,
12740 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12741 .channel_mode = alc262_modes,
12742 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012743 },
Kailang Yang272a5272007-05-14 11:00:38 +020012744 [ALC262_SONY_ASSAMD] = {
12745 .mixers = { alc262_sony_mixer },
12746 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12747 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12748 .dac_nids = alc262_dac_nids,
12749 .hp_nid = 0x02,
12750 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12751 .channel_mode = alc262_modes,
12752 .input_mux = &alc262_capture_source,
12753 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012754 .setup = alc262_hippo_setup,
12755 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012756 },
12757 [ALC262_BENQ_T31] = {
12758 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012759 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12760 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012761 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12762 .dac_nids = alc262_dac_nids,
12763 .hp_nid = 0x03,
12764 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12765 .channel_mode = alc262_modes,
12766 .input_mux = &alc262_capture_source,
12767 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012768 .setup = alc262_hippo_setup,
12769 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012770 },
Tobin Davisf651b502007-10-26 12:40:47 +020012771 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012772 .mixers = { alc262_ultra_mixer },
12773 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012774 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012775 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12776 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012777 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12778 .channel_mode = alc262_modes,
12779 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012780 .adc_nids = alc262_adc_nids, /* ADC0 */
12781 .capsrc_nids = alc262_capsrc_nids,
12782 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012783 .unsol_event = alc262_ultra_unsol_event,
12784 .init_hook = alc262_ultra_automute,
12785 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012786 [ALC262_LENOVO_3000] = {
12787 .mixers = { alc262_lenovo_3000_mixer },
12788 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012789 alc262_lenovo_3000_unsol_verbs,
12790 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012791 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12792 .dac_nids = alc262_dac_nids,
12793 .hp_nid = 0x03,
12794 .dig_out_nid = ALC262_DIGOUT_NID,
12795 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12796 .channel_mode = alc262_modes,
12797 .input_mux = &alc262_fujitsu_capture_source,
12798 .unsol_event = alc262_lenovo_3000_unsol_event,
12799 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012800 [ALC262_NEC] = {
12801 .mixers = { alc262_nec_mixer },
12802 .init_verbs = { alc262_nec_verbs },
12803 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12804 .dac_nids = alc262_dac_nids,
12805 .hp_nid = 0x03,
12806 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12807 .channel_mode = alc262_modes,
12808 .input_mux = &alc262_capture_source,
12809 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012810 [ALC262_TOSHIBA_S06] = {
12811 .mixers = { alc262_toshiba_s06_mixer },
12812 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12813 alc262_eapd_verbs },
12814 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12815 .capsrc_nids = alc262_dmic_capsrc_nids,
12816 .dac_nids = alc262_dac_nids,
12817 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012818 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012819 .dig_out_nid = ALC262_DIGOUT_NID,
12820 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12821 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012822 .unsol_event = alc_sku_unsol_event,
12823 .setup = alc262_toshiba_s06_setup,
12824 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012825 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012826 [ALC262_TOSHIBA_RX1] = {
12827 .mixers = { alc262_toshiba_rx1_mixer },
12828 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12829 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12830 .dac_nids = alc262_dac_nids,
12831 .hp_nid = 0x03,
12832 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12833 .channel_mode = alc262_modes,
12834 .input_mux = &alc262_capture_source,
12835 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012836 .setup = alc262_hippo_setup,
12837 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012838 },
Tony Vroonba340e82009-02-02 19:01:30 +000012839 [ALC262_TYAN] = {
12840 .mixers = { alc262_tyan_mixer },
12841 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12842 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12843 .dac_nids = alc262_dac_nids,
12844 .hp_nid = 0x02,
12845 .dig_out_nid = ALC262_DIGOUT_NID,
12846 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12847 .channel_mode = alc262_modes,
12848 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012849 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012850 .setup = alc262_tyan_setup,
12851 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012852 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012853};
12854
12855static int patch_alc262(struct hda_codec *codec)
12856{
12857 struct alc_spec *spec;
12858 int board_config;
12859 int err;
12860
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012861 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012862 if (spec == NULL)
12863 return -ENOMEM;
12864
12865 codec->spec = spec;
12866#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012867 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12868 * under-run
12869 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012870 {
12871 int tmp;
12872 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12873 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12874 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12875 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12876 }
12877#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012878 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012879
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012880 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12881
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012882 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12883 alc262_models,
12884 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012885
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012886 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012887 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12888 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012889 board_config = ALC262_AUTO;
12890 }
12891
Takashi Iwai18675e42010-09-08 15:55:44 +020012892 if (board_config == ALC262_AUTO)
12893 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 1);
12894
Kailang Yangdf694da2005-12-05 19:42:22 +010012895 if (board_config == ALC262_AUTO) {
12896 /* automatic parse from the BIOS config */
12897 err = alc262_parse_auto_config(codec);
12898 if (err < 0) {
12899 alc_free(codec);
12900 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012901 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012902 printk(KERN_INFO
12903 "hda_codec: Cannot set up configuration "
12904 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012905 board_config = ALC262_BASIC;
12906 }
12907 }
12908
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012909 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012910 err = snd_hda_attach_beep_device(codec, 0x1);
12911 if (err < 0) {
12912 alc_free(codec);
12913 return err;
12914 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012915 }
12916
Kailang Yangdf694da2005-12-05 19:42:22 +010012917 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012918 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012919
Kailang Yangdf694da2005-12-05 19:42:22 +010012920 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12921 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012922
Kailang Yangdf694da2005-12-05 19:42:22 +010012923 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12924 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12925
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012926 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012927 int i;
12928 /* check whether the digital-mic has to be supported */
12929 for (i = 0; i < spec->input_mux->num_items; i++) {
12930 if (spec->input_mux->items[i].index >= 9)
12931 break;
12932 }
12933 if (i < spec->input_mux->num_items) {
12934 /* use only ADC0 */
12935 spec->adc_nids = alc262_dmic_adc_nids;
12936 spec->num_adc_nids = 1;
12937 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012938 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012939 /* all analog inputs */
12940 /* check whether NID 0x07 is valid */
12941 unsigned int wcap = get_wcaps(codec, 0x07);
12942
12943 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012944 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012945 if (wcap != AC_WID_AUD_IN) {
12946 spec->adc_nids = alc262_adc_nids_alt;
12947 spec->num_adc_nids =
12948 ARRAY_SIZE(alc262_adc_nids_alt);
12949 spec->capsrc_nids = alc262_capsrc_nids_alt;
12950 } else {
12951 spec->adc_nids = alc262_adc_nids;
12952 spec->num_adc_nids =
12953 ARRAY_SIZE(alc262_adc_nids);
12954 spec->capsrc_nids = alc262_capsrc_nids;
12955 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012956 }
12957 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012958 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012959 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012960 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010012961 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012962
Takashi Iwai18675e42010-09-08 15:55:44 +020012963 if (board_config == ALC262_AUTO)
12964 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 0);
12965
Takashi Iwai2134ea42008-01-10 16:53:55 +010012966 spec->vmaster_nid = 0x0c;
12967
Kailang Yangdf694da2005-12-05 19:42:22 +010012968 codec->patch_ops = alc_patch_ops;
12969 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012970 spec->init_hook = alc262_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020012971
12972 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020012973#ifdef CONFIG_SND_HDA_POWER_SAVE
12974 if (!spec->loopback.amplist)
12975 spec->loopback.amplist = alc262_loopbacks;
12976#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012977
Kailang Yangdf694da2005-12-05 19:42:22 +010012978 return 0;
12979}
12980
Kailang Yangdf694da2005-12-05 19:42:22 +010012981/*
Kailang Yanga361d842007-06-05 12:30:55 +020012982 * ALC268 channel source setting (2 channel)
12983 */
12984#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12985#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012986
Kailang Yanga361d842007-06-05 12:30:55 +020012987static hda_nid_t alc268_dac_nids[2] = {
12988 /* front, hp */
12989 0x02, 0x03
12990};
12991
12992static hda_nid_t alc268_adc_nids[2] = {
12993 /* ADC0-1 */
12994 0x08, 0x07
12995};
12996
12997static hda_nid_t alc268_adc_nids_alt[1] = {
12998 /* ADC0 */
12999 0x08
13000};
13001
Takashi Iwaie1406342008-02-11 18:32:32 +010013002static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
13003
Kailang Yanga361d842007-06-05 12:30:55 +020013004static struct snd_kcontrol_new alc268_base_mixer[] = {
13005 /* output mixer control */
13006 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13007 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13008 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13009 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013010 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13011 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13012 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020013013 { }
13014};
13015
Takashi Iwai42171c12009-05-08 14:11:43 +020013016static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
13017 /* output mixer control */
13018 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13019 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13020 ALC262_HIPPO_MASTER_SWITCH,
David Henningsson5f99f862011-01-04 15:24:24 +010013021 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13022 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13023 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020013024 { }
13025};
13026
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013027/* bind Beep switches of both NID 0x0f and 0x10 */
13028static struct hda_bind_ctls alc268_bind_beep_sw = {
13029 .ops = &snd_hda_bind_sw,
13030 .values = {
13031 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
13032 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
13033 0
13034 },
13035};
13036
13037static struct snd_kcontrol_new alc268_beep_mixer[] = {
13038 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
13039 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
13040 { }
13041};
13042
Kailang Yangd1a991a2007-08-15 16:21:59 +020013043static struct hda_verb alc268_eapd_verbs[] = {
13044 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13045 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13046 { }
13047};
13048
Takashi Iwaid2738092007-08-16 14:59:45 +020013049/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020013050static struct hda_verb alc268_toshiba_verbs[] = {
13051 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13052 { } /* end */
13053};
13054
13055/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020013056/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020013057static struct hda_bind_ctls alc268_acer_bind_master_vol = {
13058 .ops = &snd_hda_bind_vol,
13059 .values = {
13060 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
13061 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
13062 0
13063 },
13064};
13065
Takashi Iwai889c4392007-08-23 18:56:52 +020013066/* mute/unmute internal speaker according to the hp jack and mute state */
13067static void alc268_acer_automute(struct hda_codec *codec, int force)
13068{
13069 struct alc_spec *spec = codec->spec;
13070 unsigned int mute;
13071
13072 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080013073 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020013074 spec->sense_updated = 1;
13075 }
13076 if (spec->jack_present)
13077 mute = HDA_AMP_MUTE; /* mute internal speaker */
13078 else /* unmute internal speaker if necessary */
13079 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13080 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13081 HDA_AMP_MUTE, mute);
13082}
13083
13084
13085/* bind hp and internal speaker mute (with plug check) */
13086static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
13087 struct snd_ctl_elem_value *ucontrol)
13088{
13089 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
13090 long *valp = ucontrol->value.integer.value;
13091 int change;
13092
Takashi Iwai8de56b72009-07-24 16:51:47 +020013093 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020013094 if (change)
13095 alc268_acer_automute(codec, 0);
13096 return change;
13097}
Takashi Iwaid2738092007-08-16 14:59:45 +020013098
Kailang Yang8ef355d2008-08-26 13:10:22 +020013099static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
13100 /* output mixer control */
13101 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13102 {
13103 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13104 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013105 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013106 .info = snd_hda_mixer_amp_switch_info,
13107 .get = snd_hda_mixer_amp_switch_get,
13108 .put = alc268_acer_master_sw_put,
13109 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13110 },
13111 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
13112 { }
13113};
13114
Takashi Iwaid2738092007-08-16 14:59:45 +020013115static struct snd_kcontrol_new alc268_acer_mixer[] = {
13116 /* output mixer control */
13117 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13118 {
13119 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13120 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013121 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020013122 .info = snd_hda_mixer_amp_switch_info,
13123 .get = snd_hda_mixer_amp_switch_get,
13124 .put = alc268_acer_master_sw_put,
13125 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13126 },
David Henningsson5f99f862011-01-04 15:24:24 +010013127 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13128 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
13129 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020013130 { }
13131};
13132
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013133static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
13134 /* output mixer control */
13135 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13136 {
13137 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13138 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013139 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013140 .info = snd_hda_mixer_amp_switch_info,
13141 .get = snd_hda_mixer_amp_switch_get,
13142 .put = alc268_acer_master_sw_put,
13143 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13144 },
David Henningsson5f99f862011-01-04 15:24:24 +010013145 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13146 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013147 { }
13148};
13149
Kailang Yang8ef355d2008-08-26 13:10:22 +020013150static struct hda_verb alc268_acer_aspire_one_verbs[] = {
13151 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13152 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13153 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13154 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13155 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
13156 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
13157 { }
13158};
13159
Takashi Iwaid2738092007-08-16 14:59:45 +020013160static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013161 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
13162 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020013163 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13164 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013165 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13166 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020013167 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13168 { }
13169};
13170
13171/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020013172#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013173#define alc268_toshiba_setup alc262_hippo_setup
13174#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020013175
13176static void alc268_acer_unsol_event(struct hda_codec *codec,
13177 unsigned int res)
13178{
Takashi Iwai889c4392007-08-23 18:56:52 +020013179 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020013180 return;
13181 alc268_acer_automute(codec, 1);
13182}
13183
Takashi Iwai889c4392007-08-23 18:56:52 +020013184static void alc268_acer_init_hook(struct hda_codec *codec)
13185{
13186 alc268_acer_automute(codec, 1);
13187}
13188
Kailang Yang8ef355d2008-08-26 13:10:22 +020013189/* toggle speaker-output according to the hp-jack state */
13190static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
13191{
13192 unsigned int present;
13193 unsigned char bits;
13194
Wu Fengguang864f92b2009-11-18 12:38:02 +080013195 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013196 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013197 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013198 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013199 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013200 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013201}
13202
Kailang Yang8ef355d2008-08-26 13:10:22 +020013203static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
13204 unsigned int res)
13205{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013206 switch (res >> 26) {
13207 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020013208 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013209 break;
13210 case ALC880_MIC_EVENT:
13211 alc_mic_automute(codec);
13212 break;
13213 }
13214}
13215
13216static void alc268_acer_lc_setup(struct hda_codec *codec)
13217{
13218 struct alc_spec *spec = codec->spec;
13219 spec->ext_mic.pin = 0x18;
13220 spec->ext_mic.mux_idx = 0;
13221 spec->int_mic.pin = 0x12;
13222 spec->int_mic.mux_idx = 6;
13223 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013224}
13225
13226static void alc268_acer_lc_init_hook(struct hda_codec *codec)
13227{
13228 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013229 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013230}
13231
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013232static struct snd_kcontrol_new alc268_dell_mixer[] = {
13233 /* output mixer control */
13234 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13235 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13236 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13237 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013238 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13239 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013240 { }
13241};
13242
13243static struct hda_verb alc268_dell_verbs[] = {
13244 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13245 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13246 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013247 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013248 { }
13249};
13250
13251/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013252static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013253{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013254 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013255
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013256 spec->autocfg.hp_pins[0] = 0x15;
13257 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013258 spec->ext_mic.pin = 0x18;
13259 spec->ext_mic.mux_idx = 0;
13260 spec->int_mic.pin = 0x19;
13261 spec->int_mic.mux_idx = 1;
13262 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013263}
13264
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013265static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
13266 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13267 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13268 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13269 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13270 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13271 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013272 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13273 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013274 { }
13275};
13276
13277static struct hda_verb alc267_quanta_il1_verbs[] = {
13278 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13279 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13280 { }
13281};
13282
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013283static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013284{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013285 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013286 spec->autocfg.hp_pins[0] = 0x15;
13287 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013288 spec->ext_mic.pin = 0x18;
13289 spec->ext_mic.mux_idx = 0;
13290 spec->int_mic.pin = 0x19;
13291 spec->int_mic.mux_idx = 1;
13292 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013293}
13294
Kailang Yanga361d842007-06-05 12:30:55 +020013295/*
13296 * generic initialization of ADC, input mixers and output mixers
13297 */
13298static struct hda_verb alc268_base_init_verbs[] = {
13299 /* Unmute DAC0-1 and set vol = 0 */
13300 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013301 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013302
13303 /*
13304 * Set up output mixers (0x0c - 0x0e)
13305 */
13306 /* set vol=0 to output mixers */
13307 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013308 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13309
13310 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13311 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13312
13313 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13314 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13315 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13316 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13317 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13318 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13319 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13320 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13321
13322 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13323 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13324 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13325 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013326 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013327
13328 /* set PCBEEP vol = 0, mute connections */
13329 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13330 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13331 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013332
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013333 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013334
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013335 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13336 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13337 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13338 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013339
Kailang Yanga361d842007-06-05 12:30:55 +020013340 { }
13341};
13342
13343/*
13344 * generic initialization of ADC, input mixers and output mixers
13345 */
13346static struct hda_verb alc268_volume_init_verbs[] = {
13347 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013348 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13349 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013350
13351 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13352 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13353 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13354 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13355 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13356
Kailang Yanga361d842007-06-05 12:30:55 +020013357 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013358 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13359 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13360
13361 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013362 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013363
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013364 /* set PCBEEP vol = 0, mute connections */
13365 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13366 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13367 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013368
13369 { }
13370};
13371
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013372static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13373 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13374 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13375 { } /* end */
13376};
13377
Kailang Yanga361d842007-06-05 12:30:55 +020013378static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13379 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13380 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013381 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013382 { } /* end */
13383};
13384
13385static struct snd_kcontrol_new alc268_capture_mixer[] = {
13386 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13387 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13388 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13389 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013390 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013391 { } /* end */
13392};
13393
13394static struct hda_input_mux alc268_capture_source = {
13395 .num_items = 4,
13396 .items = {
13397 { "Mic", 0x0 },
13398 { "Front Mic", 0x1 },
13399 { "Line", 0x2 },
13400 { "CD", 0x3 },
13401 },
13402};
13403
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013404static struct hda_input_mux alc268_acer_capture_source = {
13405 .num_items = 3,
13406 .items = {
13407 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013408 { "Internal Mic", 0x1 },
13409 { "Line", 0x2 },
13410 },
13411};
13412
13413static struct hda_input_mux alc268_acer_dmic_capture_source = {
13414 .num_items = 3,
13415 .items = {
13416 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013417 { "Internal Mic", 0x6 },
13418 { "Line", 0x2 },
13419 },
13420};
13421
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013422#ifdef CONFIG_SND_DEBUG
13423static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013424 /* Volume widgets */
13425 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13426 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13427 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13428 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13429 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13430 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13431 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13432 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13433 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13434 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13435 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13436 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13437 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013438 /* The below appears problematic on some hardwares */
13439 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013440 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13441 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13442 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13443 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13444
13445 /* Modes for retasking pin widgets */
13446 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13447 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13448 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13449 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13450
13451 /* Controls for GPIO pins, assuming they are configured as outputs */
13452 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13453 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13454 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13455 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13456
13457 /* Switches to allow the digital SPDIF output pin to be enabled.
13458 * The ALC268 does not have an SPDIF input.
13459 */
13460 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13461
13462 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13463 * this output to turn on an external amplifier.
13464 */
13465 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13466 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13467
13468 { } /* end */
13469};
13470#endif
13471
Kailang Yanga361d842007-06-05 12:30:55 +020013472/* create input playback/capture controls for the given pin */
13473static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13474 const char *ctlname, int idx)
13475{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013476 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013477 int err;
13478
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013479 switch (nid) {
13480 case 0x14:
13481 case 0x16:
13482 dac = 0x02;
13483 break;
13484 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013485 case 0x1a: /* ALC259/269 only */
13486 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013487 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013488 dac = 0x03;
13489 break;
13490 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013491 snd_printd(KERN_WARNING "hda_codec: "
13492 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013493 return 0;
13494 }
13495 if (spec->multiout.dac_nids[0] != dac &&
13496 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013497 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013498 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013499 HDA_OUTPUT));
13500 if (err < 0)
13501 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013502 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13503 }
13504
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013505 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013506 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013507 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013508 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013509 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013510 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013511 if (err < 0)
13512 return err;
13513 return 0;
13514}
13515
13516/* add playback controls from the parsed DAC table */
13517static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13518 const struct auto_pin_cfg *cfg)
13519{
13520 hda_nid_t nid;
13521 int err;
13522
Kailang Yanga361d842007-06-05 12:30:55 +020013523 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013524
13525 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013526 if (nid) {
13527 const char *name;
13528 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13529 name = "Speaker";
13530 else
13531 name = "Front";
13532 err = alc268_new_analog_output(spec, nid, name, 0);
13533 if (err < 0)
13534 return err;
13535 }
Kailang Yanga361d842007-06-05 12:30:55 +020013536
13537 nid = cfg->speaker_pins[0];
13538 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013539 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013540 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13541 if (err < 0)
13542 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013543 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013544 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13545 if (err < 0)
13546 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013547 }
13548 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013549 if (nid) {
13550 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13551 if (err < 0)
13552 return err;
13553 }
Kailang Yanga361d842007-06-05 12:30:55 +020013554
13555 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13556 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013557 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013558 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013559 if (err < 0)
13560 return err;
13561 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013562 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013563}
13564
13565/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013566static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013567 const struct auto_pin_cfg *cfg)
13568{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013569 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013570}
13571
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013572static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13573 hda_nid_t nid, int pin_type)
13574{
13575 int idx;
13576
13577 alc_set_pin_output(codec, nid, pin_type);
13578 if (nid == 0x14 || nid == 0x16)
13579 idx = 0;
13580 else
13581 idx = 1;
13582 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13583}
13584
13585static void alc268_auto_init_multi_out(struct hda_codec *codec)
13586{
13587 struct alc_spec *spec = codec->spec;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013588 int i;
13589
13590 for (i = 0; i < spec->autocfg.line_outs; i++) {
13591 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013592 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13593 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13594 }
13595}
13596
13597static void alc268_auto_init_hp_out(struct hda_codec *codec)
13598{
13599 struct alc_spec *spec = codec->spec;
13600 hda_nid_t pin;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013601 int i;
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013602
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013603 for (i = 0; i < spec->autocfg.hp_outs; i++) {
13604 pin = spec->autocfg.hp_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013605 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013606 }
13607 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
13608 pin = spec->autocfg.speaker_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013609 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013610 }
13611 if (spec->autocfg.mono_out_pin)
13612 snd_hda_codec_write(codec, spec->autocfg.mono_out_pin, 0,
13613 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013614}
13615
Kailang Yanga361d842007-06-05 12:30:55 +020013616static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13617{
13618 struct alc_spec *spec = codec->spec;
13619 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13620 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13621 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13622 unsigned int dac_vol1, dac_vol2;
13623
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013624 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013625 snd_hda_codec_write(codec, speaker_nid, 0,
13626 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013627 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013628 snd_hda_codec_write(codec, 0x0f, 0,
13629 AC_VERB_SET_AMP_GAIN_MUTE,
13630 AMP_IN_UNMUTE(1));
13631 snd_hda_codec_write(codec, 0x10, 0,
13632 AC_VERB_SET_AMP_GAIN_MUTE,
13633 AMP_IN_UNMUTE(1));
13634 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013635 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013636 snd_hda_codec_write(codec, 0x0f, 0,
13637 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13638 snd_hda_codec_write(codec, 0x10, 0,
13639 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13640 }
13641
13642 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013643 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013644 dac_vol2 = AMP_OUT_ZERO;
13645 else if (line_nid == 0x15)
13646 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013647 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013648 dac_vol2 = AMP_OUT_ZERO;
13649 else if (hp_nid == 0x15)
13650 dac_vol1 = AMP_OUT_ZERO;
13651 if (line_nid != 0x16 || hp_nid != 0x16 ||
13652 spec->autocfg.line_out_pins[1] != 0x16 ||
13653 spec->autocfg.line_out_pins[2] != 0x16)
13654 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13655
13656 snd_hda_codec_write(codec, 0x02, 0,
13657 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13658 snd_hda_codec_write(codec, 0x03, 0,
13659 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13660}
13661
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013662/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013663#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13664#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013665#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013666#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13667
13668/*
13669 * BIOS auto configuration
13670 */
13671static int alc268_parse_auto_config(struct hda_codec *codec)
13672{
13673 struct alc_spec *spec = codec->spec;
13674 int err;
13675 static hda_nid_t alc268_ignore[] = { 0 };
13676
13677 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13678 alc268_ignore);
13679 if (err < 0)
13680 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013681 if (!spec->autocfg.line_outs) {
13682 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13683 spec->multiout.max_channels = 2;
13684 spec->no_analog = 1;
13685 goto dig_only;
13686 }
Kailang Yanga361d842007-06-05 12:30:55 +020013687 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013688 }
Kailang Yanga361d842007-06-05 12:30:55 +020013689 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13690 if (err < 0)
13691 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013692 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013693 if (err < 0)
13694 return err;
13695
13696 spec->multiout.max_channels = 2;
13697
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013698 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013699 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013700 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013701 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013702 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013703
Takashi Iwai892981f2009-03-02 08:04:35 +010013704 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013705 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013706
Takashi Iwaid88897e2008-10-31 15:01:37 +010013707 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013708 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013709 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013710
Takashi Iwai776e1842007-08-29 15:07:11 +020013711 err = alc_auto_add_mic_boost(codec);
13712 if (err < 0)
13713 return err;
13714
Kailang Yang6227cdc2010-02-25 08:36:52 +010013715 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013716
Kailang Yanga361d842007-06-05 12:30:55 +020013717 return 1;
13718}
13719
Kailang Yanga361d842007-06-05 12:30:55 +020013720#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13721
13722/* init callback for auto-configuration model -- overriding the default init */
13723static void alc268_auto_init(struct hda_codec *codec)
13724{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013725 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013726 alc268_auto_init_multi_out(codec);
13727 alc268_auto_init_hp_out(codec);
13728 alc268_auto_init_mono_speaker_out(codec);
13729 alc268_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013730 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013731 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013732 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013733}
13734
13735/*
13736 * configuration and preset
13737 */
13738static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013739 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013740 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013741 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013742 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013743 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013744 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013745 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013746 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013747#ifdef CONFIG_SND_DEBUG
13748 [ALC268_TEST] = "test",
13749#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013750 [ALC268_AUTO] = "auto",
13751};
13752
13753static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013754 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013755 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013756 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013757 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013758 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013759 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13760 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013761 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013762 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13763 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013764 /* almost compatible with toshiba but with optional digital outs;
13765 * auto-probing seems working fine
13766 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013767 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013768 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013769 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013770 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013771 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013772 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013773 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013774 {}
13775};
13776
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013777/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13778static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13779 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13780 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13781 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13782 ALC268_TOSHIBA),
13783 {}
13784};
13785
Kailang Yanga361d842007-06-05 12:30:55 +020013786static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013787 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013788 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13789 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013790 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13791 alc267_quanta_il1_verbs },
13792 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13793 .dac_nids = alc268_dac_nids,
13794 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13795 .adc_nids = alc268_adc_nids_alt,
13796 .hp_nid = 0x03,
13797 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13798 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013799 .unsol_event = alc_sku_unsol_event,
13800 .setup = alc267_quanta_il1_setup,
13801 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013802 },
Kailang Yanga361d842007-06-05 12:30:55 +020013803 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013804 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13805 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013806 .init_verbs = { alc268_base_init_verbs },
13807 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13808 .dac_nids = alc268_dac_nids,
13809 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13810 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013811 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013812 .hp_nid = 0x03,
13813 .dig_out_nid = ALC268_DIGOUT_NID,
13814 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13815 .channel_mode = alc268_modes,
13816 .input_mux = &alc268_capture_source,
13817 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013818 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013819 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013820 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013821 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13822 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013823 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13824 .dac_nids = alc268_dac_nids,
13825 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13826 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013827 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013828 .hp_nid = 0x03,
13829 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13830 .channel_mode = alc268_modes,
13831 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013832 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013833 .setup = alc268_toshiba_setup,
13834 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013835 },
13836 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013837 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013838 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013839 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13840 alc268_acer_verbs },
13841 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13842 .dac_nids = alc268_dac_nids,
13843 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13844 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013845 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013846 .hp_nid = 0x02,
13847 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13848 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013849 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013850 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013851 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013852 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013853 [ALC268_ACER_DMIC] = {
13854 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13855 alc268_beep_mixer },
13856 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13857 alc268_acer_verbs },
13858 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13859 .dac_nids = alc268_dac_nids,
13860 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13861 .adc_nids = alc268_adc_nids_alt,
13862 .capsrc_nids = alc268_capsrc_nids,
13863 .hp_nid = 0x02,
13864 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13865 .channel_mode = alc268_modes,
13866 .input_mux = &alc268_acer_dmic_capture_source,
13867 .unsol_event = alc268_acer_unsol_event,
13868 .init_hook = alc268_acer_init_hook,
13869 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013870 [ALC268_ACER_ASPIRE_ONE] = {
13871 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013872 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013873 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013874 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13875 alc268_acer_aspire_one_verbs },
13876 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13877 .dac_nids = alc268_dac_nids,
13878 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13879 .adc_nids = alc268_adc_nids_alt,
13880 .capsrc_nids = alc268_capsrc_nids,
13881 .hp_nid = 0x03,
13882 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13883 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013884 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013885 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013886 .init_hook = alc268_acer_lc_init_hook,
13887 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013888 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013889 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13890 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013891 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13892 alc268_dell_verbs },
13893 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13894 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013895 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13896 .adc_nids = alc268_adc_nids_alt,
13897 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013898 .hp_nid = 0x02,
13899 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13900 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013901 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013902 .setup = alc268_dell_setup,
13903 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013904 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013905 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013906 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13907 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013908 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13909 alc268_toshiba_verbs },
13910 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13911 .dac_nids = alc268_dac_nids,
13912 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13913 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013914 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013915 .hp_nid = 0x03,
13916 .dig_out_nid = ALC268_DIGOUT_NID,
13917 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13918 .channel_mode = alc268_modes,
13919 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013920 .setup = alc268_toshiba_setup,
13921 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013922 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013923#ifdef CONFIG_SND_DEBUG
13924 [ALC268_TEST] = {
13925 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13926 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13927 alc268_volume_init_verbs },
13928 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13929 .dac_nids = alc268_dac_nids,
13930 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13931 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013932 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013933 .hp_nid = 0x03,
13934 .dig_out_nid = ALC268_DIGOUT_NID,
13935 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13936 .channel_mode = alc268_modes,
13937 .input_mux = &alc268_capture_source,
13938 },
13939#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013940};
13941
13942static int patch_alc268(struct hda_codec *codec)
13943{
13944 struct alc_spec *spec;
13945 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013946 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013947
Julia Lawallef86f582009-12-19 08:18:03 +010013948 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013949 if (spec == NULL)
13950 return -ENOMEM;
13951
13952 codec->spec = spec;
13953
13954 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13955 alc268_models,
13956 alc268_cfg_tbl);
13957
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013958 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13959 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013960 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013961
Kailang Yanga361d842007-06-05 12:30:55 +020013962 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013963 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13964 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013965 board_config = ALC268_AUTO;
13966 }
13967
13968 if (board_config == ALC268_AUTO) {
13969 /* automatic parse from the BIOS config */
13970 err = alc268_parse_auto_config(codec);
13971 if (err < 0) {
13972 alc_free(codec);
13973 return err;
13974 } else if (!err) {
13975 printk(KERN_INFO
13976 "hda_codec: Cannot set up configuration "
13977 "from BIOS. Using base mode...\n");
13978 board_config = ALC268_3ST;
13979 }
13980 }
13981
13982 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013983 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013984
Kailang Yanga361d842007-06-05 12:30:55 +020013985 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13986 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013987 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013988
Kailang Yanga361d842007-06-05 12:30:55 +020013989 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13990
Takashi Iwai22971e32009-02-10 11:56:44 +010013991 has_beep = 0;
13992 for (i = 0; i < spec->num_mixers; i++) {
13993 if (spec->mixers[i] == alc268_beep_mixer) {
13994 has_beep = 1;
13995 break;
13996 }
13997 }
13998
13999 if (has_beep) {
14000 err = snd_hda_attach_beep_device(codec, 0x1);
14001 if (err < 0) {
14002 alc_free(codec);
14003 return err;
14004 }
14005 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
14006 /* override the amp caps for beep generator */
14007 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014008 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
14009 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
14010 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
14011 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010014012 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014013
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014014 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014015 /* check whether NID 0x07 is valid */
14016 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010014017 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020014018
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014019 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014020 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020014021 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014022 if (spec->auto_mic ||
14023 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014024 spec->adc_nids = alc268_adc_nids_alt;
14025 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014026 if (spec->auto_mic)
14027 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014028 if (spec->auto_mic || spec->input_mux->num_items == 1)
14029 add_mixer(spec, alc268_capture_nosrc_mixer);
14030 else
14031 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014032 } else {
14033 spec->adc_nids = alc268_adc_nids;
14034 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010014035 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020014036 }
Takashi Iwai85860c02008-02-19 15:00:15 +010014037 /* set default input source */
14038 for (i = 0; i < spec->num_adc_nids; i++)
14039 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
14040 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030014041 i < spec->num_mux_defs ?
14042 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010014043 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020014044 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010014045
14046 spec->vmaster_nid = 0x02;
14047
Kailang Yanga361d842007-06-05 12:30:55 +020014048 codec->patch_ops = alc_patch_ops;
14049 if (board_config == ALC268_AUTO)
14050 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020014051
Kailang Yangbf1b0222010-10-21 08:49:56 +020014052 alc_init_jacks(codec);
14053
Kailang Yanga361d842007-06-05 12:30:55 +020014054 return 0;
14055}
14056
14057/*
Kailang Yangf6a92242007-12-13 16:52:54 +010014058 * ALC269 channel source setting (2 channel)
14059 */
14060#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
14061
14062#define alc269_dac_nids alc260_dac_nids
14063
14064static hda_nid_t alc269_adc_nids[1] = {
14065 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020014066 0x08,
14067};
14068
Takashi Iwaie01bf502008-08-21 16:25:07 +020014069static hda_nid_t alc269_capsrc_nids[1] = {
14070 0x23,
14071};
14072
Kailang Yang84898e82010-02-04 14:16:14 +010014073static hda_nid_t alc269vb_adc_nids[1] = {
14074 /* ADC1 */
14075 0x09,
14076};
14077
14078static hda_nid_t alc269vb_capsrc_nids[1] = {
14079 0x22,
14080};
14081
Takashi Iwai66946352010-03-29 17:21:45 +020014082static hda_nid_t alc269_adc_candidates[] = {
14083 0x08, 0x09, 0x07,
14084};
Takashi Iwaie01bf502008-08-21 16:25:07 +020014085
Kailang Yangf6a92242007-12-13 16:52:54 +010014086#define alc269_modes alc260_modes
14087#define alc269_capture_source alc880_lg_lw_capture_source
14088
14089static struct snd_kcontrol_new alc269_base_mixer[] = {
14090 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14091 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14092 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14093 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14094 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14095 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014096 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014097 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14098 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014099 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014100 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14101 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
14102 { } /* end */
14103};
14104
Kailang Yang60db6b52008-08-26 13:13:00 +020014105static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
14106 /* output mixer control */
14107 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14108 {
14109 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14110 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014111 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020014112 .info = snd_hda_mixer_amp_switch_info,
14113 .get = snd_hda_mixer_amp_switch_get,
14114 .put = alc268_acer_master_sw_put,
14115 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14116 },
14117 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14118 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014119 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014120 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14121 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014122 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014123 { }
14124};
14125
Tony Vroon64154832008-11-06 15:08:49 +000014126static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
14127 /* output mixer control */
14128 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14129 {
14130 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14131 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014132 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000014133 .info = snd_hda_mixer_amp_switch_info,
14134 .get = snd_hda_mixer_amp_switch_get,
14135 .put = alc268_acer_master_sw_put,
14136 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14137 },
14138 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14139 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014140 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014141 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14142 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014143 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014144 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
14145 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014146 HDA_CODEC_VOLUME("Dock Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014147 { }
14148};
14149
Kailang Yang84898e82010-02-04 14:16:14 +010014150static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020014151 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014152 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020014153 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014154 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020014155 { } /* end */
14156};
14157
Kailang Yang84898e82010-02-04 14:16:14 +010014158static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
14159 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14160 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14161 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14162 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14163 { } /* end */
14164};
14165
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014166static struct snd_kcontrol_new alc269_asus_mixer[] = {
14167 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14168 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
14169 { } /* end */
14170};
14171
Kailang Yangf6a92242007-12-13 16:52:54 +010014172/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010014173static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
14174 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14175 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014176 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14177 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014178 { } /* end */
14179};
14180
14181static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020014182 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14183 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014184 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010014185 { } /* end */
14186};
14187
Kailang Yang84898e82010-02-04 14:16:14 +010014188static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
14189 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14190 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014191 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14192 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014193 { } /* end */
14194};
14195
14196static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
14197 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14198 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014199 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014200 { } /* end */
14201};
14202
Takashi Iwai26f5df22008-11-03 17:39:46 +010014203/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010014204#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020014205
Kailang Yang60db6b52008-08-26 13:13:00 +020014206static struct hda_verb alc269_quanta_fl1_verbs[] = {
14207 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14208 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14209 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14210 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14211 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14212 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14213 { }
14214};
14215
Tony Vroon64154832008-11-06 15:08:49 +000014216static struct hda_verb alc269_lifebook_verbs[] = {
14217 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14218 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
14219 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14220 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14221 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14222 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14223 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14224 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14225 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14226 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14227 { }
14228};
14229
Kailang Yang60db6b52008-08-26 13:13:00 +020014230/* toggle speaker-output according to the hp-jack state */
14231static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
14232{
14233 unsigned int present;
14234 unsigned char bits;
14235
Wu Fengguang864f92b2009-11-18 12:38:02 +080014236 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014237 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014238 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014239 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014240 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014241 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014242
14243 snd_hda_codec_write(codec, 0x20, 0,
14244 AC_VERB_SET_COEF_INDEX, 0x0c);
14245 snd_hda_codec_write(codec, 0x20, 0,
14246 AC_VERB_SET_PROC_COEF, 0x680);
14247
14248 snd_hda_codec_write(codec, 0x20, 0,
14249 AC_VERB_SET_COEF_INDEX, 0x0c);
14250 snd_hda_codec_write(codec, 0x20, 0,
14251 AC_VERB_SET_PROC_COEF, 0x480);
14252}
14253
Tony Vroon64154832008-11-06 15:08:49 +000014254/* toggle speaker-output according to the hp-jacks state */
14255static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
14256{
14257 unsigned int present;
14258 unsigned char bits;
14259
14260 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014261 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000014262
14263 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014264 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000014265
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014266 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000014267 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014268 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014269 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014270 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014271
14272 snd_hda_codec_write(codec, 0x20, 0,
14273 AC_VERB_SET_COEF_INDEX, 0x0c);
14274 snd_hda_codec_write(codec, 0x20, 0,
14275 AC_VERB_SET_PROC_COEF, 0x680);
14276
14277 snd_hda_codec_write(codec, 0x20, 0,
14278 AC_VERB_SET_COEF_INDEX, 0x0c);
14279 snd_hda_codec_write(codec, 0x20, 0,
14280 AC_VERB_SET_PROC_COEF, 0x480);
14281}
14282
Tony Vroon64154832008-11-06 15:08:49 +000014283static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14284{
14285 unsigned int present_laptop;
14286 unsigned int present_dock;
14287
Wu Fengguang864f92b2009-11-18 12:38:02 +080014288 present_laptop = snd_hda_jack_detect(codec, 0x18);
14289 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014290
14291 /* Laptop mic port overrides dock mic port, design decision */
14292 if (present_dock)
14293 snd_hda_codec_write(codec, 0x23, 0,
14294 AC_VERB_SET_CONNECT_SEL, 0x3);
14295 if (present_laptop)
14296 snd_hda_codec_write(codec, 0x23, 0,
14297 AC_VERB_SET_CONNECT_SEL, 0x0);
14298 if (!present_dock && !present_laptop)
14299 snd_hda_codec_write(codec, 0x23, 0,
14300 AC_VERB_SET_CONNECT_SEL, 0x1);
14301}
14302
Kailang Yang60db6b52008-08-26 13:13:00 +020014303static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14304 unsigned int res)
14305{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014306 switch (res >> 26) {
14307 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014308 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014309 break;
14310 case ALC880_MIC_EVENT:
14311 alc_mic_automute(codec);
14312 break;
14313 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014314}
14315
Tony Vroon64154832008-11-06 15:08:49 +000014316static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14317 unsigned int res)
14318{
14319 if ((res >> 26) == ALC880_HP_EVENT)
14320 alc269_lifebook_speaker_automute(codec);
14321 if ((res >> 26) == ALC880_MIC_EVENT)
14322 alc269_lifebook_mic_autoswitch(codec);
14323}
14324
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014325static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14326{
14327 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014328 spec->autocfg.hp_pins[0] = 0x15;
14329 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014330 spec->ext_mic.pin = 0x18;
14331 spec->ext_mic.mux_idx = 0;
14332 spec->int_mic.pin = 0x19;
14333 spec->int_mic.mux_idx = 1;
14334 spec->auto_mic = 1;
14335}
14336
Kailang Yang60db6b52008-08-26 13:13:00 +020014337static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14338{
14339 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014340 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014341}
14342
Tony Vroon64154832008-11-06 15:08:49 +000014343static void alc269_lifebook_init_hook(struct hda_codec *codec)
14344{
14345 alc269_lifebook_speaker_automute(codec);
14346 alc269_lifebook_mic_autoswitch(codec);
14347}
14348
Kailang Yang84898e82010-02-04 14:16:14 +010014349static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014350 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14351 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14352 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14353 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14354 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14355 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14356 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14357 {}
14358};
14359
Kailang Yang84898e82010-02-04 14:16:14 +010014360static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014361 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14362 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14363 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14364 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14365 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14366 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14367 {}
14368};
14369
Kailang Yang84898e82010-02-04 14:16:14 +010014370static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14371 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14372 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14373 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14374 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14375 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14376 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14377 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14378 {}
14379};
14380
14381static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14382 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14383 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14384 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14385 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14386 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14387 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14388 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14389 {}
14390};
14391
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014392static struct hda_verb alc271_acer_dmic_verbs[] = {
14393 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14394 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14395 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14396 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14397 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14398 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14399 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14400 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14401 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14402 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14403 { }
14404};
14405
Kailang Yang60db6b52008-08-26 13:13:00 +020014406/* toggle speaker-output according to the hp-jack state */
14407static void alc269_speaker_automute(struct hda_codec *codec)
14408{
Kailang Yangebb83ee2009-12-17 12:23:00 +010014409 struct alc_spec *spec = codec->spec;
14410 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020014411 unsigned int present;
14412 unsigned char bits;
14413
Kailang Yangebb83ee2009-12-17 12:23:00 +010014414 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014415 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014416 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014417 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014418 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014419 HDA_AMP_MUTE, bits);
Kailang Yangbf1b0222010-10-21 08:49:56 +020014420 alc_report_jack(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020014421}
14422
Kailang Yang60db6b52008-08-26 13:13:00 +020014423/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010014424static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020014425 unsigned int res)
14426{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014427 switch (res >> 26) {
14428 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014429 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014430 break;
14431 case ALC880_MIC_EVENT:
14432 alc_mic_automute(codec);
14433 break;
14434 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014435}
14436
Kailang Yang226b1ec2010-04-09 11:01:20 +020014437static void alc269_laptop_amic_setup(struct hda_codec *codec)
14438{
14439 struct alc_spec *spec = codec->spec;
14440 spec->autocfg.hp_pins[0] = 0x15;
14441 spec->autocfg.speaker_pins[0] = 0x14;
14442 spec->ext_mic.pin = 0x18;
14443 spec->ext_mic.mux_idx = 0;
14444 spec->int_mic.pin = 0x19;
14445 spec->int_mic.mux_idx = 1;
14446 spec->auto_mic = 1;
14447}
14448
Kailang Yang84898e82010-02-04 14:16:14 +010014449static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014450{
14451 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014452 spec->autocfg.hp_pins[0] = 0x15;
14453 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014454 spec->ext_mic.pin = 0x18;
14455 spec->ext_mic.mux_idx = 0;
14456 spec->int_mic.pin = 0x12;
14457 spec->int_mic.mux_idx = 5;
14458 spec->auto_mic = 1;
14459}
14460
Kailang Yang226b1ec2010-04-09 11:01:20 +020014461static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014462{
14463 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014464 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014465 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014466 spec->ext_mic.pin = 0x18;
14467 spec->ext_mic.mux_idx = 0;
14468 spec->int_mic.pin = 0x19;
14469 spec->int_mic.mux_idx = 1;
14470 spec->auto_mic = 1;
14471}
14472
Kailang Yang226b1ec2010-04-09 11:01:20 +020014473static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14474{
14475 struct alc_spec *spec = codec->spec;
14476 spec->autocfg.hp_pins[0] = 0x21;
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 = 0x12;
14481 spec->int_mic.mux_idx = 6;
14482 spec->auto_mic = 1;
14483}
14484
Kailang Yang84898e82010-02-04 14:16:14 +010014485static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020014486{
14487 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014488 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014489}
14490
Kailang Yangf6a92242007-12-13 16:52:54 +010014491/*
14492 * generic initialization of ADC, input mixers and output mixers
14493 */
14494static struct hda_verb alc269_init_verbs[] = {
14495 /*
14496 * Unmute ADC0 and set the default input to mic-in
14497 */
Kailang Yang84898e82010-02-04 14:16:14 +010014498 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014499
14500 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014501 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014502 */
14503 /* set vol=0 to output mixers */
14504 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14505 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14506
14507 /* set up input amps for analog loopback */
14508 /* Amp Indices: DAC = 0, mixer = 1 */
14509 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14510 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14511 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14512 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14513 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14514 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14515
14516 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14517 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14518 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14519 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14520 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14521 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14522 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14523
14524 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14525 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014526
Kailang Yang84898e82010-02-04 14:16:14 +010014527 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014528 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14529 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014530 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014531
14532 /* set EAPD */
14533 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014534 { }
14535};
14536
14537static struct hda_verb alc269vb_init_verbs[] = {
14538 /*
14539 * Unmute ADC0 and set the default input to mic-in
14540 */
14541 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14542
14543 /*
14544 * Set up output mixers (0x02 - 0x03)
14545 */
14546 /* set vol=0 to output mixers */
14547 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14548 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14549
14550 /* set up input amps for analog loopback */
14551 /* Amp Indices: DAC = 0, mixer = 1 */
14552 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14553 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14554 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14555 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14556 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14557 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14558
14559 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14560 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14561 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14562 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14563 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14564 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14565 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14566
14567 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14568 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14569
14570 /* FIXME: use Mux-type input source selection */
14571 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14572 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14573 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14574
14575 /* set EAPD */
14576 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014577 { }
14578};
14579
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014580#define alc269_auto_create_multi_out_ctls \
14581 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014582#define alc269_auto_create_input_ctls \
14583 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014584
14585#ifdef CONFIG_SND_HDA_POWER_SAVE
14586#define alc269_loopbacks alc880_loopbacks
14587#endif
14588
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014589/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014590#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14591#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14592#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14593#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14594
Takashi Iwaif03d3112009-03-05 14:18:16 +010014595static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14596 .substreams = 1,
14597 .channels_min = 2,
14598 .channels_max = 8,
14599 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14600 /* NID is set in alc_build_pcms */
14601 .ops = {
14602 .open = alc880_playback_pcm_open,
14603 .prepare = alc880_playback_pcm_prepare,
14604 .cleanup = alc880_playback_pcm_cleanup
14605 },
14606};
14607
14608static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14609 .substreams = 1,
14610 .channels_min = 2,
14611 .channels_max = 2,
14612 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14613 /* NID is set in alc_build_pcms */
14614};
14615
Takashi Iwaiad358792010-03-30 18:00:59 +020014616#ifdef CONFIG_SND_HDA_POWER_SAVE
14617static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14618{
14619 switch (codec->subsystem_id) {
14620 case 0x103c1586:
14621 return 1;
14622 }
14623 return 0;
14624}
14625
14626static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14627{
14628 /* update mute-LED according to the speaker mute state */
14629 if (nid == 0x01 || nid == 0x14) {
14630 int pinval;
14631 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14632 HDA_AMP_MUTE)
14633 pinval = 0x24;
14634 else
14635 pinval = 0x20;
14636 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a542010-03-30 18:03:44 +020014637 snd_hda_codec_update_cache(codec, 0x19, 0,
14638 AC_VERB_SET_PIN_WIDGET_CONTROL,
14639 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014640 }
14641 return alc_check_power_status(codec, nid);
14642}
14643#endif /* CONFIG_SND_HDA_POWER_SAVE */
14644
Takashi Iwai840b64c2010-07-13 22:49:01 +020014645static int alc275_setup_dual_adc(struct hda_codec *codec)
14646{
14647 struct alc_spec *spec = codec->spec;
14648
14649 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14650 return 0;
14651 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14652 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14653 if (spec->ext_mic.pin <= 0x12) {
14654 spec->private_adc_nids[0] = 0x08;
14655 spec->private_adc_nids[1] = 0x11;
14656 spec->private_capsrc_nids[0] = 0x23;
14657 spec->private_capsrc_nids[1] = 0x22;
14658 } else {
14659 spec->private_adc_nids[0] = 0x11;
14660 spec->private_adc_nids[1] = 0x08;
14661 spec->private_capsrc_nids[0] = 0x22;
14662 spec->private_capsrc_nids[1] = 0x23;
14663 }
14664 spec->adc_nids = spec->private_adc_nids;
14665 spec->capsrc_nids = spec->private_capsrc_nids;
14666 spec->num_adc_nids = 2;
14667 spec->dual_adc_switch = 1;
14668 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14669 spec->adc_nids[0], spec->adc_nids[1]);
14670 return 1;
14671 }
14672 return 0;
14673}
14674
Takashi Iwaid433a672010-09-20 15:11:54 +020014675/* different alc269-variants */
14676enum {
14677 ALC269_TYPE_NORMAL,
Kailang Yang48c88e82010-11-23 08:56:16 +010014678 ALC269_TYPE_ALC258,
Takashi Iwaid433a672010-09-20 15:11:54 +020014679 ALC269_TYPE_ALC259,
Kailang Yang48c88e82010-11-23 08:56:16 +010014680 ALC269_TYPE_ALC269VB,
14681 ALC269_TYPE_ALC270,
Takashi Iwaid433a672010-09-20 15:11:54 +020014682 ALC269_TYPE_ALC271X,
14683};
14684
Kailang Yangf6a92242007-12-13 16:52:54 +010014685/*
14686 * BIOS auto configuration
14687 */
14688static int alc269_parse_auto_config(struct hda_codec *codec)
14689{
14690 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014691 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014692 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14693
14694 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14695 alc269_ignore);
14696 if (err < 0)
14697 return err;
14698
14699 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14700 if (err < 0)
14701 return err;
Takashi Iwaif3550d12010-09-20 15:09:03 +020014702 if (spec->codec_variant == ALC269_TYPE_NORMAL)
14703 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
14704 else
14705 err = alc_auto_create_input_ctls(codec, &spec->autocfg, 0,
14706 0x22, 0);
Kailang Yangf6a92242007-12-13 16:52:54 +010014707 if (err < 0)
14708 return err;
14709
14710 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14711
Takashi Iwai757899a2010-07-30 10:48:14 +020014712 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014713
Takashi Iwai603c4012008-07-30 15:01:44 +020014714 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014715 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014716
Takashi Iwaid433a672010-09-20 15:11:54 +020014717 if (spec->codec_variant != ALC269_TYPE_NORMAL) {
Kailang Yang84898e82010-02-04 14:16:14 +010014718 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014719 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014720 } else {
14721 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014722 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014723 }
14724
Kailang Yangf6a92242007-12-13 16:52:54 +010014725 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014726 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014727
14728 if (!alc275_setup_dual_adc(codec))
14729 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14730 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014731
Takashi Iwaie01bf502008-08-21 16:25:07 +020014732 /* set default input source */
Takashi Iwai840b64c2010-07-13 22:49:01 +020014733 if (!spec->dual_adc_switch)
Takashi Iwai748cce42010-08-04 07:37:39 +020014734 select_or_unmute_capsrc(codec, spec->capsrc_nids[0],
14735 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014736
14737 err = alc_auto_add_mic_boost(codec);
14738 if (err < 0)
14739 return err;
14740
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014741 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014742 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014743
Kailang Yangf6a92242007-12-13 16:52:54 +010014744 return 1;
14745}
14746
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014747#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14748#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014749#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14750
14751
14752/* init callback for auto-configuration model -- overriding the default init */
14753static void alc269_auto_init(struct hda_codec *codec)
14754{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014755 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014756 alc269_auto_init_multi_out(codec);
14757 alc269_auto_init_hp_out(codec);
14758 alc269_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014759 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014760 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014761 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014762}
14763
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014764#ifdef SND_HDA_NEEDS_RESUME
14765static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
14766{
14767 int val = alc_read_coef_idx(codec, 0x04);
14768 if (power_up)
14769 val |= 1 << 11;
14770 else
14771 val &= ~(1 << 11);
14772 alc_write_coef_idx(codec, 0x04, val);
14773}
14774
Kailang Yang977ddd62010-09-15 10:02:29 +020014775#ifdef CONFIG_SND_HDA_POWER_SAVE
14776static int alc269_suspend(struct hda_codec *codec, pm_message_t state)
14777{
14778 struct alc_spec *spec = codec->spec;
Kailang Yang977ddd62010-09-15 10:02:29 +020014779
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014780 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017)
14781 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014782 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014783 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014784 msleep(150);
14785 }
14786
14787 alc_shutup(codec);
14788 if (spec && spec->power_hook)
14789 spec->power_hook(codec);
14790 return 0;
14791}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014792#endif /* CONFIG_SND_HDA_POWER_SAVE */
14793
Kailang Yang977ddd62010-09-15 10:02:29 +020014794static int alc269_resume(struct hda_codec *codec)
14795{
Kailang Yang977ddd62010-09-15 10:02:29 +020014796 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014797 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014798 msleep(150);
14799 }
14800
14801 codec->patch_ops.init(codec);
14802
14803 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014804 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014805 msleep(200);
14806 }
14807
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014808 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018)
14809 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014810
14811 snd_hda_codec_resume_amp(codec);
14812 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +020014813 hda_call_check_power_status(codec, 0x01);
Kailang Yang977ddd62010-09-15 10:02:29 +020014814 return 0;
14815}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014816#endif /* SND_HDA_NEEDS_RESUME */
Kailang Yang977ddd62010-09-15 10:02:29 +020014817
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014818static void alc269_fixup_hweq(struct hda_codec *codec,
14819 const struct alc_fixup *fix, int pre_init)
14820{
14821 int coef;
14822
14823 coef = alc_read_coef_idx(codec, 0x1e);
14824 alc_write_coef_idx(codec, 0x1e, coef | 0x80);
14825}
14826
Takashi Iwaiff818c22010-04-12 08:59:25 +020014827enum {
14828 ALC269_FIXUP_SONY_VAIO,
Kailang Yang27855912010-12-21 09:09:53 +010014829 ALC275_FIX_SONY_VAIO_GPIO2,
David Henningsson145a9022010-09-16 10:07:53 +020014830 ALC269_FIXUP_DELL_M101Z,
David Henningsson022c92b2010-12-17 20:43:04 +010014831 ALC269_FIXUP_SKU_IGNORE,
David Henningssonac612402010-12-15 09:18:18 +010014832 ALC269_FIXUP_ASUS_G73JW,
Kailang Yang357f9152011-01-12 08:12:52 +010014833 ALC269_FIXUP_LENOVO_EAPD,
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014834 ALC275_FIXUP_SONY_HWEQ,
Takashi Iwaiff818c22010-04-12 08:59:25 +020014835};
14836
Takashi Iwaiff818c22010-04-12 08:59:25 +020014837static const struct alc_fixup alc269_fixups[] = {
14838 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020014839 .verbs = (const struct hda_verb[]) {
14840 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14841 {}
14842 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014843 },
Kailang Yang27855912010-12-21 09:09:53 +010014844 [ALC275_FIX_SONY_VAIO_GPIO2] = {
14845 .verbs = (const struct hda_verb[]) {
14846 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
14847 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
14848 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
14849 { }
14850 }
14851 },
David Henningsson145a9022010-09-16 10:07:53 +020014852 [ALC269_FIXUP_DELL_M101Z] = {
14853 .verbs = (const struct hda_verb[]) {
14854 /* Enables internal speaker */
14855 {0x20, AC_VERB_SET_COEF_INDEX, 13},
14856 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
14857 {}
14858 }
14859 },
David Henningsson022c92b2010-12-17 20:43:04 +010014860 [ALC269_FIXUP_SKU_IGNORE] = {
David Henningssonfe67b242010-12-15 08:01:46 +010014861 .sku = ALC_FIXUP_SKU_IGNORE,
14862 },
David Henningssonac612402010-12-15 09:18:18 +010014863 [ALC269_FIXUP_ASUS_G73JW] = {
14864 .pins = (const struct alc_pincfg[]) {
14865 { 0x17, 0x99130111 }, /* subwoofer */
14866 { }
14867 }
14868 },
Kailang Yang357f9152011-01-12 08:12:52 +010014869 [ALC269_FIXUP_LENOVO_EAPD] = {
14870 .verbs = (const struct hda_verb[]) {
14871 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
14872 {}
14873 }
14874 },
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014875 [ALC275_FIXUP_SONY_HWEQ] = {
14876 .func = alc269_fixup_hweq,
14877 .verbs = (const struct hda_verb[]) {
14878 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
14879 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
14880 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
14881 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14882 { }
14883 }
14884 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014885};
14886
14887static struct snd_pci_quirk alc269_fixup_tbl[] = {
Kailang Yang27855912010-12-21 09:09:53 +010014888 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIX_SONY_VAIO_GPIO2),
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014889 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
14890 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
Takashi Iwaiabdd8f52010-09-21 17:38:14 +020014891 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningsson145a9022010-09-16 10:07:53 +020014892 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
David Henningsson022c92b2010-12-17 20:43:04 +010014893 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
14894 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
David Henningssonac612402010-12-15 09:18:18 +010014895 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
Kailang Yang357f9152011-01-12 08:12:52 +010014896 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014897 {}
14898};
14899
14900
Kailang Yangf6a92242007-12-13 16:52:54 +010014901/*
14902 * configuration and preset
14903 */
14904static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014905 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014906 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014907 [ALC269_AMIC] = "laptop-amic",
14908 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014909 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014910 [ALC269_LIFEBOOK] = "lifebook",
14911 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014912};
14913
14914static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014915 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014916 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014917 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014918 ALC269_AMIC),
14919 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14920 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14921 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14922 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14923 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14924 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14925 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14926 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14927 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
14928 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14929 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14930 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14931 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14932 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14933 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14934 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14935 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14936 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14937 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14938 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14939 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14940 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14941 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14942 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14943 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14944 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14945 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14946 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14947 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14948 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14949 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14950 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14951 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14952 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14953 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14954 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014955 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014956 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014957 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014958 ALC269_DMIC),
14959 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14960 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014961 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014962 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014963 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14964 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14965 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14966 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14967 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14968 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014969 {}
14970};
14971
14972static struct alc_config_preset alc269_presets[] = {
14973 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014974 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014975 .init_verbs = { alc269_init_verbs },
14976 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14977 .dac_nids = alc269_dac_nids,
14978 .hp_nid = 0x03,
14979 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14980 .channel_mode = alc269_modes,
14981 .input_mux = &alc269_capture_source,
14982 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014983 [ALC269_QUANTA_FL1] = {
14984 .mixers = { alc269_quanta_fl1_mixer },
14985 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14986 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14987 .dac_nids = alc269_dac_nids,
14988 .hp_nid = 0x03,
14989 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14990 .channel_mode = alc269_modes,
14991 .input_mux = &alc269_capture_source,
14992 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014993 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014994 .init_hook = alc269_quanta_fl1_init_hook,
14995 },
Kailang Yang84898e82010-02-04 14:16:14 +010014996 [ALC269_AMIC] = {
14997 .mixers = { alc269_laptop_mixer },
14998 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014999 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015000 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015001 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15002 .dac_nids = alc269_dac_nids,
15003 .hp_nid = 0x03,
15004 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15005 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015006 .unsol_event = alc269_laptop_unsol_event,
15007 .setup = alc269_laptop_amic_setup,
15008 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015009 },
Kailang Yang84898e82010-02-04 14:16:14 +010015010 [ALC269_DMIC] = {
15011 .mixers = { alc269_laptop_mixer },
15012 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020015013 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015014 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015015 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15016 .dac_nids = alc269_dac_nids,
15017 .hp_nid = 0x03,
15018 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15019 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015020 .unsol_event = alc269_laptop_unsol_event,
15021 .setup = alc269_laptop_dmic_setup,
15022 .init_hook = alc269_laptop_inithook,
15023 },
15024 [ALC269VB_AMIC] = {
15025 .mixers = { alc269vb_laptop_mixer },
15026 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
15027 .init_verbs = { alc269vb_init_verbs,
15028 alc269vb_laptop_amic_init_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 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020015035 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010015036 .init_hook = alc269_laptop_inithook,
15037 },
15038 [ALC269VB_DMIC] = {
15039 .mixers = { alc269vb_laptop_mixer },
15040 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15041 .init_verbs = { alc269vb_init_verbs,
15042 alc269vb_laptop_dmic_init_verbs },
15043 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15044 .dac_nids = alc269_dac_nids,
15045 .hp_nid = 0x03,
15046 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15047 .channel_mode = alc269_modes,
15048 .unsol_event = alc269_laptop_unsol_event,
15049 .setup = alc269vb_laptop_dmic_setup,
15050 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015051 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015052 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015053 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010015054 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015055 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015056 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015057 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15058 .dac_nids = alc269_dac_nids,
15059 .hp_nid = 0x03,
15060 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15061 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015062 .unsol_event = alc269_laptop_unsol_event,
15063 .setup = alc269_laptop_dmic_setup,
15064 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015065 },
Tony Vroon64154832008-11-06 15:08:49 +000015066 [ALC269_LIFEBOOK] = {
15067 .mixers = { alc269_lifebook_mixer },
15068 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
15069 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15070 .dac_nids = alc269_dac_nids,
15071 .hp_nid = 0x03,
15072 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15073 .channel_mode = alc269_modes,
15074 .input_mux = &alc269_capture_source,
15075 .unsol_event = alc269_lifebook_unsol_event,
15076 .init_hook = alc269_lifebook_init_hook,
15077 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020015078 [ALC271_ACER] = {
15079 .mixers = { alc269_asus_mixer },
15080 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15081 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
15082 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15083 .dac_nids = alc269_dac_nids,
15084 .adc_nids = alc262_dmic_adc_nids,
15085 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
15086 .capsrc_nids = alc262_dmic_capsrc_nids,
15087 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15088 .channel_mode = alc269_modes,
15089 .input_mux = &alc269_capture_source,
15090 .dig_out_nid = ALC880_DIGOUT_NID,
15091 .unsol_event = alc_sku_unsol_event,
15092 .setup = alc269vb_laptop_dmic_setup,
15093 .init_hook = alc_inithook,
15094 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015095};
15096
Kailang Yang977ddd62010-09-15 10:02:29 +020015097static int alc269_fill_coef(struct hda_codec *codec)
15098{
15099 int val;
15100
15101 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
15102 alc_write_coef_idx(codec, 0xf, 0x960b);
15103 alc_write_coef_idx(codec, 0xe, 0x8817);
15104 }
15105
15106 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
15107 alc_write_coef_idx(codec, 0xf, 0x960b);
15108 alc_write_coef_idx(codec, 0xe, 0x8814);
15109 }
15110
15111 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
15112 val = alc_read_coef_idx(codec, 0x04);
15113 /* Power up output pin */
15114 alc_write_coef_idx(codec, 0x04, val | (1<<11));
15115 }
15116
15117 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
15118 val = alc_read_coef_idx(codec, 0xd);
15119 if ((val & 0x0c00) >> 10 != 0x1) {
15120 /* Capless ramp up clock control */
15121 alc_write_coef_idx(codec, 0xd, val | 1<<10);
15122 }
15123 val = alc_read_coef_idx(codec, 0x17);
15124 if ((val & 0x01c0) >> 6 != 0x4) {
15125 /* Class D power on reset */
15126 alc_write_coef_idx(codec, 0x17, val | 1<<7);
15127 }
15128 }
15129 return 0;
15130}
15131
Kailang Yangf6a92242007-12-13 16:52:54 +010015132static int patch_alc269(struct hda_codec *codec)
15133{
15134 struct alc_spec *spec;
Kailang Yang48c88e82010-11-23 08:56:16 +010015135 int board_config, coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010015136 int err;
15137
15138 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15139 if (spec == NULL)
15140 return -ENOMEM;
15141
15142 codec->spec = spec;
15143
Kailang Yangda00c242010-03-19 11:23:45 +010015144 alc_auto_parse_customize_define(codec);
15145
Kailang Yangc793bec2010-12-21 09:14:13 +010015146 if (codec->vendor_id == 0x10ec0269) {
15147 coef = alc_read_coef_idx(codec, 0);
15148 if ((coef & 0x00f0) == 0x0010) {
15149 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
15150 spec->cdefine.platform_type == 1) {
15151 alc_codec_rename(codec, "ALC271X");
15152 spec->codec_variant = ALC269_TYPE_ALC271X;
15153 } else if ((coef & 0xf000) == 0x1000) {
15154 spec->codec_variant = ALC269_TYPE_ALC270;
15155 } else if ((coef & 0xf000) == 0x2000) {
15156 alc_codec_rename(codec, "ALC259");
15157 spec->codec_variant = ALC269_TYPE_ALC259;
15158 } else if ((coef & 0xf000) == 0x3000) {
15159 alc_codec_rename(codec, "ALC258");
15160 spec->codec_variant = ALC269_TYPE_ALC258;
15161 } else {
15162 alc_codec_rename(codec, "ALC269VB");
15163 spec->codec_variant = ALC269_TYPE_ALC269VB;
15164 }
15165 } else
15166 alc_fix_pll_init(codec, 0x20, 0x04, 15);
15167 alc269_fill_coef(codec);
15168 }
Kailang Yang977ddd62010-09-15 10:02:29 +020015169
Kailang Yangf6a92242007-12-13 16:52:54 +010015170 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
15171 alc269_models,
15172 alc269_cfg_tbl);
15173
15174 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015175 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15176 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010015177 board_config = ALC269_AUTO;
15178 }
15179
Takashi Iwaiff818c22010-04-12 08:59:25 +020015180 if (board_config == ALC269_AUTO)
15181 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 1);
15182
Kailang Yangf6a92242007-12-13 16:52:54 +010015183 if (board_config == ALC269_AUTO) {
15184 /* automatic parse from the BIOS config */
15185 err = alc269_parse_auto_config(codec);
15186 if (err < 0) {
15187 alc_free(codec);
15188 return err;
15189 } else if (!err) {
15190 printk(KERN_INFO
15191 "hda_codec: Cannot set up configuration "
15192 "from BIOS. Using base mode...\n");
15193 board_config = ALC269_BASIC;
15194 }
15195 }
15196
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015197 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020015198 err = snd_hda_attach_beep_device(codec, 0x1);
15199 if (err < 0) {
15200 alc_free(codec);
15201 return err;
15202 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015203 }
15204
Kailang Yangf6a92242007-12-13 16:52:54 +010015205 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015206 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010015207
Kailang Yang84898e82010-02-04 14:16:14 +010015208 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010015209 /* Due to a hardware problem on Lenovo Ideadpad, we need to
15210 * fix the sample rate of analog I/O to 44.1kHz
15211 */
15212 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
15213 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020015214 } else if (spec->dual_adc_switch) {
15215 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15216 /* switch ADC dynamically */
15217 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010015218 } else {
15219 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15220 spec->stream_analog_capture = &alc269_pcm_analog_capture;
15221 }
Kailang Yangf6a92242007-12-13 16:52:54 +010015222 spec->stream_digital_playback = &alc269_pcm_digital_playback;
15223 spec->stream_digital_capture = &alc269_pcm_digital_capture;
15224
Takashi Iwai66946352010-03-29 17:21:45 +020015225 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
Kailang Yang1657cbd2010-11-23 08:53:32 +010015226 if (spec->codec_variant == ALC269_TYPE_NORMAL) {
Takashi Iwai66946352010-03-29 17:21:45 +020015227 spec->adc_nids = alc269_adc_nids;
15228 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
15229 spec->capsrc_nids = alc269_capsrc_nids;
15230 } else {
15231 spec->adc_nids = alc269vb_adc_nids;
15232 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
15233 spec->capsrc_nids = alc269vb_capsrc_nids;
15234 }
Kailang Yang84898e82010-02-04 14:16:14 +010015235 }
15236
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015237 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015238 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015239 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010015240 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010015241
Takashi Iwaiff818c22010-04-12 08:59:25 +020015242 if (board_config == ALC269_AUTO)
15243 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 0);
15244
Takashi Iwai100d5eb2009-08-10 11:55:51 +020015245 spec->vmaster_nid = 0x02;
15246
Kailang Yangf6a92242007-12-13 16:52:54 +010015247 codec->patch_ops = alc_patch_ops;
Kailang Yang977ddd62010-09-15 10:02:29 +020015248#ifdef CONFIG_SND_HDA_POWER_SAVE
15249 codec->patch_ops.suspend = alc269_suspend;
15250#endif
15251#ifdef SND_HDA_NEEDS_RESUME
15252 codec->patch_ops.resume = alc269_resume;
15253#endif
Kailang Yangf6a92242007-12-13 16:52:54 +010015254 if (board_config == ALC269_AUTO)
15255 spec->init_hook = alc269_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020015256
15257 alc_init_jacks(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010015258#ifdef CONFIG_SND_HDA_POWER_SAVE
15259 if (!spec->loopback.amplist)
15260 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020015261 if (alc269_mic2_for_mute_led(codec))
15262 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010015263#endif
15264
15265 return 0;
15266}
15267
15268/*
Kailang Yangdf694da2005-12-05 19:42:22 +010015269 * ALC861 channel source setting (2/6 channel selection for 3-stack)
15270 */
15271
15272/*
15273 * set the path ways for 2 channel output
15274 * need to set the codec line out and mic 1 pin widgets to inputs
15275 */
15276static struct hda_verb alc861_threestack_ch2_init[] = {
15277 /* set pin widget 1Ah (line in) for input */
15278 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015279 /* set pin widget 18h (mic1/2) for input, for mic also enable
15280 * the vref
15281 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015282 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15283
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015284 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15285#if 0
15286 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15287 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15288#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015289 { } /* end */
15290};
15291/*
15292 * 6ch mode
15293 * need to set the codec line out and mic 1 pin widgets to outputs
15294 */
15295static struct hda_verb alc861_threestack_ch6_init[] = {
15296 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15297 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15298 /* set pin widget 18h (mic1) for output (CLFE)*/
15299 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15300
15301 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015302 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015303
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015304 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15305#if 0
15306 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15307 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15308#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015309 { } /* end */
15310};
15311
15312static struct hda_channel_mode alc861_threestack_modes[2] = {
15313 { 2, alc861_threestack_ch2_init },
15314 { 6, alc861_threestack_ch6_init },
15315};
Takashi Iwai22309c32006-08-09 16:57:28 +020015316/* Set mic1 as input and unmute the mixer */
15317static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
15318 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15319 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15320 { } /* end */
15321};
15322/* Set mic1 as output and mute mixer */
15323static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
15324 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15325 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15326 { } /* end */
15327};
15328
15329static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
15330 { 2, alc861_uniwill_m31_ch2_init },
15331 { 4, alc861_uniwill_m31_ch4_init },
15332};
Kailang Yangdf694da2005-12-05 19:42:22 +010015333
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015334/* Set mic1 and line-in as input and unmute the mixer */
15335static struct hda_verb alc861_asus_ch2_init[] = {
15336 /* set pin widget 1Ah (line in) for input */
15337 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015338 /* set pin widget 18h (mic1/2) for input, for mic also enable
15339 * the vref
15340 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015341 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15342
15343 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15344#if 0
15345 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15346 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15347#endif
15348 { } /* end */
15349};
15350/* Set mic1 nad line-in as output and mute mixer */
15351static struct hda_verb alc861_asus_ch6_init[] = {
15352 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15353 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15354 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15355 /* set pin widget 18h (mic1) for output (CLFE)*/
15356 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15357 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15358 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
15359 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
15360
15361 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15362#if 0
15363 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15364 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15365#endif
15366 { } /* end */
15367};
15368
15369static struct hda_channel_mode alc861_asus_modes[2] = {
15370 { 2, alc861_asus_ch2_init },
15371 { 6, alc861_asus_ch6_init },
15372};
15373
Kailang Yangdf694da2005-12-05 19:42:22 +010015374/* patch-ALC861 */
15375
15376static struct snd_kcontrol_new alc861_base_mixer[] = {
15377 /* output mixer control */
15378 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15379 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15380 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15381 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15382 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15383
15384 /*Input mixer control */
15385 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15386 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15387 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15388 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15389 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15390 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15391 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15392 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15393 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15394 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015395
Kailang Yangdf694da2005-12-05 19:42:22 +010015396 { } /* end */
15397};
15398
15399static struct snd_kcontrol_new alc861_3ST_mixer[] = {
15400 /* output mixer control */
15401 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15402 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15403 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15404 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15405 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15406
15407 /* Input mixer control */
15408 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15409 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15410 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15411 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15412 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15413 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15414 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15415 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15416 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15417 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015418
Kailang Yangdf694da2005-12-05 19:42:22 +010015419 {
15420 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15421 .name = "Channel Mode",
15422 .info = alc_ch_mode_info,
15423 .get = alc_ch_mode_get,
15424 .put = alc_ch_mode_put,
15425 .private_value = ARRAY_SIZE(alc861_threestack_modes),
15426 },
15427 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015428};
15429
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015430static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015431 /* output mixer control */
15432 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15433 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15434 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015435
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015436 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015437};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015438
Takashi Iwai22309c32006-08-09 16:57:28 +020015439static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
15440 /* output mixer control */
15441 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15442 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15443 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15444 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15445 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15446
15447 /* Input mixer control */
15448 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15449 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15450 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15451 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15452 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15453 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15454 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15455 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15456 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15457 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015458
Takashi Iwai22309c32006-08-09 16:57:28 +020015459 {
15460 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15461 .name = "Channel Mode",
15462 .info = alc_ch_mode_info,
15463 .get = alc_ch_mode_get,
15464 .put = alc_ch_mode_put,
15465 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15466 },
15467 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015468};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015469
15470static struct snd_kcontrol_new alc861_asus_mixer[] = {
15471 /* output mixer control */
15472 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15473 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15474 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15475 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15476 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15477
15478 /* Input mixer control */
15479 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15480 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15481 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15482 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15483 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15484 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15485 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15486 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15487 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015488 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15489
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015490 {
15491 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15492 .name = "Channel Mode",
15493 .info = alc_ch_mode_info,
15494 .get = alc_ch_mode_get,
15495 .put = alc_ch_mode_put,
15496 .private_value = ARRAY_SIZE(alc861_asus_modes),
15497 },
15498 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015499};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015500
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015501/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015502static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015503 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15504 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015505 { }
15506};
15507
Kailang Yangdf694da2005-12-05 19:42:22 +010015508/*
15509 * generic initialization of ADC, input mixers and output mixers
15510 */
15511static struct hda_verb alc861_base_init_verbs[] = {
15512 /*
15513 * Unmute ADC0 and set the default input to mic-in
15514 */
15515 /* port-A for surround (rear panel) */
15516 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15517 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15518 /* port-B for mic-in (rear panel) with vref */
15519 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15520 /* port-C for line-in (rear panel) */
15521 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15522 /* port-D for Front */
15523 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15524 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15525 /* port-E for HP out (front panel) */
15526 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15527 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015528 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015529 /* port-F for mic-in (front panel) with vref */
15530 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15531 /* port-G for CLFE (rear panel) */
15532 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15533 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15534 /* port-H for side (rear panel) */
15535 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15536 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15537 /* CD-in */
15538 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15539 /* route front mic to ADC1*/
15540 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15541 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015542
Kailang Yangdf694da2005-12-05 19:42:22 +010015543 /* Unmute DAC0~3 & spdif out*/
15544 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15545 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15546 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15547 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15548 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015549
Kailang Yangdf694da2005-12-05 19:42:22 +010015550 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15551 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15552 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15553 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15554 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015555
Kailang Yangdf694da2005-12-05 19:42:22 +010015556 /* Unmute Stereo Mixer 15 */
15557 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15558 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15559 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015560 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015561
15562 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15563 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15564 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15565 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15566 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15567 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15568 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15569 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015570 /* hp used DAC 3 (Front) */
15571 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015572 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15573
15574 { }
15575};
15576
15577static struct hda_verb alc861_threestack_init_verbs[] = {
15578 /*
15579 * Unmute ADC0 and set the default input to mic-in
15580 */
15581 /* port-A for surround (rear panel) */
15582 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15583 /* port-B for mic-in (rear panel) with vref */
15584 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15585 /* port-C for line-in (rear panel) */
15586 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15587 /* port-D for Front */
15588 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15589 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15590 /* port-E for HP out (front panel) */
15591 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15592 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015593 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015594 /* port-F for mic-in (front panel) with vref */
15595 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15596 /* port-G for CLFE (rear panel) */
15597 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15598 /* port-H for side (rear panel) */
15599 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15600 /* CD-in */
15601 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15602 /* route front mic to ADC1*/
15603 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15604 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15605 /* Unmute DAC0~3 & spdif out*/
15606 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15607 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15608 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15609 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15610 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015611
Kailang Yangdf694da2005-12-05 19:42:22 +010015612 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15613 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15614 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15615 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15616 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015617
Kailang Yangdf694da2005-12-05 19:42:22 +010015618 /* Unmute Stereo Mixer 15 */
15619 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15620 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15621 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015622 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015623
15624 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15625 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15626 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15627 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15628 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15629 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15630 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15631 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015632 /* hp used DAC 3 (Front) */
15633 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015634 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15635 { }
15636};
Takashi Iwai22309c32006-08-09 16:57:28 +020015637
15638static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15639 /*
15640 * Unmute ADC0 and set the default input to mic-in
15641 */
15642 /* port-A for surround (rear panel) */
15643 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15644 /* port-B for mic-in (rear panel) with vref */
15645 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15646 /* port-C for line-in (rear panel) */
15647 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15648 /* port-D for Front */
15649 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15650 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15651 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015652 /* this has to be set to VREF80 */
15653 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015654 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015655 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015656 /* port-F for mic-in (front panel) with vref */
15657 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15658 /* port-G for CLFE (rear panel) */
15659 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15660 /* port-H for side (rear panel) */
15661 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15662 /* CD-in */
15663 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15664 /* route front mic to ADC1*/
15665 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15666 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15667 /* Unmute DAC0~3 & spdif out*/
15668 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15669 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15670 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15671 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15672 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015673
Takashi Iwai22309c32006-08-09 16:57:28 +020015674 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15675 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15676 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15677 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15678 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015679
Takashi Iwai22309c32006-08-09 16:57:28 +020015680 /* Unmute Stereo Mixer 15 */
15681 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15682 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15683 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015684 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015685
15686 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15687 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15688 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15689 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15690 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15691 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15692 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15693 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015694 /* hp used DAC 3 (Front) */
15695 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015696 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15697 { }
15698};
15699
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015700static struct hda_verb alc861_asus_init_verbs[] = {
15701 /*
15702 * Unmute ADC0 and set the default input to mic-in
15703 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015704 /* port-A for surround (rear panel)
15705 * according to codec#0 this is the HP jack
15706 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015707 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15708 /* route front PCM to HP */
15709 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15710 /* port-B for mic-in (rear panel) with vref */
15711 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15712 /* port-C for line-in (rear panel) */
15713 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15714 /* port-D for Front */
15715 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15716 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15717 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015718 /* this has to be set to VREF80 */
15719 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015720 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015721 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015722 /* port-F for mic-in (front panel) with vref */
15723 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15724 /* port-G for CLFE (rear panel) */
15725 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15726 /* port-H for side (rear panel) */
15727 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15728 /* CD-in */
15729 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15730 /* route front mic to ADC1*/
15731 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15732 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15733 /* Unmute DAC0~3 & spdif out*/
15734 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15735 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15736 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15737 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15738 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15739 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15740 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15741 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15742 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15743 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015744
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015745 /* Unmute Stereo Mixer 15 */
15746 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15747 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15748 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015749 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015750
15751 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15752 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15753 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15754 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15755 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15756 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15757 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15758 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015759 /* hp used DAC 3 (Front) */
15760 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015761 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15762 { }
15763};
15764
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015765/* additional init verbs for ASUS laptops */
15766static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15767 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15768 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15769 { }
15770};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015771
Kailang Yangdf694da2005-12-05 19:42:22 +010015772/*
15773 * generic initialization of ADC, input mixers and output mixers
15774 */
15775static struct hda_verb alc861_auto_init_verbs[] = {
15776 /*
15777 * Unmute ADC0 and set the default input to mic-in
15778 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015779 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015780 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015781
Kailang Yangdf694da2005-12-05 19:42:22 +010015782 /* Unmute DAC0~3 & spdif out*/
15783 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15784 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15785 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15786 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15787 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015788
Kailang Yangdf694da2005-12-05 19:42:22 +010015789 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15790 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15791 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15792 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15793 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015794
Kailang Yangdf694da2005-12-05 19:42:22 +010015795 /* Unmute Stereo Mixer 15 */
15796 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15797 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15798 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15799 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15800
Takashi Iwai1c209302009-07-22 15:17:45 +020015801 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15802 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15803 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15804 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15805 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15806 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15807 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15808 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015809
15810 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15811 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015812 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15813 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015814 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15815 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015816 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15817 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015818
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015819 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015820
15821 { }
15822};
15823
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015824static struct hda_verb alc861_toshiba_init_verbs[] = {
15825 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015826
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015827 { }
15828};
15829
15830/* toggle speaker-output according to the hp-jack state */
15831static void alc861_toshiba_automute(struct hda_codec *codec)
15832{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015833 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015834
Takashi Iwai47fd8302007-08-10 17:11:07 +020015835 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15836 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15837 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15838 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015839}
15840
15841static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15842 unsigned int res)
15843{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015844 if ((res >> 26) == ALC880_HP_EVENT)
15845 alc861_toshiba_automute(codec);
15846}
15847
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015848/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015849#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15850#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15851#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15852#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15853
15854
15855#define ALC861_DIGOUT_NID 0x07
15856
15857static struct hda_channel_mode alc861_8ch_modes[1] = {
15858 { 8, NULL }
15859};
15860
15861static hda_nid_t alc861_dac_nids[4] = {
15862 /* front, surround, clfe, side */
15863 0x03, 0x06, 0x05, 0x04
15864};
15865
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015866static hda_nid_t alc660_dac_nids[3] = {
15867 /* front, clfe, surround */
15868 0x03, 0x05, 0x06
15869};
15870
Kailang Yangdf694da2005-12-05 19:42:22 +010015871static hda_nid_t alc861_adc_nids[1] = {
15872 /* ADC0-2 */
15873 0x08,
15874};
15875
15876static struct hda_input_mux alc861_capture_source = {
15877 .num_items = 5,
15878 .items = {
15879 { "Mic", 0x0 },
15880 { "Front Mic", 0x3 },
15881 { "Line", 0x1 },
15882 { "CD", 0x4 },
15883 { "Mixer", 0x5 },
15884 },
15885};
15886
Takashi Iwai1c209302009-07-22 15:17:45 +020015887static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15888{
15889 struct alc_spec *spec = codec->spec;
15890 hda_nid_t mix, srcs[5];
15891 int i, j, num;
15892
15893 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15894 return 0;
15895 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15896 if (num < 0)
15897 return 0;
15898 for (i = 0; i < num; i++) {
15899 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015900 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015901 if (type != AC_WID_AUD_OUT)
15902 continue;
15903 for (j = 0; j < spec->multiout.num_dacs; j++)
15904 if (spec->multiout.dac_nids[j] == srcs[i])
15905 break;
15906 if (j >= spec->multiout.num_dacs)
15907 return srcs[i];
15908 }
15909 return 0;
15910}
15911
Kailang Yangdf694da2005-12-05 19:42:22 +010015912/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015913static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015914 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015915{
Takashi Iwai1c209302009-07-22 15:17:45 +020015916 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015917 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015918 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015919
15920 spec->multiout.dac_nids = spec->private_dac_nids;
15921 for (i = 0; i < cfg->line_outs; i++) {
15922 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015923 dac = alc861_look_for_dac(codec, nid);
15924 if (!dac)
15925 continue;
15926 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015927 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015928 return 0;
15929}
15930
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015931static int __alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15932 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015933{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015934 return __add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015935 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15936}
15937
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015938#define alc861_create_out_sw(codec, pfx, nid, chs) \
15939 __alc861_create_out_sw(codec, pfx, nid, 0, chs)
15940
Takashi Iwai1c209302009-07-22 15:17:45 +020015941/* add playback controls from the parsed DAC table */
15942static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15943 const struct auto_pin_cfg *cfg)
15944{
15945 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015946 static const char *chname[4] = {
15947 "Front", "Surround", NULL /*CLFE*/, "Side"
15948 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015949 const char *pfx = alc_get_line_out_pfx(cfg, true);
Kailang Yangdf694da2005-12-05 19:42:22 +010015950 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015951 int i, err;
15952
Kailang Yangdf694da2005-12-05 19:42:22 +010015953 for (i = 0; i < cfg->line_outs; i++) {
15954 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015955 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015956 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015957 if (!pfx && i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015958 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015959 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015960 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015961 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015962 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015963 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015964 return err;
15965 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015966 const char *name = pfx;
15967 if (!name)
15968 name = chname[i];
15969 err = __alc861_create_out_sw(codec, name, nid, i, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015970 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015971 return err;
15972 }
15973 }
15974 return 0;
15975}
15976
Takashi Iwai1c209302009-07-22 15:17:45 +020015977static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015978{
Takashi Iwai1c209302009-07-22 15:17:45 +020015979 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015980 int err;
15981 hda_nid_t nid;
15982
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015983 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015984 return 0;
15985
15986 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020015987 nid = alc861_look_for_dac(codec, pin);
15988 if (nid) {
15989 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
15990 if (err < 0)
15991 return err;
15992 spec->multiout.hp_nid = nid;
15993 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015994 }
15995 return 0;
15996}
15997
15998/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015999static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016000 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010016001{
Takashi Iwai05f5f472009-08-25 13:10:18 +020016002 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010016003}
16004
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016005static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
16006 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020016007 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010016008{
Takashi Iwai1c209302009-07-22 15:17:45 +020016009 hda_nid_t mix, srcs[5];
16010 int i, num;
16011
Jacek Luczak564c5be2008-05-03 18:41:23 +020016012 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
16013 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020016014 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020016015 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020016016 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
16017 return;
16018 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
16019 if (num < 0)
16020 return;
16021 for (i = 0; i < num; i++) {
16022 unsigned int mute;
16023 if (srcs[i] == dac || srcs[i] == 0x15)
16024 mute = AMP_IN_UNMUTE(i);
16025 else
16026 mute = AMP_IN_MUTE(i);
16027 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16028 mute);
16029 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016030}
16031
16032static void alc861_auto_init_multi_out(struct hda_codec *codec)
16033{
16034 struct alc_spec *spec = codec->spec;
16035 int i;
16036
16037 for (i = 0; i < spec->autocfg.line_outs; i++) {
16038 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016039 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016040 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016041 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016042 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016043 }
16044}
16045
16046static void alc861_auto_init_hp_out(struct hda_codec *codec)
16047{
16048 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016049
Takashi Iwai15870f02009-10-05 08:25:13 +020016050 if (spec->autocfg.hp_outs)
16051 alc861_auto_set_output_and_unmute(codec,
16052 spec->autocfg.hp_pins[0],
16053 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020016054 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020016055 if (spec->autocfg.speaker_outs)
16056 alc861_auto_set_output_and_unmute(codec,
16057 spec->autocfg.speaker_pins[0],
16058 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020016059 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016060}
16061
16062static void alc861_auto_init_analog_input(struct hda_codec *codec)
16063{
16064 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016065 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010016066 int i;
16067
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016068 for (i = 0; i < cfg->num_inputs; i++) {
16069 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010016070 if (nid >= 0x0c && nid <= 0x11)
Takashi Iwai30ea0982010-09-16 18:47:56 +020016071 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016072 }
16073}
16074
16075/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016076/* return 1 if successful, 0 if the proper config is not found,
16077 * or a negative error code
16078 */
Kailang Yangdf694da2005-12-05 19:42:22 +010016079static int alc861_parse_auto_config(struct hda_codec *codec)
16080{
16081 struct alc_spec *spec = codec->spec;
16082 int err;
16083 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
16084
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016085 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16086 alc861_ignore);
16087 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016088 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016089 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010016090 return 0; /* can't find valid BIOS pin config */
16091
Takashi Iwai1c209302009-07-22 15:17:45 +020016092 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016093 if (err < 0)
16094 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016095 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016096 if (err < 0)
16097 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016098 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016099 if (err < 0)
16100 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016101 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016102 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016103 return err;
16104
16105 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16106
Takashi Iwai757899a2010-07-30 10:48:14 +020016107 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016108
Takashi Iwai603c4012008-07-30 15:01:44 +020016109 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016110 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010016111
Takashi Iwaid88897e2008-10-31 15:01:37 +010016112 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010016113
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020016114 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016115 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010016116
16117 spec->adc_nids = alc861_adc_nids;
16118 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016119 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016120
Kailang Yang6227cdc2010-02-25 08:36:52 +010016121 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016122
Kailang Yangdf694da2005-12-05 19:42:22 +010016123 return 1;
16124}
16125
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016126/* additional initialization for auto-configuration model */
16127static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010016128{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016129 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016130 alc861_auto_init_multi_out(codec);
16131 alc861_auto_init_hp_out(codec);
16132 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020016133 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016134 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016135 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016136}
16137
Takashi Iwaicb53c622007-08-10 17:21:45 +020016138#ifdef CONFIG_SND_HDA_POWER_SAVE
16139static struct hda_amp_list alc861_loopbacks[] = {
16140 { 0x15, HDA_INPUT, 0 },
16141 { 0x15, HDA_INPUT, 1 },
16142 { 0x15, HDA_INPUT, 2 },
16143 { 0x15, HDA_INPUT, 3 },
16144 { } /* end */
16145};
16146#endif
16147
Kailang Yangdf694da2005-12-05 19:42:22 +010016148
16149/*
16150 * configuration and preset
16151 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016152static const char *alc861_models[ALC861_MODEL_LAST] = {
16153 [ALC861_3ST] = "3stack",
16154 [ALC660_3ST] = "3stack-660",
16155 [ALC861_3ST_DIG] = "3stack-dig",
16156 [ALC861_6ST_DIG] = "6stack-dig",
16157 [ALC861_UNIWILL_M31] = "uniwill-m31",
16158 [ALC861_TOSHIBA] = "toshiba",
16159 [ALC861_ASUS] = "asus",
16160 [ALC861_ASUS_LAPTOP] = "asus-laptop",
16161 [ALC861_AUTO] = "auto",
16162};
16163
16164static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010016165 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016166 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16167 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16168 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016169 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020016170 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010016171 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020016172 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
16173 * Any other models that need this preset?
16174 */
16175 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020016176 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
16177 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016178 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
16179 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
16180 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
16181 /* FIXME: the below seems conflict */
16182 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
16183 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
16184 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010016185 {}
16186};
16187
16188static struct alc_config_preset alc861_presets[] = {
16189 [ALC861_3ST] = {
16190 .mixers = { alc861_3ST_mixer },
16191 .init_verbs = { alc861_threestack_init_verbs },
16192 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16193 .dac_nids = alc861_dac_nids,
16194 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16195 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016196 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016197 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16198 .adc_nids = alc861_adc_nids,
16199 .input_mux = &alc861_capture_source,
16200 },
16201 [ALC861_3ST_DIG] = {
16202 .mixers = { alc861_base_mixer },
16203 .init_verbs = { alc861_threestack_init_verbs },
16204 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16205 .dac_nids = alc861_dac_nids,
16206 .dig_out_nid = ALC861_DIGOUT_NID,
16207 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16208 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016209 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016210 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16211 .adc_nids = alc861_adc_nids,
16212 .input_mux = &alc861_capture_source,
16213 },
16214 [ALC861_6ST_DIG] = {
16215 .mixers = { alc861_base_mixer },
16216 .init_verbs = { alc861_base_init_verbs },
16217 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16218 .dac_nids = alc861_dac_nids,
16219 .dig_out_nid = ALC861_DIGOUT_NID,
16220 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
16221 .channel_mode = alc861_8ch_modes,
16222 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16223 .adc_nids = alc861_adc_nids,
16224 .input_mux = &alc861_capture_source,
16225 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016226 [ALC660_3ST] = {
16227 .mixers = { alc861_3ST_mixer },
16228 .init_verbs = { alc861_threestack_init_verbs },
16229 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
16230 .dac_nids = alc660_dac_nids,
16231 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16232 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016233 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016234 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16235 .adc_nids = alc861_adc_nids,
16236 .input_mux = &alc861_capture_source,
16237 },
Takashi Iwai22309c32006-08-09 16:57:28 +020016238 [ALC861_UNIWILL_M31] = {
16239 .mixers = { alc861_uniwill_m31_mixer },
16240 .init_verbs = { alc861_uniwill_m31_init_verbs },
16241 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16242 .dac_nids = alc861_dac_nids,
16243 .dig_out_nid = ALC861_DIGOUT_NID,
16244 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
16245 .channel_mode = alc861_uniwill_m31_modes,
16246 .need_dac_fix = 1,
16247 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16248 .adc_nids = alc861_adc_nids,
16249 .input_mux = &alc861_capture_source,
16250 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016251 [ALC861_TOSHIBA] = {
16252 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016253 .init_verbs = { alc861_base_init_verbs,
16254 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016255 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16256 .dac_nids = alc861_dac_nids,
16257 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16258 .channel_mode = alc883_3ST_2ch_modes,
16259 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16260 .adc_nids = alc861_adc_nids,
16261 .input_mux = &alc861_capture_source,
16262 .unsol_event = alc861_toshiba_unsol_event,
16263 .init_hook = alc861_toshiba_automute,
16264 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020016265 [ALC861_ASUS] = {
16266 .mixers = { alc861_asus_mixer },
16267 .init_verbs = { alc861_asus_init_verbs },
16268 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16269 .dac_nids = alc861_dac_nids,
16270 .dig_out_nid = ALC861_DIGOUT_NID,
16271 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
16272 .channel_mode = alc861_asus_modes,
16273 .need_dac_fix = 1,
16274 .hp_nid = 0x06,
16275 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16276 .adc_nids = alc861_adc_nids,
16277 .input_mux = &alc861_capture_source,
16278 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010016279 [ALC861_ASUS_LAPTOP] = {
16280 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
16281 .init_verbs = { alc861_asus_init_verbs,
16282 alc861_asus_laptop_init_verbs },
16283 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16284 .dac_nids = alc861_dac_nids,
16285 .dig_out_nid = ALC861_DIGOUT_NID,
16286 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16287 .channel_mode = alc883_3ST_2ch_modes,
16288 .need_dac_fix = 1,
16289 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16290 .adc_nids = alc861_adc_nids,
16291 .input_mux = &alc861_capture_source,
16292 },
16293};
Kailang Yangdf694da2005-12-05 19:42:22 +010016294
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016295/* Pin config fixes */
16296enum {
16297 PINFIX_FSC_AMILO_PI1505,
16298};
16299
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016300static const struct alc_fixup alc861_fixups[] = {
16301 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020016302 .pins = (const struct alc_pincfg[]) {
16303 { 0x0b, 0x0221101f }, /* HP */
16304 { 0x0f, 0x90170310 }, /* speaker */
16305 { }
16306 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016307 },
16308};
16309
16310static struct snd_pci_quirk alc861_fixup_tbl[] = {
16311 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
16312 {}
16313};
Kailang Yangdf694da2005-12-05 19:42:22 +010016314
16315static int patch_alc861(struct hda_codec *codec)
16316{
16317 struct alc_spec *spec;
16318 int board_config;
16319 int err;
16320
Robert P. J. Daydc041e02006-12-19 14:44:15 +010016321 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010016322 if (spec == NULL)
16323 return -ENOMEM;
16324
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016325 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016326
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016327 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
16328 alc861_models,
16329 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016330
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016331 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016332 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16333 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010016334 board_config = ALC861_AUTO;
16335 }
16336
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016337 if (board_config == ALC861_AUTO)
16338 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 1);
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016339
Kailang Yangdf694da2005-12-05 19:42:22 +010016340 if (board_config == ALC861_AUTO) {
16341 /* automatic parse from the BIOS config */
16342 err = alc861_parse_auto_config(codec);
16343 if (err < 0) {
16344 alc_free(codec);
16345 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016346 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016347 printk(KERN_INFO
16348 "hda_codec: Cannot set up configuration "
16349 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010016350 board_config = ALC861_3ST_DIG;
16351 }
16352 }
16353
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016354 err = snd_hda_attach_beep_device(codec, 0x23);
16355 if (err < 0) {
16356 alc_free(codec);
16357 return err;
16358 }
16359
Kailang Yangdf694da2005-12-05 19:42:22 +010016360 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016361 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016362
Kailang Yangdf694da2005-12-05 19:42:22 +010016363 spec->stream_analog_playback = &alc861_pcm_analog_playback;
16364 spec->stream_analog_capture = &alc861_pcm_analog_capture;
16365
Kailang Yangdf694da2005-12-05 19:42:22 +010016366 spec->stream_digital_playback = &alc861_pcm_digital_playback;
16367 spec->stream_digital_capture = &alc861_pcm_digital_capture;
16368
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010016369 if (!spec->cap_mixer)
16370 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016371 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
16372
Takashi Iwai2134ea42008-01-10 16:53:55 +010016373 spec->vmaster_nid = 0x03;
16374
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016375 if (board_config == ALC861_AUTO)
16376 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 0);
16377
Kailang Yangdf694da2005-12-05 19:42:22 +010016378 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050016379 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016380 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016381#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050016382 spec->power_hook = alc_power_eapd;
16383#endif
16384 }
16385#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020016386 if (!spec->loopback.amplist)
16387 spec->loopback.amplist = alc861_loopbacks;
16388#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020016389
Kailang Yangdf694da2005-12-05 19:42:22 +010016390 return 0;
16391}
16392
16393/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016394 * ALC861-VD support
16395 *
16396 * Based on ALC882
16397 *
16398 * In addition, an independent DAC
16399 */
16400#define ALC861VD_DIGOUT_NID 0x06
16401
16402static hda_nid_t alc861vd_dac_nids[4] = {
16403 /* front, surr, clfe, side surr */
16404 0x02, 0x03, 0x04, 0x05
16405};
16406
16407/* dac_nids for ALC660vd are in a different order - according to
16408 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016409 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016410 * of ALC660vd codecs, but for now there is only 3stack mixer
16411 * - and it is the same as in 861vd.
16412 * adc_nids in ALC660vd are (is) the same as in 861vd
16413 */
16414static hda_nid_t alc660vd_dac_nids[3] = {
16415 /* front, rear, clfe, rear_surr */
16416 0x02, 0x04, 0x03
16417};
16418
16419static hda_nid_t alc861vd_adc_nids[1] = {
16420 /* ADC0 */
16421 0x09,
16422};
16423
Takashi Iwaie1406342008-02-11 18:32:32 +010016424static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
16425
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016426/* input MUX */
16427/* FIXME: should be a matrix-type input source selection */
16428static struct hda_input_mux alc861vd_capture_source = {
16429 .num_items = 4,
16430 .items = {
16431 { "Mic", 0x0 },
16432 { "Front Mic", 0x1 },
16433 { "Line", 0x2 },
16434 { "CD", 0x4 },
16435 },
16436};
16437
Kailang Yang272a5272007-05-14 11:00:38 +020016438static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016439 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016440 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +010016441 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010016442 { "Internal Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016443 },
16444};
16445
Kailang Yangd1a991a2007-08-15 16:21:59 +020016446static struct hda_input_mux alc861vd_hp_capture_source = {
16447 .num_items = 2,
16448 .items = {
16449 { "Front Mic", 0x0 },
16450 { "ATAPI Mic", 0x1 },
16451 },
16452};
16453
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016454/*
16455 * 2ch mode
16456 */
16457static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16458 { 2, NULL }
16459};
16460
16461/*
16462 * 6ch mode
16463 */
16464static struct hda_verb alc861vd_6stack_ch6_init[] = {
16465 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16466 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16467 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16468 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16469 { } /* end */
16470};
16471
16472/*
16473 * 8ch mode
16474 */
16475static struct hda_verb alc861vd_6stack_ch8_init[] = {
16476 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16477 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16478 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16479 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16480 { } /* end */
16481};
16482
16483static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16484 { 6, alc861vd_6stack_ch6_init },
16485 { 8, alc861vd_6stack_ch8_init },
16486};
16487
16488static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16489 {
16490 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16491 .name = "Channel Mode",
16492 .info = alc_ch_mode_info,
16493 .get = alc_ch_mode_get,
16494 .put = alc_ch_mode_put,
16495 },
16496 { } /* end */
16497};
16498
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016499/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16500 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16501 */
16502static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16503 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16504 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16505
16506 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16507 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16508
16509 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16510 HDA_OUTPUT),
16511 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16512 HDA_OUTPUT),
16513 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16514 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16515
16516 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16517 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16518
16519 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16520
David Henningsson5f99f862011-01-04 15:24:24 +010016521 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016522 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16523 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16524
David Henningsson5f99f862011-01-04 15:24:24 +010016525 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016526 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16527 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16528
16529 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16530 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16531
16532 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16533 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16534
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016535 { } /* end */
16536};
16537
16538static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16539 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16540 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16541
16542 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16543
David Henningsson5f99f862011-01-04 15:24:24 +010016544 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016545 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16546 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16547
David Henningsson5f99f862011-01-04 15:24:24 +010016548 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016549 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16550 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16551
16552 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16553 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16554
16555 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16556 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16557
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016558 { } /* end */
16559};
16560
Kailang Yangbdd148a2007-05-08 15:19:08 +020016561static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16562 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16563 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16564 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16565
16566 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16567
David Henningsson5f99f862011-01-04 15:24:24 +010016568 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016569 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16570 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16571
David Henningsson5f99f862011-01-04 15:24:24 +010016572 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016573 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16574 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16575
16576 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16577 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16578
16579 { } /* end */
16580};
16581
Tobin Davisb419f342008-03-07 11:57:51 +010016582/* Pin assignment: Speaker=0x14, HP = 0x15,
David Henningsson8607f7c2010-12-20 14:43:54 +010016583 * Mic=0x18, Internal Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016584 */
16585static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016586 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16587 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016588 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16589 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016590 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +010016591 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16592 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016593 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010016594 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16595 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016596 { } /* end */
16597};
16598
Kailang Yangd1a991a2007-08-15 16:21:59 +020016599/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16600 * Front Mic=0x18, ATAPI Mic = 0x19,
16601 */
16602static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16603 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16604 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16605 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16606 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16607 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16608 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16609 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16610 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016611
Kailang Yangd1a991a2007-08-15 16:21:59 +020016612 { } /* end */
16613};
16614
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016615/*
16616 * generic initialization of ADC, input mixers and output mixers
16617 */
16618static struct hda_verb alc861vd_volume_init_verbs[] = {
16619 /*
16620 * Unmute ADC0 and set the default input to mic-in
16621 */
16622 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16623 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16624
16625 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16626 * the analog-loopback mixer widget
16627 */
16628 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016629 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16630 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16631 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16632 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16633 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016634
16635 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016636 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16637 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16638 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016639 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016640
16641 /*
16642 * Set up output mixers (0x02 - 0x05)
16643 */
16644 /* set vol=0 to output mixers */
16645 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16646 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16647 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16648 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16649
16650 /* set up input amps for analog loopback */
16651 /* Amp Indices: DAC = 0, mixer = 1 */
16652 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16653 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16654 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16655 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16656 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16657 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16658 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16659 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16660
16661 { }
16662};
16663
16664/*
16665 * 3-stack pin configuration:
16666 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16667 */
16668static struct hda_verb alc861vd_3stack_init_verbs[] = {
16669 /*
16670 * Set pin mode and muting
16671 */
16672 /* set front pin widgets 0x14 for output */
16673 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16674 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16675 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16676
16677 /* Mic (rear) pin: input vref at 80% */
16678 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16679 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16680 /* Front Mic pin: input vref at 80% */
16681 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16682 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16683 /* Line In pin: input */
16684 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16685 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16686 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16687 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16688 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16689 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16690 /* CD pin widget for input */
16691 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16692
16693 { }
16694};
16695
16696/*
16697 * 6-stack pin configuration:
16698 */
16699static struct hda_verb alc861vd_6stack_init_verbs[] = {
16700 /*
16701 * Set pin mode and muting
16702 */
16703 /* set front pin widgets 0x14 for output */
16704 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16705 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16706 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16707
16708 /* Rear Pin: output 1 (0x0d) */
16709 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16710 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16711 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16712 /* CLFE Pin: output 2 (0x0e) */
16713 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16714 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16715 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16716 /* Side Pin: output 3 (0x0f) */
16717 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16718 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16719 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16720
16721 /* Mic (rear) pin: input vref at 80% */
16722 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16723 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16724 /* Front Mic pin: input vref at 80% */
16725 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16726 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16727 /* Line In pin: input */
16728 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16729 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16730 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16731 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16732 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16733 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16734 /* CD pin widget for input */
16735 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16736
16737 { }
16738};
16739
Kailang Yangbdd148a2007-05-08 15:19:08 +020016740static struct hda_verb alc861vd_eapd_verbs[] = {
16741 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16742 { }
16743};
16744
Kailang Yangf9423e72008-05-27 12:32:25 +020016745static struct hda_verb alc660vd_eapd_verbs[] = {
16746 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16747 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16748 { }
16749};
16750
Kailang Yangbdd148a2007-05-08 15:19:08 +020016751static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16752 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16753 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16754 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16755 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016756 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016757 {}
16758};
16759
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016760static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016761{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016762 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016763 spec->autocfg.hp_pins[0] = 0x1b;
16764 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016765}
16766
16767static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16768{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016769 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +010016770 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016771}
16772
16773static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16774 unsigned int res)
16775{
16776 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016777 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +010016778 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016779 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016780 default:
16781 alc_automute_amp_unsol_event(codec, res);
16782 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016783 }
16784}
16785
Kailang Yang272a5272007-05-14 11:00:38 +020016786static struct hda_verb alc861vd_dallas_verbs[] = {
16787 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16788 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16789 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16790 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16791
16792 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16793 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16794 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16795 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16796 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16797 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16798 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16799 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016800
Kailang Yang272a5272007-05-14 11:00:38 +020016801 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16802 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16803 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16804 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16805 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16806 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16807 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16808 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16809
16810 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16811 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16812 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16813 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16814 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16815 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16816 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16817 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16818
16819 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16820 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16821 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16822 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16823
16824 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016825 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016826 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16827
16828 { } /* end */
16829};
16830
16831/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016832static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016833{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016834 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016835
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016836 spec->autocfg.hp_pins[0] = 0x15;
16837 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016838}
16839
Takashi Iwaicb53c622007-08-10 17:21:45 +020016840#ifdef CONFIG_SND_HDA_POWER_SAVE
16841#define alc861vd_loopbacks alc880_loopbacks
16842#endif
16843
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016844/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016845#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16846#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16847#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16848#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16849
16850/*
16851 * configuration and preset
16852 */
16853static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
16854 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016855 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016856 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016857 [ALC861VD_3ST] = "3stack",
16858 [ALC861VD_3ST_DIG] = "3stack-digout",
16859 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016860 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016861 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016862 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016863 [ALC861VD_AUTO] = "auto",
16864};
16865
16866static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016867 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16868 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016869 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016870 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016871 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016872 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016873 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016874 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016875 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016876 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016877 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016878 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016879 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016880 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016881 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016882 {}
16883};
16884
16885static struct alc_config_preset alc861vd_presets[] = {
16886 [ALC660VD_3ST] = {
16887 .mixers = { alc861vd_3st_mixer },
16888 .init_verbs = { alc861vd_volume_init_verbs,
16889 alc861vd_3stack_init_verbs },
16890 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16891 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016892 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16893 .channel_mode = alc861vd_3stack_2ch_modes,
16894 .input_mux = &alc861vd_capture_source,
16895 },
Mike Crash6963f842007-06-25 12:12:51 +020016896 [ALC660VD_3ST_DIG] = {
16897 .mixers = { alc861vd_3st_mixer },
16898 .init_verbs = { alc861vd_volume_init_verbs,
16899 alc861vd_3stack_init_verbs },
16900 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16901 .dac_nids = alc660vd_dac_nids,
16902 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016903 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16904 .channel_mode = alc861vd_3stack_2ch_modes,
16905 .input_mux = &alc861vd_capture_source,
16906 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016907 [ALC861VD_3ST] = {
16908 .mixers = { alc861vd_3st_mixer },
16909 .init_verbs = { alc861vd_volume_init_verbs,
16910 alc861vd_3stack_init_verbs },
16911 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16912 .dac_nids = alc861vd_dac_nids,
16913 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16914 .channel_mode = alc861vd_3stack_2ch_modes,
16915 .input_mux = &alc861vd_capture_source,
16916 },
16917 [ALC861VD_3ST_DIG] = {
16918 .mixers = { alc861vd_3st_mixer },
16919 .init_verbs = { alc861vd_volume_init_verbs,
16920 alc861vd_3stack_init_verbs },
16921 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16922 .dac_nids = alc861vd_dac_nids,
16923 .dig_out_nid = ALC861VD_DIGOUT_NID,
16924 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16925 .channel_mode = alc861vd_3stack_2ch_modes,
16926 .input_mux = &alc861vd_capture_source,
16927 },
16928 [ALC861VD_6ST_DIG] = {
16929 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16930 .init_verbs = { alc861vd_volume_init_verbs,
16931 alc861vd_6stack_init_verbs },
16932 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16933 .dac_nids = alc861vd_dac_nids,
16934 .dig_out_nid = ALC861VD_DIGOUT_NID,
16935 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16936 .channel_mode = alc861vd_6stack_modes,
16937 .input_mux = &alc861vd_capture_source,
16938 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016939 [ALC861VD_LENOVO] = {
16940 .mixers = { alc861vd_lenovo_mixer },
16941 .init_verbs = { alc861vd_volume_init_verbs,
16942 alc861vd_3stack_init_verbs,
16943 alc861vd_eapd_verbs,
16944 alc861vd_lenovo_unsol_verbs },
16945 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16946 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016947 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16948 .channel_mode = alc861vd_3stack_2ch_modes,
16949 .input_mux = &alc861vd_capture_source,
16950 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016951 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016952 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016953 },
Kailang Yang272a5272007-05-14 11:00:38 +020016954 [ALC861VD_DALLAS] = {
16955 .mixers = { alc861vd_dallas_mixer },
16956 .init_verbs = { alc861vd_dallas_verbs },
16957 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16958 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016959 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16960 .channel_mode = alc861vd_3stack_2ch_modes,
16961 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016962 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016963 .setup = alc861vd_dallas_setup,
16964 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016965 },
16966 [ALC861VD_HP] = {
16967 .mixers = { alc861vd_hp_mixer },
16968 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16969 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16970 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016971 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016972 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16973 .channel_mode = alc861vd_3stack_2ch_modes,
16974 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016975 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016976 .setup = alc861vd_dallas_setup,
16977 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020016978 },
Takashi Iwai13c94742008-11-05 08:06:08 +010016979 [ALC660VD_ASUS_V1S] = {
16980 .mixers = { alc861vd_lenovo_mixer },
16981 .init_verbs = { alc861vd_volume_init_verbs,
16982 alc861vd_3stack_init_verbs,
16983 alc861vd_eapd_verbs,
16984 alc861vd_lenovo_unsol_verbs },
16985 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16986 .dac_nids = alc660vd_dac_nids,
16987 .dig_out_nid = ALC861VD_DIGOUT_NID,
16988 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16989 .channel_mode = alc861vd_3stack_2ch_modes,
16990 .input_mux = &alc861vd_capture_source,
16991 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016992 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016993 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010016994 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016995};
16996
16997/*
16998 * BIOS auto configuration
16999 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017000static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
17001 const struct auto_pin_cfg *cfg)
17002{
Herton Ronaldo Krzesinski71675942010-11-25 00:08:01 -020017003 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x22, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020017004}
17005
17006
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017007static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
17008 hda_nid_t nid, int pin_type, int dac_idx)
17009{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017010 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017011}
17012
17013static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
17014{
17015 struct alc_spec *spec = codec->spec;
17016 int i;
17017
17018 for (i = 0; i <= HDA_SIDE; i++) {
17019 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017020 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017021 if (nid)
17022 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017023 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017024 }
17025}
17026
17027
17028static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
17029{
17030 struct alc_spec *spec = codec->spec;
17031 hda_nid_t pin;
17032
17033 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017034 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017035 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017036 pin = spec->autocfg.speaker_pins[0];
17037 if (pin)
17038 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017039}
17040
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017041#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
17042
17043static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
17044{
17045 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017046 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017047 int i;
17048
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017049 for (i = 0; i < cfg->num_inputs; i++) {
17050 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017051 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020017052 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +010017053 if (nid != ALC861VD_PIN_CD_NID &&
17054 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017055 snd_hda_codec_write(codec, nid, 0,
17056 AC_VERB_SET_AMP_GAIN_MUTE,
17057 AMP_OUT_MUTE);
17058 }
17059 }
17060}
17061
Takashi Iwaif511b012008-08-15 16:46:42 +020017062#define alc861vd_auto_init_input_src alc882_auto_init_input_src
17063
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017064#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
17065#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
17066
17067/* add playback controls from the parsed DAC table */
17068/* Based on ALC880 version. But ALC861VD has separate,
17069 * different NIDs for mute/unmute switch and volume control */
17070static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
17071 const struct auto_pin_cfg *cfg)
17072{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017073 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017074 const char *pfx = alc_get_line_out_pfx(cfg, true);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017075 hda_nid_t nid_v, nid_s;
17076 int i, err;
17077
17078 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017079 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017080 continue;
17081 nid_v = alc861vd_idx_to_mixer_vol(
17082 alc880_dac_to_idx(
17083 spec->multiout.dac_nids[i]));
17084 nid_s = alc861vd_idx_to_mixer_switch(
17085 alc880_dac_to_idx(
17086 spec->multiout.dac_nids[i]));
17087
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017088 if (!pfx && i == 2) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017089 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017090 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17091 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017092 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
17093 HDA_OUTPUT));
17094 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017095 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017096 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17097 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017098 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
17099 HDA_OUTPUT));
17100 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017101 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017102 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17103 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017104 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
17105 HDA_INPUT));
17106 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017107 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017108 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17109 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017110 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
17111 HDA_INPUT));
17112 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017113 return err;
17114 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017115 const char *name = pfx;
17116 if (!name)
17117 name = chname[i];
17118 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17119 name, i,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017120 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
17121 HDA_OUTPUT));
17122 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017123 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017124 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17125 name, i,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017126 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017127 HDA_INPUT));
17128 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017129 return err;
17130 }
17131 }
17132 return 0;
17133}
17134
17135/* add playback controls for speaker and HP outputs */
17136/* Based on ALC880 version. But ALC861VD has separate,
17137 * different NIDs for mute/unmute switch and volume control */
17138static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
17139 hda_nid_t pin, const char *pfx)
17140{
17141 hda_nid_t nid_v, nid_s;
17142 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017143
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017144 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017145 return 0;
17146
17147 if (alc880_is_fixed_pin(pin)) {
17148 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17149 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017150 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017151 spec->multiout.hp_nid = nid_v;
17152 else
17153 spec->multiout.extra_out_nid[0] = nid_v;
17154 /* control HP volume/switch on the output mixer amp */
17155 nid_v = alc861vd_idx_to_mixer_vol(
17156 alc880_fixed_pin_idx(pin));
17157 nid_s = alc861vd_idx_to_mixer_switch(
17158 alc880_fixed_pin_idx(pin));
17159
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017160 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017161 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
17162 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017163 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017164 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017165 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
17166 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017167 return err;
17168 } else if (alc880_is_multi_pin(pin)) {
17169 /* set manual connection */
17170 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017171 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017172 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17173 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017174 return err;
17175 }
17176 return 0;
17177}
17178
17179/* parse the BIOS configuration and set up the alc_spec
17180 * return 1 if successful, 0 if the proper config is not found,
17181 * or a negative error code
17182 * Based on ALC880 version - had to change it to override
17183 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
17184static int alc861vd_parse_auto_config(struct hda_codec *codec)
17185{
17186 struct alc_spec *spec = codec->spec;
17187 int err;
17188 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
17189
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017190 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17191 alc861vd_ignore);
17192 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017193 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017194 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017195 return 0; /* can't find valid BIOS pin config */
17196
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017197 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17198 if (err < 0)
17199 return err;
17200 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
17201 if (err < 0)
17202 return err;
17203 err = alc861vd_auto_create_extra_out(spec,
17204 spec->autocfg.speaker_pins[0],
17205 "Speaker");
17206 if (err < 0)
17207 return err;
17208 err = alc861vd_auto_create_extra_out(spec,
17209 spec->autocfg.hp_pins[0],
17210 "Headphone");
17211 if (err < 0)
17212 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017213 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017214 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017215 return err;
17216
17217 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17218
Takashi Iwai757899a2010-07-30 10:48:14 +020017219 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017220
Takashi Iwai603c4012008-07-30 15:01:44 +020017221 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017222 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017223
Takashi Iwaid88897e2008-10-31 15:01:37 +010017224 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017225
17226 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017227 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017228
Takashi Iwai776e1842007-08-29 15:07:11 +020017229 err = alc_auto_add_mic_boost(codec);
17230 if (err < 0)
17231 return err;
17232
Kailang Yang6227cdc2010-02-25 08:36:52 +010017233 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017234
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017235 return 1;
17236}
17237
17238/* additional initialization for auto-configuration model */
17239static void alc861vd_auto_init(struct hda_codec *codec)
17240{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017241 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017242 alc861vd_auto_init_multi_out(codec);
17243 alc861vd_auto_init_hp_out(codec);
17244 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017245 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020017246 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017247 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017248 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017249}
17250
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017251enum {
17252 ALC660VD_FIX_ASUS_GPIO1
17253};
17254
17255/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017256static const struct alc_fixup alc861vd_fixups[] = {
17257 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020017258 .verbs = (const struct hda_verb[]) {
17259 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
17260 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
17261 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
17262 { }
17263 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017264 },
17265};
17266
17267static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
17268 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
17269 {}
17270};
17271
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017272static int patch_alc861vd(struct hda_codec *codec)
17273{
17274 struct alc_spec *spec;
17275 int err, board_config;
17276
17277 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17278 if (spec == NULL)
17279 return -ENOMEM;
17280
17281 codec->spec = spec;
17282
17283 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
17284 alc861vd_models,
17285 alc861vd_cfg_tbl);
17286
17287 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017288 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17289 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017290 board_config = ALC861VD_AUTO;
17291 }
17292
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017293 if (board_config == ALC861VD_AUTO)
17294 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 1);
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017295
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017296 if (board_config == ALC861VD_AUTO) {
17297 /* automatic parse from the BIOS config */
17298 err = alc861vd_parse_auto_config(codec);
17299 if (err < 0) {
17300 alc_free(codec);
17301 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017302 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017303 printk(KERN_INFO
17304 "hda_codec: Cannot set up configuration "
17305 "from BIOS. Using base mode...\n");
17306 board_config = ALC861VD_3ST;
17307 }
17308 }
17309
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017310 err = snd_hda_attach_beep_device(codec, 0x23);
17311 if (err < 0) {
17312 alc_free(codec);
17313 return err;
17314 }
17315
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017316 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017317 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017318
Kailang Yang2f893282008-05-27 12:14:47 +020017319 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020017320 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010017321 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020017322 }
17323
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017324 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
17325 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
17326
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017327 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
17328 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
17329
Takashi Iwaidd704692009-08-11 08:45:11 +020017330 if (!spec->adc_nids) {
17331 spec->adc_nids = alc861vd_adc_nids;
17332 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
17333 }
17334 if (!spec->capsrc_nids)
17335 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017336
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017337 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010017338 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017339
Takashi Iwai2134ea42008-01-10 16:53:55 +010017340 spec->vmaster_nid = 0x02;
17341
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017342 if (board_config == ALC861VD_AUTO)
17343 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 0);
17344
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017345 codec->patch_ops = alc_patch_ops;
17346
17347 if (board_config == ALC861VD_AUTO)
17348 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017349#ifdef CONFIG_SND_HDA_POWER_SAVE
17350 if (!spec->loopback.amplist)
17351 spec->loopback.amplist = alc861vd_loopbacks;
17352#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017353
17354 return 0;
17355}
17356
17357/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017358 * ALC662 support
17359 *
17360 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
17361 * configuration. Each pin widget can choose any input DACs and a mixer.
17362 * Each ADC is connected from a mixer of all inputs. This makes possible
17363 * 6-channel independent captures.
17364 *
17365 * In addition, an independent DAC for the multi-playback (not used in this
17366 * driver yet).
17367 */
17368#define ALC662_DIGOUT_NID 0x06
17369#define ALC662_DIGIN_NID 0x0a
17370
17371static hda_nid_t alc662_dac_nids[4] = {
17372 /* front, rear, clfe, rear_surr */
17373 0x02, 0x03, 0x04
17374};
17375
Kailang Yang622e84c2009-04-21 07:39:04 +020017376static hda_nid_t alc272_dac_nids[2] = {
17377 0x02, 0x03
17378};
17379
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017380static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017381 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017382 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017383};
Takashi Iwaie1406342008-02-11 18:32:32 +010017384
Kailang Yang622e84c2009-04-21 07:39:04 +020017385static hda_nid_t alc272_adc_nids[1] = {
17386 /* ADC1-2 */
17387 0x08,
17388};
17389
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017390static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020017391static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
17392
Takashi Iwaie1406342008-02-11 18:32:32 +010017393
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017394/* input MUX */
17395/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017396static struct hda_input_mux alc662_capture_source = {
17397 .num_items = 4,
17398 .items = {
17399 { "Mic", 0x0 },
17400 { "Front Mic", 0x1 },
17401 { "Line", 0x2 },
17402 { "CD", 0x4 },
17403 },
17404};
17405
17406static struct hda_input_mux alc662_lenovo_101e_capture_source = {
17407 .num_items = 2,
17408 .items = {
17409 { "Mic", 0x1 },
17410 { "Line", 0x2 },
17411 },
17412};
Kailang Yang291702f2007-10-16 14:28:03 +020017413
Kailang Yang6dda9f42008-05-27 12:05:31 +020017414static struct hda_input_mux alc663_capture_source = {
17415 .num_items = 3,
17416 .items = {
17417 { "Mic", 0x0 },
17418 { "Front Mic", 0x1 },
17419 { "Line", 0x2 },
17420 },
17421};
17422
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017423#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020017424static struct hda_input_mux alc272_nc10_capture_source = {
17425 .num_items = 16,
17426 .items = {
17427 { "Autoselect Mic", 0x0 },
17428 { "Internal Mic", 0x1 },
17429 { "In-0x02", 0x2 },
17430 { "In-0x03", 0x3 },
17431 { "In-0x04", 0x4 },
17432 { "In-0x05", 0x5 },
17433 { "In-0x06", 0x6 },
17434 { "In-0x07", 0x7 },
17435 { "In-0x08", 0x8 },
17436 { "In-0x09", 0x9 },
17437 { "In-0x0a", 0x0a },
17438 { "In-0x0b", 0x0b },
17439 { "In-0x0c", 0x0c },
17440 { "In-0x0d", 0x0d },
17441 { "In-0x0e", 0x0e },
17442 { "In-0x0f", 0x0f },
17443 },
17444};
17445#endif
17446
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017447/*
17448 * 2ch mode
17449 */
17450static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17451 { 2, NULL }
17452};
17453
17454/*
17455 * 2ch mode
17456 */
17457static struct hda_verb alc662_3ST_ch2_init[] = {
17458 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17459 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17460 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17461 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17462 { } /* end */
17463};
17464
17465/*
17466 * 6ch mode
17467 */
17468static struct hda_verb alc662_3ST_ch6_init[] = {
17469 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17470 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17471 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17472 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17473 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17474 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17475 { } /* end */
17476};
17477
17478static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17479 { 2, alc662_3ST_ch2_init },
17480 { 6, alc662_3ST_ch6_init },
17481};
17482
17483/*
17484 * 2ch mode
17485 */
17486static struct hda_verb alc662_sixstack_ch6_init[] = {
17487 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17488 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17489 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17490 { } /* end */
17491};
17492
17493/*
17494 * 6ch mode
17495 */
17496static struct hda_verb alc662_sixstack_ch8_init[] = {
17497 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17498 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17499 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17500 { } /* end */
17501};
17502
17503static struct hda_channel_mode alc662_5stack_modes[2] = {
17504 { 2, alc662_sixstack_ch6_init },
17505 { 6, alc662_sixstack_ch8_init },
17506};
17507
17508/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17509 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17510 */
17511
17512static struct snd_kcontrol_new alc662_base_mixer[] = {
17513 /* output mixer control */
17514 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017515 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017516 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017517 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017518 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17519 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017520 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17521 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017522 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17523
17524 /*Input mixer control */
17525 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17526 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17527 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17528 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17529 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17530 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17531 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17532 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017533 { } /* end */
17534};
17535
17536static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17537 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017538 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017539 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17540 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17541 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17542 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17543 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17544 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17545 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17546 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17547 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017548 { } /* end */
17549};
17550
17551static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17552 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017553 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017554 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017555 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017556 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17557 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017558 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17559 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017560 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17561 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17562 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17563 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17564 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17565 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17566 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17567 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17568 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017569 { } /* end */
17570};
17571
17572static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17573 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17574 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017575 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17576 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017577 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17578 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17579 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17580 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17581 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017582 { } /* end */
17583};
17584
Kailang Yang291702f2007-10-16 14:28:03 +020017585static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017586 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17587 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017588
David Henningsson5f99f862011-01-04 15:24:24 +010017589 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017590 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17591 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017592
David Henningsson5f99f862011-01-04 15:24:24 +010017593 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017594 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17595 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017596 { } /* end */
17597};
17598
Kailang Yang8c427222008-01-10 13:03:59 +010017599static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017600 ALC262_HIPPO_MASTER_SWITCH,
17601 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017602 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017603 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17604 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017605 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17606 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17607 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17608 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17609 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17610 { } /* end */
17611};
17612
Kailang Yangf1d4e282008-08-26 14:03:29 +020017613static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17614 .ops = &snd_hda_bind_vol,
17615 .values = {
17616 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17617 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17618 0
17619 },
17620};
17621
17622static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17623 .ops = &snd_hda_bind_sw,
17624 .values = {
17625 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17626 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17627 0
17628 },
17629};
17630
Kailang Yang6dda9f42008-05-27 12:05:31 +020017631static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017632 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17633 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17634 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17635 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17636 { } /* end */
17637};
17638
17639static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17640 .ops = &snd_hda_bind_sw,
17641 .values = {
17642 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17643 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17644 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17645 0
17646 },
17647};
17648
17649static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17650 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17651 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17652 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17653 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17654 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17655 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17656
17657 { } /* end */
17658};
17659
17660static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17661 .ops = &snd_hda_bind_sw,
17662 .values = {
17663 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17664 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17665 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17666 0
17667 },
17668};
17669
17670static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17671 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17672 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17673 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17674 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17675 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17676 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17677 { } /* end */
17678};
17679
17680static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017681 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17682 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017683 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17684 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17685 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17686 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17687 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17688 { } /* end */
17689};
17690
17691static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17692 .ops = &snd_hda_bind_vol,
17693 .values = {
17694 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17695 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17696 0
17697 },
17698};
17699
17700static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17701 .ops = &snd_hda_bind_sw,
17702 .values = {
17703 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17704 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17705 0
17706 },
17707};
17708
17709static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17710 HDA_BIND_VOL("Master Playback Volume",
17711 &alc663_asus_two_bind_master_vol),
17712 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17713 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017714 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17715 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17716 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017717 { } /* end */
17718};
17719
17720static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17721 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17722 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17723 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17724 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17725 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17726 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017727 { } /* end */
17728};
17729
17730static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17731 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17732 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17733 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17734 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17735 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17736
17737 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17738 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017739 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17740 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017741 { } /* end */
17742};
17743
17744static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17745 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17746 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17747 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17748
17749 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17750 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017751 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17752 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017753 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17754 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17755 { } /* end */
17756};
17757
Kailang Yangebb83ee2009-12-17 12:23:00 +010017758static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17759 .ops = &snd_hda_bind_sw,
17760 .values = {
17761 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17762 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17763 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17764 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17765 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17766 0
17767 },
17768};
17769
17770static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17771 .ops = &snd_hda_bind_sw,
17772 .values = {
17773 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17774 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17775 0
17776 },
17777};
17778
17779static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17780 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17781 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17782 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17783 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17784 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17785 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17786 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17787 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17788 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17789 { } /* end */
17790};
17791
17792static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17793 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17794 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17795 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17796 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17797 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17798 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17799 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17800 { } /* end */
17801};
17802
17803
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017804static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17805 {
17806 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17807 .name = "Channel Mode",
17808 .info = alc_ch_mode_info,
17809 .get = alc_ch_mode_get,
17810 .put = alc_ch_mode_put,
17811 },
17812 { } /* end */
17813};
17814
17815static struct hda_verb alc662_init_verbs[] = {
17816 /* ADC: mute amp left and right */
17817 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17818 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017819
Kailang Yangb60dd392007-09-20 12:50:29 +020017820 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17821 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17822 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17823 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17824 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17825 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017826
17827 /* Front Pin: output 0 (0x0c) */
17828 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17829 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17830
17831 /* Rear Pin: output 1 (0x0d) */
17832 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17833 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17834
17835 /* CLFE Pin: output 2 (0x0e) */
17836 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17837 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17838
17839 /* Mic (rear) pin: input vref at 80% */
17840 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17841 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17842 /* Front Mic pin: input vref at 80% */
17843 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17844 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17845 /* Line In pin: input */
17846 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17847 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17848 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17849 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17850 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17851 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17852 /* CD pin widget for input */
17853 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17854
17855 /* FIXME: use matrix-type input source selection */
17856 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17857 /* Input mixer */
17858 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017859 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017860
17861 /* always trun on EAPD */
17862 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17863 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17864
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017865 { }
17866};
17867
Kailang Yangcec27c82010-02-04 14:18:18 +010017868static struct hda_verb alc663_init_verbs[] = {
17869 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17870 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17871 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17872 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17873 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17874 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17875 { }
17876};
17877
17878static struct hda_verb alc272_init_verbs[] = {
17879 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17880 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17881 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17882 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17883 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17884 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17885 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17886 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17887 { }
17888};
17889
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017890static struct hda_verb alc662_sue_init_verbs[] = {
17891 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17892 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017893 {}
17894};
17895
17896static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17897 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17898 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17899 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017900};
17901
Kailang Yang8c427222008-01-10 13:03:59 +010017902/* Set Unsolicited Event*/
17903static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17904 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17905 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17906 {}
17907};
17908
Kailang Yang6dda9f42008-05-27 12:05:31 +020017909static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017910 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17911 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017912 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17913 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017914 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17915 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17916 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017917 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17918 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17919 {}
17920};
17921
Kailang Yangf1d4e282008-08-26 14:03:29 +020017922static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17923 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17924 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17925 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17926 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17927 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17928 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17929 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17930 {}
17931};
17932
17933static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17934 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17935 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17936 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17937 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17938 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17939 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17940 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17941 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17942 {}
17943};
17944
17945static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17946 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17947 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17948 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17949 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17950 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17951 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17952 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17953 {}
17954};
17955
17956static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17957 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17958 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17959 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17960 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17961 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17962 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17963 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17964 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17965 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17966 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17967 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17968 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17969 {}
17970};
17971
17972static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
17973 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17974 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17975 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17976 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17977 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17978 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17979 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17980 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17981 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17982 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17983 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17984 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17985 {}
17986};
17987
Kailang Yang6dda9f42008-05-27 12:05:31 +020017988static struct hda_verb alc663_g71v_init_verbs[] = {
17989 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17990 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
17991 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
17992
17993 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17994 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17995 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17996
17997 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17998 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
17999 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
18000 {}
18001};
18002
18003static struct hda_verb alc663_g50v_init_verbs[] = {
18004 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18005 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18006 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18007
18008 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18009 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18010 {}
18011};
18012
Kailang Yangf1d4e282008-08-26 14:03:29 +020018013static struct hda_verb alc662_ecs_init_verbs[] = {
18014 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
18015 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18016 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18017 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18018 {}
18019};
18020
Kailang Yang622e84c2009-04-21 07:39:04 +020018021static struct hda_verb alc272_dell_zm1_init_verbs[] = {
18022 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18023 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18024 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18025 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18026 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18027 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18028 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18029 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18030 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18031 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18032 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18033 {}
18034};
18035
18036static struct hda_verb alc272_dell_init_verbs[] = {
18037 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18038 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18039 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18040 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18041 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18042 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18043 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18044 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18045 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18046 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18047 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18048 {}
18049};
18050
Kailang Yangebb83ee2009-12-17 12:23:00 +010018051static struct hda_verb alc663_mode7_init_verbs[] = {
18052 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18053 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18054 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18055 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18056 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18057 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18058 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
18059 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18060 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18061 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18062 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18063 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18064 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18065 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18066 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18067 {}
18068};
18069
18070static struct hda_verb alc663_mode8_init_verbs[] = {
18071 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18072 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18073 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18074 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
18075 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18076 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18077 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18078 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18079 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18080 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18081 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18082 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18083 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18084 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18085 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18086 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18087 {}
18088};
18089
Kailang Yangf1d4e282008-08-26 14:03:29 +020018090static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
18091 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
18092 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
18093 { } /* end */
18094};
18095
Kailang Yang622e84c2009-04-21 07:39:04 +020018096static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
18097 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
18098 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
18099 { } /* end */
18100};
18101
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018102static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
18103{
18104 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018105 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018106
Wu Fengguang864f92b2009-11-18 12:38:02 +080018107 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018108 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018109
Takashi Iwai47fd8302007-08-10 17:11:07 +020018110 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18111 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018112}
18113
18114static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
18115{
18116 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018117 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018118
Wu Fengguang864f92b2009-11-18 12:38:02 +080018119 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018120 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018121
Takashi Iwai47fd8302007-08-10 17:11:07 +020018122 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18123 HDA_AMP_MUTE, bits);
18124 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18125 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018126}
18127
18128static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
18129 unsigned int res)
18130{
18131 if ((res >> 26) == ALC880_HP_EVENT)
18132 alc662_lenovo_101e_all_automute(codec);
18133 if ((res >> 26) == ALC880_FRONT_EVENT)
18134 alc662_lenovo_101e_ispeaker_automute(codec);
18135}
18136
Kailang Yang291702f2007-10-16 14:28:03 +020018137/* unsolicited event for HP jack sensing */
18138static void alc662_eeepc_unsol_event(struct hda_codec *codec,
18139 unsigned int res)
18140{
Kailang Yang291702f2007-10-16 14:28:03 +020018141 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018142 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020018143 else
18144 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020018145}
18146
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018147static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020018148{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018149 struct alc_spec *spec = codec->spec;
18150
18151 alc262_hippo1_setup(codec);
18152 spec->ext_mic.pin = 0x18;
18153 spec->ext_mic.mux_idx = 0;
18154 spec->int_mic.pin = 0x19;
18155 spec->int_mic.mux_idx = 1;
18156 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020018157}
18158
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018159static void alc662_eeepc_inithook(struct hda_codec *codec)
18160{
18161 alc262_hippo_automute(codec);
18162 alc_mic_automute(codec);
18163}
18164
18165static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010018166{
Takashi Iwai42171c12009-05-08 14:11:43 +020018167 struct alc_spec *spec = codec->spec;
18168
18169 spec->autocfg.hp_pins[0] = 0x14;
18170 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010018171}
18172
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018173#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
18174
Kailang Yang6dda9f42008-05-27 12:05:31 +020018175static void alc663_m51va_speaker_automute(struct hda_codec *codec)
18176{
18177 unsigned int present;
18178 unsigned char bits;
18179
Wu Fengguang864f92b2009-11-18 12:38:02 +080018180 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018181 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018182 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018183 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018184 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018185 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018186}
18187
18188static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
18189{
18190 unsigned int present;
18191 unsigned char bits;
18192
Wu Fengguang864f92b2009-11-18 12:38:02 +080018193 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018194 bits = present ? HDA_AMP_MUTE : 0;
18195 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018196 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018197 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018198 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018199 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018200 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018201 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018202 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018203}
18204
18205static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
18206{
18207 unsigned int present;
18208 unsigned char bits;
18209
Wu Fengguang864f92b2009-11-18 12:38:02 +080018210 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018211 bits = present ? HDA_AMP_MUTE : 0;
18212 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018213 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018214 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018215 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018216 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018217 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018218 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018219 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018220}
18221
18222static void alc662_f5z_speaker_automute(struct hda_codec *codec)
18223{
18224 unsigned int present;
18225 unsigned char bits;
18226
Wu Fengguang864f92b2009-11-18 12:38:02 +080018227 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018228 bits = present ? 0 : PIN_OUT;
18229 snd_hda_codec_write(codec, 0x14, 0,
18230 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
18231}
18232
18233static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
18234{
18235 unsigned int present1, present2;
18236
Wu Fengguang864f92b2009-11-18 12:38:02 +080018237 present1 = snd_hda_jack_detect(codec, 0x21);
18238 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018239
18240 if (present1 || present2) {
18241 snd_hda_codec_write_cache(codec, 0x14, 0,
18242 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18243 } else {
18244 snd_hda_codec_write_cache(codec, 0x14, 0,
18245 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18246 }
18247}
18248
18249static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
18250{
18251 unsigned int present1, present2;
18252
Wu Fengguang864f92b2009-11-18 12:38:02 +080018253 present1 = snd_hda_jack_detect(codec, 0x1b);
18254 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018255
18256 if (present1 || present2) {
18257 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018258 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018259 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018260 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018261 } else {
18262 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018263 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018264 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018265 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018266 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020018267}
18268
Kailang Yangebb83ee2009-12-17 12:23:00 +010018269static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
18270{
18271 unsigned int present1, present2;
18272
18273 present1 = snd_hda_codec_read(codec, 0x1b, 0,
18274 AC_VERB_GET_PIN_SENSE, 0)
18275 & AC_PINSENSE_PRESENCE;
18276 present2 = snd_hda_codec_read(codec, 0x21, 0,
18277 AC_VERB_GET_PIN_SENSE, 0)
18278 & AC_PINSENSE_PRESENCE;
18279
18280 if (present1 || present2) {
18281 snd_hda_codec_write_cache(codec, 0x14, 0,
18282 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18283 snd_hda_codec_write_cache(codec, 0x17, 0,
18284 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18285 } else {
18286 snd_hda_codec_write_cache(codec, 0x14, 0,
18287 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18288 snd_hda_codec_write_cache(codec, 0x17, 0,
18289 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18290 }
18291}
18292
18293static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
18294{
18295 unsigned int present1, present2;
18296
18297 present1 = snd_hda_codec_read(codec, 0x21, 0,
18298 AC_VERB_GET_PIN_SENSE, 0)
18299 & AC_PINSENSE_PRESENCE;
18300 present2 = snd_hda_codec_read(codec, 0x15, 0,
18301 AC_VERB_GET_PIN_SENSE, 0)
18302 & AC_PINSENSE_PRESENCE;
18303
18304 if (present1 || present2) {
18305 snd_hda_codec_write_cache(codec, 0x14, 0,
18306 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18307 snd_hda_codec_write_cache(codec, 0x17, 0,
18308 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18309 } else {
18310 snd_hda_codec_write_cache(codec, 0x14, 0,
18311 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18312 snd_hda_codec_write_cache(codec, 0x17, 0,
18313 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18314 }
18315}
18316
Kailang Yang6dda9f42008-05-27 12:05:31 +020018317static void alc663_m51va_unsol_event(struct hda_codec *codec,
18318 unsigned int res)
18319{
18320 switch (res >> 26) {
18321 case ALC880_HP_EVENT:
18322 alc663_m51va_speaker_automute(codec);
18323 break;
18324 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018325 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018326 break;
18327 }
18328}
18329
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018330static void alc663_m51va_setup(struct hda_codec *codec)
18331{
18332 struct alc_spec *spec = codec->spec;
18333 spec->ext_mic.pin = 0x18;
18334 spec->ext_mic.mux_idx = 0;
18335 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018336 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018337 spec->auto_mic = 1;
18338}
18339
Kailang Yang6dda9f42008-05-27 12:05:31 +020018340static void alc663_m51va_inithook(struct hda_codec *codec)
18341{
18342 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018343 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018344}
18345
Kailang Yangf1d4e282008-08-26 14:03:29 +020018346/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018347#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010018348
18349static void alc663_mode1_setup(struct hda_codec *codec)
18350{
18351 struct alc_spec *spec = codec->spec;
18352 spec->ext_mic.pin = 0x18;
18353 spec->ext_mic.mux_idx = 0;
18354 spec->int_mic.pin = 0x19;
18355 spec->int_mic.mux_idx = 1;
18356 spec->auto_mic = 1;
18357}
18358
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018359#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020018360
Kailang Yangf1d4e282008-08-26 14:03:29 +020018361/* ***************** Mode2 ******************************/
18362static void alc662_mode2_unsol_event(struct hda_codec *codec,
18363 unsigned int res)
18364{
18365 switch (res >> 26) {
18366 case ALC880_HP_EVENT:
18367 alc662_f5z_speaker_automute(codec);
18368 break;
18369 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018370 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018371 break;
18372 }
18373}
18374
Kailang Yangebb83ee2009-12-17 12:23:00 +010018375#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018376
Kailang Yangf1d4e282008-08-26 14:03:29 +020018377static void alc662_mode2_inithook(struct hda_codec *codec)
18378{
18379 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018380 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018381}
18382/* ***************** Mode3 ******************************/
18383static void alc663_mode3_unsol_event(struct hda_codec *codec,
18384 unsigned int res)
18385{
18386 switch (res >> 26) {
18387 case ALC880_HP_EVENT:
18388 alc663_two_hp_m1_speaker_automute(codec);
18389 break;
18390 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018391 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018392 break;
18393 }
18394}
18395
Kailang Yangebb83ee2009-12-17 12:23:00 +010018396#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018397
Kailang Yangf1d4e282008-08-26 14:03:29 +020018398static void alc663_mode3_inithook(struct hda_codec *codec)
18399{
18400 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018401 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018402}
18403/* ***************** Mode4 ******************************/
18404static void alc663_mode4_unsol_event(struct hda_codec *codec,
18405 unsigned int res)
18406{
18407 switch (res >> 26) {
18408 case ALC880_HP_EVENT:
18409 alc663_21jd_two_speaker_automute(codec);
18410 break;
18411 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018412 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018413 break;
18414 }
18415}
18416
Kailang Yangebb83ee2009-12-17 12:23:00 +010018417#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018418
Kailang Yangf1d4e282008-08-26 14:03:29 +020018419static void alc663_mode4_inithook(struct hda_codec *codec)
18420{
18421 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018422 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018423}
18424/* ***************** Mode5 ******************************/
18425static void alc663_mode5_unsol_event(struct hda_codec *codec,
18426 unsigned int res)
18427{
18428 switch (res >> 26) {
18429 case ALC880_HP_EVENT:
18430 alc663_15jd_two_speaker_automute(codec);
18431 break;
18432 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018433 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018434 break;
18435 }
18436}
18437
Kailang Yangebb83ee2009-12-17 12:23:00 +010018438#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018439
Kailang Yangf1d4e282008-08-26 14:03:29 +020018440static void alc663_mode5_inithook(struct hda_codec *codec)
18441{
18442 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018443 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018444}
18445/* ***************** Mode6 ******************************/
18446static void alc663_mode6_unsol_event(struct hda_codec *codec,
18447 unsigned int res)
18448{
18449 switch (res >> 26) {
18450 case ALC880_HP_EVENT:
18451 alc663_two_hp_m2_speaker_automute(codec);
18452 break;
18453 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018454 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018455 break;
18456 }
18457}
18458
Kailang Yangebb83ee2009-12-17 12:23:00 +010018459#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018460
Kailang Yangf1d4e282008-08-26 14:03:29 +020018461static void alc663_mode6_inithook(struct hda_codec *codec)
18462{
18463 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018464 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018465}
18466
Kailang Yangebb83ee2009-12-17 12:23:00 +010018467/* ***************** Mode7 ******************************/
18468static void alc663_mode7_unsol_event(struct hda_codec *codec,
18469 unsigned int res)
18470{
18471 switch (res >> 26) {
18472 case ALC880_HP_EVENT:
18473 alc663_two_hp_m7_speaker_automute(codec);
18474 break;
18475 case ALC880_MIC_EVENT:
18476 alc_mic_automute(codec);
18477 break;
18478 }
18479}
18480
18481#define alc663_mode7_setup alc663_mode1_setup
18482
18483static void alc663_mode7_inithook(struct hda_codec *codec)
18484{
18485 alc663_two_hp_m7_speaker_automute(codec);
18486 alc_mic_automute(codec);
18487}
18488
18489/* ***************** Mode8 ******************************/
18490static void alc663_mode8_unsol_event(struct hda_codec *codec,
18491 unsigned int res)
18492{
18493 switch (res >> 26) {
18494 case ALC880_HP_EVENT:
18495 alc663_two_hp_m8_speaker_automute(codec);
18496 break;
18497 case ALC880_MIC_EVENT:
18498 alc_mic_automute(codec);
18499 break;
18500 }
18501}
18502
18503#define alc663_mode8_setup alc663_m51va_setup
18504
18505static void alc663_mode8_inithook(struct hda_codec *codec)
18506{
18507 alc663_two_hp_m8_speaker_automute(codec);
18508 alc_mic_automute(codec);
18509}
18510
Kailang Yang6dda9f42008-05-27 12:05:31 +020018511static void alc663_g71v_hp_automute(struct hda_codec *codec)
18512{
18513 unsigned int present;
18514 unsigned char bits;
18515
Wu Fengguang864f92b2009-11-18 12:38:02 +080018516 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018517 bits = present ? HDA_AMP_MUTE : 0;
18518 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18519 HDA_AMP_MUTE, bits);
18520 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18521 HDA_AMP_MUTE, bits);
18522}
18523
18524static void alc663_g71v_front_automute(struct hda_codec *codec)
18525{
18526 unsigned int present;
18527 unsigned char bits;
18528
Wu Fengguang864f92b2009-11-18 12:38:02 +080018529 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018530 bits = present ? HDA_AMP_MUTE : 0;
18531 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18532 HDA_AMP_MUTE, bits);
18533}
18534
18535static void alc663_g71v_unsol_event(struct hda_codec *codec,
18536 unsigned int res)
18537{
18538 switch (res >> 26) {
18539 case ALC880_HP_EVENT:
18540 alc663_g71v_hp_automute(codec);
18541 break;
18542 case ALC880_FRONT_EVENT:
18543 alc663_g71v_front_automute(codec);
18544 break;
18545 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018546 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018547 break;
18548 }
18549}
18550
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018551#define alc663_g71v_setup alc663_m51va_setup
18552
Kailang Yang6dda9f42008-05-27 12:05:31 +020018553static void alc663_g71v_inithook(struct hda_codec *codec)
18554{
18555 alc663_g71v_front_automute(codec);
18556 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018557 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018558}
18559
18560static void alc663_g50v_unsol_event(struct hda_codec *codec,
18561 unsigned int res)
18562{
18563 switch (res >> 26) {
18564 case ALC880_HP_EVENT:
18565 alc663_m51va_speaker_automute(codec);
18566 break;
18567 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018568 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018569 break;
18570 }
18571}
18572
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018573#define alc663_g50v_setup alc663_m51va_setup
18574
Kailang Yang6dda9f42008-05-27 12:05:31 +020018575static void alc663_g50v_inithook(struct hda_codec *codec)
18576{
18577 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018578 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018579}
18580
Kailang Yangf1d4e282008-08-26 14:03:29 +020018581static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18582 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018583 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018584
David Henningsson5f99f862011-01-04 15:24:24 +010018585 HDA_CODEC_VOLUME("Mic/LineIn Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018586 HDA_CODEC_VOLUME("Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18587 HDA_CODEC_MUTE("Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018588
David Henningsson5f99f862011-01-04 15:24:24 +010018589 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018590 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18591 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018592 { } /* end */
18593};
18594
Chris Pockelé9541ba12009-05-12 08:08:53 +020018595static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18596 /* Master Playback automatically created from Speaker and Headphone */
18597 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18598 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18599 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18600 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18601
David Henningsson8607f7c2010-12-20 14:43:54 +010018602 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18603 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018604 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018605
David Henningsson28c4edb2010-12-20 14:24:29 +010018606 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18607 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018608 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018609 { } /* end */
18610};
18611
Takashi Iwaicb53c622007-08-10 17:21:45 +020018612#ifdef CONFIG_SND_HDA_POWER_SAVE
18613#define alc662_loopbacks alc880_loopbacks
18614#endif
18615
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018616
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018617/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018618#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18619#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18620#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18621#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18622
18623/*
18624 * configuration and preset
18625 */
18626static const char *alc662_models[ALC662_MODEL_LAST] = {
18627 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18628 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18629 [ALC662_3ST_6ch] = "3stack-6ch",
18630 [ALC662_5ST_DIG] = "6stack-dig",
18631 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018632 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018633 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018634 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018635 [ALC663_ASUS_M51VA] = "m51va",
18636 [ALC663_ASUS_G71V] = "g71v",
18637 [ALC663_ASUS_H13] = "h13",
18638 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018639 [ALC663_ASUS_MODE1] = "asus-mode1",
18640 [ALC662_ASUS_MODE2] = "asus-mode2",
18641 [ALC663_ASUS_MODE3] = "asus-mode3",
18642 [ALC663_ASUS_MODE4] = "asus-mode4",
18643 [ALC663_ASUS_MODE5] = "asus-mode5",
18644 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018645 [ALC663_ASUS_MODE7] = "asus-mode7",
18646 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018647 [ALC272_DELL] = "dell",
18648 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018649 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018650 [ALC662_AUTO] = "auto",
18651};
18652
18653static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018654 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018655 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18656 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018657 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18658 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018659 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018660 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18661 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18662 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18663 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018664 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18665 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018666 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018667 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18668 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18669 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18670 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18671 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018672 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018673 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18674 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018675 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18676 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18677 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18678 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018679 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018680 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18681 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18682 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018683 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18684 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18685 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18686 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018687 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018688 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18689 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018690 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018691 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18692 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18693 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018694 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018695 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018696 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18697 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018698 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18699 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18700 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018701 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018702 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18703 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018704 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018705 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018706 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018707 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18708 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18709 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018710 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018711 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18712 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018713 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018714 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018715 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018716 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018717 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18718 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018719 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018720 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018721 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18722 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018723 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018724 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018725 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018726 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018727 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018728 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018729 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18730 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018731 {}
18732};
18733
18734static struct alc_config_preset alc662_presets[] = {
18735 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018736 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018737 .init_verbs = { alc662_init_verbs },
18738 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18739 .dac_nids = alc662_dac_nids,
18740 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018741 .dig_in_nid = ALC662_DIGIN_NID,
18742 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18743 .channel_mode = alc662_3ST_2ch_modes,
18744 .input_mux = &alc662_capture_source,
18745 },
18746 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018747 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018748 .init_verbs = { alc662_init_verbs },
18749 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18750 .dac_nids = alc662_dac_nids,
18751 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018752 .dig_in_nid = ALC662_DIGIN_NID,
18753 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18754 .channel_mode = alc662_3ST_6ch_modes,
18755 .need_dac_fix = 1,
18756 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018757 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018758 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018759 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018760 .init_verbs = { alc662_init_verbs },
18761 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18762 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018763 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18764 .channel_mode = alc662_3ST_6ch_modes,
18765 .need_dac_fix = 1,
18766 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018767 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018768 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018769 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018770 .init_verbs = { alc662_init_verbs },
18771 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18772 .dac_nids = alc662_dac_nids,
18773 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018774 .dig_in_nid = ALC662_DIGIN_NID,
18775 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18776 .channel_mode = alc662_5stack_modes,
18777 .input_mux = &alc662_capture_source,
18778 },
18779 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018780 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018781 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18782 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18783 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018784 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18785 .channel_mode = alc662_3ST_2ch_modes,
18786 .input_mux = &alc662_lenovo_101e_capture_source,
18787 .unsol_event = alc662_lenovo_101e_unsol_event,
18788 .init_hook = alc662_lenovo_101e_all_automute,
18789 },
Kailang Yang291702f2007-10-16 14:28:03 +020018790 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018791 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018792 .init_verbs = { alc662_init_verbs,
18793 alc662_eeepc_sue_init_verbs },
18794 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18795 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018796 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18797 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018798 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018799 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018800 .init_hook = alc662_eeepc_inithook,
18801 },
Kailang Yang8c427222008-01-10 13:03:59 +010018802 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018803 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018804 alc662_chmode_mixer },
18805 .init_verbs = { alc662_init_verbs,
18806 alc662_eeepc_ep20_sue_init_verbs },
18807 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18808 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018809 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18810 .channel_mode = alc662_3ST_6ch_modes,
18811 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018812 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018813 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018814 .init_hook = alc662_eeepc_ep20_inithook,
18815 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018816 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018817 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018818 .init_verbs = { alc662_init_verbs,
18819 alc662_ecs_init_verbs },
18820 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18821 .dac_nids = alc662_dac_nids,
18822 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18823 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018824 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018825 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018826 .init_hook = alc662_eeepc_inithook,
18827 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018828 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018829 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018830 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18831 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18832 .dac_nids = alc662_dac_nids,
18833 .dig_out_nid = ALC662_DIGOUT_NID,
18834 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18835 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018836 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018837 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018838 .init_hook = alc663_m51va_inithook,
18839 },
18840 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018841 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018842 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18843 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18844 .dac_nids = alc662_dac_nids,
18845 .dig_out_nid = ALC662_DIGOUT_NID,
18846 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18847 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018848 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018849 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018850 .init_hook = alc663_g71v_inithook,
18851 },
18852 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018853 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018854 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18855 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18856 .dac_nids = alc662_dac_nids,
18857 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18858 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018859 .unsol_event = alc663_m51va_unsol_event,
18860 .init_hook = alc663_m51va_inithook,
18861 },
18862 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018863 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018864 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18865 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18866 .dac_nids = alc662_dac_nids,
18867 .dig_out_nid = ALC662_DIGOUT_NID,
18868 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18869 .channel_mode = alc662_3ST_6ch_modes,
18870 .input_mux = &alc663_capture_source,
18871 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018872 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018873 .init_hook = alc663_g50v_inithook,
18874 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018875 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018876 .mixers = { alc663_m51va_mixer },
18877 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018878 .init_verbs = { alc662_init_verbs,
18879 alc663_21jd_amic_init_verbs },
18880 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18881 .hp_nid = 0x03,
18882 .dac_nids = alc662_dac_nids,
18883 .dig_out_nid = ALC662_DIGOUT_NID,
18884 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18885 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018886 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018887 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018888 .init_hook = alc663_mode1_inithook,
18889 },
18890 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018891 .mixers = { alc662_1bjd_mixer },
18892 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018893 .init_verbs = { alc662_init_verbs,
18894 alc662_1bjd_amic_init_verbs },
18895 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18896 .dac_nids = alc662_dac_nids,
18897 .dig_out_nid = ALC662_DIGOUT_NID,
18898 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18899 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018900 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018901 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018902 .init_hook = alc662_mode2_inithook,
18903 },
18904 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018905 .mixers = { alc663_two_hp_m1_mixer },
18906 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018907 .init_verbs = { alc662_init_verbs,
18908 alc663_two_hp_amic_m1_init_verbs },
18909 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18910 .hp_nid = 0x03,
18911 .dac_nids = alc662_dac_nids,
18912 .dig_out_nid = ALC662_DIGOUT_NID,
18913 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18914 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018915 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018916 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018917 .init_hook = alc663_mode3_inithook,
18918 },
18919 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018920 .mixers = { alc663_asus_21jd_clfe_mixer },
18921 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018922 .init_verbs = { alc662_init_verbs,
18923 alc663_21jd_amic_init_verbs},
18924 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18925 .hp_nid = 0x03,
18926 .dac_nids = alc662_dac_nids,
18927 .dig_out_nid = ALC662_DIGOUT_NID,
18928 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18929 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018930 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018931 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018932 .init_hook = alc663_mode4_inithook,
18933 },
18934 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018935 .mixers = { alc663_asus_15jd_clfe_mixer },
18936 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018937 .init_verbs = { alc662_init_verbs,
18938 alc663_15jd_amic_init_verbs },
18939 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18940 .hp_nid = 0x03,
18941 .dac_nids = alc662_dac_nids,
18942 .dig_out_nid = ALC662_DIGOUT_NID,
18943 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18944 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018945 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018946 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018947 .init_hook = alc663_mode5_inithook,
18948 },
18949 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018950 .mixers = { alc663_two_hp_m2_mixer },
18951 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018952 .init_verbs = { alc662_init_verbs,
18953 alc663_two_hp_amic_m2_init_verbs },
18954 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18955 .hp_nid = 0x03,
18956 .dac_nids = alc662_dac_nids,
18957 .dig_out_nid = ALC662_DIGOUT_NID,
18958 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18959 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018960 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018961 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018962 .init_hook = alc663_mode6_inithook,
18963 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018964 [ALC663_ASUS_MODE7] = {
18965 .mixers = { alc663_mode7_mixer },
18966 .cap_mixer = alc662_auto_capture_mixer,
18967 .init_verbs = { alc662_init_verbs,
18968 alc663_mode7_init_verbs },
18969 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18970 .hp_nid = 0x03,
18971 .dac_nids = alc662_dac_nids,
18972 .dig_out_nid = ALC662_DIGOUT_NID,
18973 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18974 .channel_mode = alc662_3ST_2ch_modes,
18975 .unsol_event = alc663_mode7_unsol_event,
18976 .setup = alc663_mode7_setup,
18977 .init_hook = alc663_mode7_inithook,
18978 },
18979 [ALC663_ASUS_MODE8] = {
18980 .mixers = { alc663_mode8_mixer },
18981 .cap_mixer = alc662_auto_capture_mixer,
18982 .init_verbs = { alc662_init_verbs,
18983 alc663_mode8_init_verbs },
18984 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18985 .hp_nid = 0x03,
18986 .dac_nids = alc662_dac_nids,
18987 .dig_out_nid = ALC662_DIGOUT_NID,
18988 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18989 .channel_mode = alc662_3ST_2ch_modes,
18990 .unsol_event = alc663_mode8_unsol_event,
18991 .setup = alc663_mode8_setup,
18992 .init_hook = alc663_mode8_inithook,
18993 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018994 [ALC272_DELL] = {
18995 .mixers = { alc663_m51va_mixer },
18996 .cap_mixer = alc272_auto_capture_mixer,
18997 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
18998 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18999 .dac_nids = alc662_dac_nids,
19000 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19001 .adc_nids = alc272_adc_nids,
19002 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
19003 .capsrc_nids = alc272_capsrc_nids,
19004 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020019005 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019006 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020019007 .init_hook = alc663_m51va_inithook,
19008 },
19009 [ALC272_DELL_ZM1] = {
19010 .mixers = { alc663_m51va_mixer },
19011 .cap_mixer = alc662_auto_capture_mixer,
19012 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
19013 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19014 .dac_nids = alc662_dac_nids,
19015 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19016 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019017 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020019018 .capsrc_nids = alc662_capsrc_nids,
19019 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020019020 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019021 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020019022 .init_hook = alc663_m51va_inithook,
19023 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020019024 [ALC272_SAMSUNG_NC10] = {
19025 .mixers = { alc272_nc10_mixer },
19026 .init_verbs = { alc662_init_verbs,
19027 alc663_21jd_amic_init_verbs },
19028 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19029 .dac_nids = alc272_dac_nids,
19030 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19031 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019032 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020019033 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019034 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020019035 .init_hook = alc663_mode4_inithook,
19036 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019037};
19038
19039
19040/*
19041 * BIOS auto configuration
19042 */
19043
Takashi Iwai7085ec12009-10-02 09:03:58 +020019044/* convert from MIX nid to DAC */
19045static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
19046{
19047 if (nid == 0x0f)
19048 return 0x02;
19049 else if (nid >= 0x0c && nid <= 0x0e)
19050 return nid - 0x0c + 0x02;
David Henningssoncc1c4522010-11-24 14:17:47 +010019051 else if (nid == 0x26) /* ALC887-VD has this DAC too */
19052 return 0x25;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019053 else
19054 return 0;
19055}
19056
19057/* get MIX nid connected to the given pin targeted to DAC */
19058static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
19059 hda_nid_t dac)
19060{
David Henningssoncc1c4522010-11-24 14:17:47 +010019061 hda_nid_t mix[5];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019062 int i, num;
19063
19064 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
19065 for (i = 0; i < num; i++) {
19066 if (alc662_mix_to_dac(mix[i]) == dac)
19067 return mix[i];
19068 }
19069 return 0;
19070}
19071
19072/* look for an empty DAC slot */
19073static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
19074{
19075 struct alc_spec *spec = codec->spec;
19076 hda_nid_t srcs[5];
19077 int i, j, num;
19078
19079 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
19080 if (num < 0)
19081 return 0;
19082 for (i = 0; i < num; i++) {
19083 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
19084 if (!nid)
19085 continue;
19086 for (j = 0; j < spec->multiout.num_dacs; j++)
19087 if (spec->multiout.dac_nids[j] == nid)
19088 break;
19089 if (j >= spec->multiout.num_dacs)
19090 return nid;
19091 }
19092 return 0;
19093}
19094
19095/* fill in the dac_nids table from the parsed pin configuration */
19096static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
19097 const struct auto_pin_cfg *cfg)
19098{
19099 struct alc_spec *spec = codec->spec;
19100 int i;
19101 hda_nid_t dac;
19102
19103 spec->multiout.dac_nids = spec->private_dac_nids;
19104 for (i = 0; i < cfg->line_outs; i++) {
19105 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
19106 if (!dac)
19107 continue;
19108 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19109 }
19110 return 0;
19111}
19112
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019113static inline int __alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
19114 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019115{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019116 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019117 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
19118}
19119
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019120static inline int __alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
19121 hda_nid_t nid, int idx, unsigned int chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019122{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019123 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019124 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
19125}
19126
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019127#define alc662_add_vol_ctl(spec, pfx, nid, chs) \
19128 __alc662_add_vol_ctl(spec, pfx, nid, 0, chs)
19129#define alc662_add_sw_ctl(spec, pfx, nid, chs) \
19130 __alc662_add_sw_ctl(spec, pfx, nid, 0, chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019131#define alc662_add_stereo_vol(spec, pfx, nid) \
19132 alc662_add_vol_ctl(spec, pfx, nid, 3)
19133#define alc662_add_stereo_sw(spec, pfx, nid) \
19134 alc662_add_sw_ctl(spec, pfx, nid, 3)
19135
19136/* add playback controls from the parsed DAC table */
19137static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
19138 const struct auto_pin_cfg *cfg)
19139{
19140 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019141 static const char *chname[4] = {
19142 "Front", "Surround", NULL /*CLFE*/, "Side"
19143 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019144 const char *pfx = alc_get_line_out_pfx(cfg, true);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019145 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019146 int i, err;
19147
19148 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019149 nid = spec->multiout.dac_nids[i];
19150 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019151 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019152 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
19153 if (!mix)
19154 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019155 if (!pfx && i == 2) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019156 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019157 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019158 if (err < 0)
19159 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019160 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019161 if (err < 0)
19162 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019163 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019164 if (err < 0)
19165 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019166 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019167 if (err < 0)
19168 return err;
19169 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019170 const char *name = pfx;
19171 if (!name)
19172 name = chname[i];
19173 err = __alc662_add_vol_ctl(spec, name, nid, i, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019174 if (err < 0)
19175 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019176 err = __alc662_add_sw_ctl(spec, name, mix, i, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019177 if (err < 0)
19178 return err;
19179 }
19180 }
19181 return 0;
19182}
19183
19184/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019185/* return DAC nid if any new DAC is assigned */
19186static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019187 const char *pfx)
19188{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019189 struct alc_spec *spec = codec->spec;
19190 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019191 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019192
19193 if (!pin)
19194 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019195 nid = alc662_look_for_dac(codec, pin);
19196 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019197 /* the corresponding DAC is already occupied */
19198 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
19199 return 0; /* no way */
19200 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019201 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019202 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19203 }
19204
19205 mix = alc662_dac_to_mix(codec, pin, nid);
19206 if (!mix)
19207 return 0;
19208 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
19209 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020019210 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019211 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
19212 if (err < 0)
19213 return err;
19214 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019215}
19216
19217/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020019218#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020019219 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019220
19221static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
19222 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019223 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019224{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019225 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020019226 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019227
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019228 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019229 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019230 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
19231 if (num <= 1)
19232 return;
19233 for (i = 0; i < num; i++) {
19234 if (alc662_mix_to_dac(srcs[i]) != dac)
19235 continue;
19236 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
19237 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019238 }
19239}
19240
19241static void alc662_auto_init_multi_out(struct hda_codec *codec)
19242{
19243 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019244 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019245 int i;
19246
19247 for (i = 0; i <= HDA_SIDE; i++) {
19248 hda_nid_t nid = spec->autocfg.line_out_pins[i];
19249 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020019250 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019251 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019252 }
19253}
19254
19255static void alc662_auto_init_hp_out(struct hda_codec *codec)
19256{
19257 struct alc_spec *spec = codec->spec;
19258 hda_nid_t pin;
19259
19260 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019261 if (pin)
19262 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
19263 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019264 pin = spec->autocfg.speaker_pins[0];
19265 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019266 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
19267 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019268}
19269
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019270#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
19271
19272static void alc662_auto_init_analog_input(struct hda_codec *codec)
19273{
19274 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019275 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019276 int i;
19277
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019278 for (i = 0; i < cfg->num_inputs; i++) {
19279 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019280 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020019281 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010019282 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010019283 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019284 snd_hda_codec_write(codec, nid, 0,
19285 AC_VERB_SET_AMP_GAIN_MUTE,
19286 AMP_OUT_MUTE);
19287 }
19288 }
19289}
19290
Takashi Iwaif511b012008-08-15 16:46:42 +020019291#define alc662_auto_init_input_src alc882_auto_init_input_src
19292
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019293static int alc662_parse_auto_config(struct hda_codec *codec)
19294{
19295 struct alc_spec *spec = codec->spec;
19296 int err;
19297 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
19298
19299 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19300 alc662_ignore);
19301 if (err < 0)
19302 return err;
19303 if (!spec->autocfg.line_outs)
19304 return 0; /* can't find valid BIOS pin config */
19305
Takashi Iwai7085ec12009-10-02 09:03:58 +020019306 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019307 if (err < 0)
19308 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019309 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019310 if (err < 0)
19311 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019312 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019313 spec->autocfg.speaker_pins[0],
19314 "Speaker");
19315 if (err < 0)
19316 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019317 if (err)
19318 spec->multiout.extra_out_nid[0] = err;
19319 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019320 "Headphone");
19321 if (err < 0)
19322 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019323 if (err)
19324 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019325 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019326 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019327 return err;
19328
19329 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
19330
Takashi Iwai757899a2010-07-30 10:48:14 +020019331 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019332
Takashi Iwai603c4012008-07-30 15:01:44 +020019333 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010019334 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019335
19336 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020019337 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020019338
Kailang Yangcec27c82010-02-04 14:18:18 +010019339 add_verb(spec, alc662_init_verbs);
19340 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019341 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Kailang Yangcec27c82010-02-04 14:18:18 +010019342 add_verb(spec, alc663_init_verbs);
19343
19344 if (codec->vendor_id == 0x10ec0272)
19345 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020019346
19347 err = alc_auto_add_mic_boost(codec);
19348 if (err < 0)
19349 return err;
19350
Kailang Yang6227cdc2010-02-25 08:36:52 +010019351 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
19352 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
19353 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
19354 else
19355 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020019356
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019357 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019358}
19359
19360/* additional initialization for auto-configuration model */
19361static void alc662_auto_init(struct hda_codec *codec)
19362{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019363 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019364 alc662_auto_init_multi_out(codec);
19365 alc662_auto_init_hp_out(codec);
19366 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020019367 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019368 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019369 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020019370 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019371}
19372
Todd Broch6be79482010-12-07 16:51:05 -080019373static void alc272_fixup_mario(struct hda_codec *codec,
19374 const struct alc_fixup *fix, int pre_init) {
19375 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
19376 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
19377 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
19378 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
19379 (0 << AC_AMPCAP_MUTE_SHIFT)))
19380 printk(KERN_WARNING
19381 "hda_codec: failed to override amp caps for NID 0x2\n");
19382}
19383
David Henningsson6cb3b702010-09-09 08:51:44 +020019384enum {
Daniel T Chen2df03512010-10-10 22:39:28 -040019385 ALC662_FIXUP_ASPIRE,
David Henningsson6cb3b702010-09-09 08:51:44 +020019386 ALC662_FIXUP_IDEAPAD,
Todd Broch6be79482010-12-07 16:51:05 -080019387 ALC272_FIXUP_MARIO,
David Henningsson6cb3b702010-09-09 08:51:44 +020019388};
19389
19390static const struct alc_fixup alc662_fixups[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019391 [ALC662_FIXUP_ASPIRE] = {
19392 .pins = (const struct alc_pincfg[]) {
19393 { 0x15, 0x99130112 }, /* subwoofer */
19394 { }
19395 }
19396 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019397 [ALC662_FIXUP_IDEAPAD] = {
19398 .pins = (const struct alc_pincfg[]) {
19399 { 0x17, 0x99130112 }, /* subwoofer */
19400 { }
19401 }
19402 },
Todd Broch6be79482010-12-07 16:51:05 -080019403 [ALC272_FIXUP_MARIO] = {
19404 .func = alc272_fixup_mario,
19405 }
David Henningsson6cb3b702010-09-09 08:51:44 +020019406};
19407
19408static struct snd_pci_quirk alc662_fixup_tbl[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019409 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
Daniel T Chena0e90ac2010-11-20 10:20:35 -050019410 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
Valentine Sinitsynd4118582010-10-01 22:24:08 +060019411 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
David Henningsson6cb3b702010-09-09 08:51:44 +020019412 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
19413 {}
19414};
19415
Todd Broch6be79482010-12-07 16:51:05 -080019416static const struct alc_model_fixup alc662_fixup_models[] = {
19417 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
19418 {}
19419};
David Henningsson6cb3b702010-09-09 08:51:44 +020019420
19421
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019422static int patch_alc662(struct hda_codec *codec)
19423{
19424 struct alc_spec *spec;
19425 int err, board_config;
Kailang Yang693194f2010-10-21 08:51:48 +020019426 int coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019427
19428 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19429 if (!spec)
19430 return -ENOMEM;
19431
19432 codec->spec = spec;
19433
Kailang Yangda00c242010-03-19 11:23:45 +010019434 alc_auto_parse_customize_define(codec);
19435
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020019436 alc_fix_pll_init(codec, 0x20, 0x04, 15);
19437
Kailang Yang693194f2010-10-21 08:51:48 +020019438 coef = alc_read_coef_idx(codec, 0);
19439 if (coef == 0x8020 || coef == 0x8011)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019440 alc_codec_rename(codec, "ALC661");
Kailang Yang693194f2010-10-21 08:51:48 +020019441 else if (coef & (1 << 14) &&
19442 codec->bus->pci->subsystem_vendor == 0x1025 &&
19443 spec->cdefine.platform_type == 1)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019444 alc_codec_rename(codec, "ALC272X");
Kailang Yang693194f2010-10-21 08:51:48 +020019445 else if (coef == 0x4011)
19446 alc_codec_rename(codec, "ALC656");
Kailang Yang274693f2009-12-03 10:07:50 +010019447
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019448 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19449 alc662_models,
19450 alc662_cfg_tbl);
19451 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019452 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19453 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019454 board_config = ALC662_AUTO;
19455 }
19456
19457 if (board_config == ALC662_AUTO) {
David Henningsson6cb3b702010-09-09 08:51:44 +020019458 alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019459 /* automatic parse from the BIOS config */
19460 err = alc662_parse_auto_config(codec);
19461 if (err < 0) {
19462 alc_free(codec);
19463 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019464 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019465 printk(KERN_INFO
19466 "hda_codec: Cannot set up configuration "
19467 "from BIOS. Using base mode...\n");
19468 board_config = ALC662_3ST_2ch_DIG;
19469 }
19470 }
19471
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019472 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019473 err = snd_hda_attach_beep_device(codec, 0x1);
19474 if (err < 0) {
19475 alc_free(codec);
19476 return err;
19477 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019478 }
19479
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019480 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019481 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019482
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019483 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19484 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19485
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019486 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19487 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19488
Takashi Iwaidd704692009-08-11 08:45:11 +020019489 if (!spec->adc_nids) {
19490 spec->adc_nids = alc662_adc_nids;
19491 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19492 }
19493 if (!spec->capsrc_nids)
19494 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019495
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019496 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019497 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019498
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019499 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019500 switch (codec->vendor_id) {
19501 case 0x10ec0662:
19502 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19503 break;
19504 case 0x10ec0272:
19505 case 0x10ec0663:
19506 case 0x10ec0665:
19507 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19508 break;
19509 case 0x10ec0273:
19510 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19511 break;
19512 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019513 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019514 spec->vmaster_nid = 0x02;
19515
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019516 codec->patch_ops = alc_patch_ops;
David Henningsson6cb3b702010-09-09 08:51:44 +020019517 if (board_config == ALC662_AUTO) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019518 spec->init_hook = alc662_auto_init;
Todd Broch6be79482010-12-07 16:51:05 -080019519 alc_pick_fixup_model(codec, alc662_fixup_models,
19520 alc662_fixup_tbl, alc662_fixups, 0);
David Henningsson6cb3b702010-09-09 08:51:44 +020019521 }
19522
Kailang Yangbf1b0222010-10-21 08:49:56 +020019523 alc_init_jacks(codec);
19524
Takashi Iwaicb53c622007-08-10 17:21:45 +020019525#ifdef CONFIG_SND_HDA_POWER_SAVE
19526 if (!spec->loopback.amplist)
19527 spec->loopback.amplist = alc662_loopbacks;
19528#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019529
19530 return 0;
19531}
19532
Kailang Yang274693f2009-12-03 10:07:50 +010019533static int patch_alc888(struct hda_codec *codec)
19534{
19535 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19536 kfree(codec->chip_name);
Kailang Yang01e0f132010-11-22 10:59:36 +010019537 if (codec->vendor_id == 0x10ec0887)
19538 codec->chip_name = kstrdup("ALC887-VD", GFP_KERNEL);
19539 else
19540 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019541 if (!codec->chip_name) {
19542 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019543 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019544 }
19545 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019546 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019547 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019548}
19549
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019550/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019551 * ALC680 support
19552 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019553#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019554#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19555#define alc680_modes alc260_modes
19556
19557static hda_nid_t alc680_dac_nids[3] = {
19558 /* Lout1, Lout2, hp */
19559 0x02, 0x03, 0x04
19560};
19561
19562static hda_nid_t alc680_adc_nids[3] = {
19563 /* ADC0-2 */
19564 /* DMIC, MIC, Line-in*/
19565 0x07, 0x08, 0x09
19566};
19567
Kailang Yangc69aefa2010-08-17 10:39:22 +020019568/*
19569 * Analog capture ADC cgange
19570 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019571static void alc680_rec_autoswitch(struct hda_codec *codec)
19572{
19573 struct alc_spec *spec = codec->spec;
19574 struct auto_pin_cfg *cfg = &spec->autocfg;
19575 int pin_found = 0;
19576 int type_found = AUTO_PIN_LAST;
19577 hda_nid_t nid;
19578 int i;
19579
19580 for (i = 0; i < cfg->num_inputs; i++) {
19581 nid = cfg->inputs[i].pin;
19582 if (!(snd_hda_query_pin_caps(codec, nid) &
19583 AC_PINCAP_PRES_DETECT))
19584 continue;
19585 if (snd_hda_jack_detect(codec, nid)) {
19586 if (cfg->inputs[i].type < type_found) {
19587 type_found = cfg->inputs[i].type;
19588 pin_found = nid;
19589 }
19590 }
19591 }
19592
19593 nid = 0x07;
19594 if (pin_found)
19595 snd_hda_get_connections(codec, pin_found, &nid, 1);
19596
19597 if (nid != spec->cur_adc)
19598 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19599 spec->cur_adc = nid;
19600 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19601 spec->cur_adc_format);
19602}
19603
Kailang Yangc69aefa2010-08-17 10:39:22 +020019604static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19605 struct hda_codec *codec,
19606 unsigned int stream_tag,
19607 unsigned int format,
19608 struct snd_pcm_substream *substream)
19609{
19610 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019611
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019612 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019613 spec->cur_adc_stream_tag = stream_tag;
19614 spec->cur_adc_format = format;
19615
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019616 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019617 return 0;
19618}
19619
19620static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19621 struct hda_codec *codec,
19622 struct snd_pcm_substream *substream)
19623{
19624 snd_hda_codec_cleanup_stream(codec, 0x07);
19625 snd_hda_codec_cleanup_stream(codec, 0x08);
19626 snd_hda_codec_cleanup_stream(codec, 0x09);
19627 return 0;
19628}
19629
19630static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19631 .substreams = 1, /* can be overridden */
19632 .channels_min = 2,
19633 .channels_max = 2,
19634 /* NID is set in alc_build_pcms */
19635 .ops = {
19636 .prepare = alc680_capture_pcm_prepare,
19637 .cleanup = alc680_capture_pcm_cleanup
19638 },
19639};
19640
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019641static struct snd_kcontrol_new alc680_base_mixer[] = {
19642 /* output mixer control */
19643 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19644 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19645 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19646 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010019647 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x12, 0, HDA_INPUT),
19648 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
19649 HDA_CODEC_VOLUME("Line In Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019650 { }
19651};
19652
Kailang Yangc69aefa2010-08-17 10:39:22 +020019653static struct hda_bind_ctls alc680_bind_cap_vol = {
19654 .ops = &snd_hda_bind_vol,
19655 .values = {
19656 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19657 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19658 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19659 0
19660 },
19661};
19662
19663static struct hda_bind_ctls alc680_bind_cap_switch = {
19664 .ops = &snd_hda_bind_sw,
19665 .values = {
19666 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19667 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19668 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19669 0
19670 },
19671};
19672
19673static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19674 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19675 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019676 { } /* end */
19677};
19678
19679/*
19680 * generic initialization of ADC, input mixers and output mixers
19681 */
19682static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019683 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19684 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19685 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019686
Kailang Yangc69aefa2010-08-17 10:39:22 +020019687 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19688 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19689 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19690 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19691 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19692 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019693
19694 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19695 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19696 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19697 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19698 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019699
19700 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19701 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019702 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019703
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019704 { }
19705};
19706
Kailang Yangc69aefa2010-08-17 10:39:22 +020019707/* toggle speaker-output according to the hp-jack state */
19708static void alc680_base_setup(struct hda_codec *codec)
19709{
19710 struct alc_spec *spec = codec->spec;
19711
19712 spec->autocfg.hp_pins[0] = 0x16;
19713 spec->autocfg.speaker_pins[0] = 0x14;
19714 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019715 spec->autocfg.num_inputs = 2;
19716 spec->autocfg.inputs[0].pin = 0x18;
19717 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19718 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019719 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019720}
19721
19722static void alc680_unsol_event(struct hda_codec *codec,
19723 unsigned int res)
19724{
19725 if ((res >> 26) == ALC880_HP_EVENT)
19726 alc_automute_amp(codec);
19727 if ((res >> 26) == ALC880_MIC_EVENT)
19728 alc680_rec_autoswitch(codec);
19729}
19730
19731static void alc680_inithook(struct hda_codec *codec)
19732{
19733 alc_automute_amp(codec);
19734 alc680_rec_autoswitch(codec);
19735}
19736
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019737/* create input playback/capture controls for the given pin */
19738static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19739 const char *ctlname, int idx)
19740{
19741 hda_nid_t dac;
19742 int err;
19743
19744 switch (nid) {
19745 case 0x14:
19746 dac = 0x02;
19747 break;
19748 case 0x15:
19749 dac = 0x03;
19750 break;
19751 case 0x16:
19752 dac = 0x04;
19753 break;
19754 default:
19755 return 0;
19756 }
19757 if (spec->multiout.dac_nids[0] != dac &&
19758 spec->multiout.dac_nids[1] != dac) {
19759 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19760 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19761 HDA_OUTPUT));
19762 if (err < 0)
19763 return err;
19764
19765 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19766 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19767
19768 if (err < 0)
19769 return err;
19770 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19771 }
19772
19773 return 0;
19774}
19775
19776/* add playback controls from the parsed DAC table */
19777static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19778 const struct auto_pin_cfg *cfg)
19779{
19780 hda_nid_t nid;
19781 int err;
19782
19783 spec->multiout.dac_nids = spec->private_dac_nids;
19784
19785 nid = cfg->line_out_pins[0];
19786 if (nid) {
19787 const char *name;
19788 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19789 name = "Speaker";
19790 else
19791 name = "Front";
19792 err = alc680_new_analog_output(spec, nid, name, 0);
19793 if (err < 0)
19794 return err;
19795 }
19796
19797 nid = cfg->speaker_pins[0];
19798 if (nid) {
19799 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19800 if (err < 0)
19801 return err;
19802 }
19803 nid = cfg->hp_pins[0];
19804 if (nid) {
19805 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19806 if (err < 0)
19807 return err;
19808 }
19809
19810 return 0;
19811}
19812
19813static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19814 hda_nid_t nid, int pin_type)
19815{
19816 alc_set_pin_output(codec, nid, pin_type);
19817}
19818
19819static void alc680_auto_init_multi_out(struct hda_codec *codec)
19820{
19821 struct alc_spec *spec = codec->spec;
19822 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19823 if (nid) {
19824 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19825 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19826 }
19827}
19828
19829static void alc680_auto_init_hp_out(struct hda_codec *codec)
19830{
19831 struct alc_spec *spec = codec->spec;
19832 hda_nid_t pin;
19833
19834 pin = spec->autocfg.hp_pins[0];
19835 if (pin)
19836 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19837 pin = spec->autocfg.speaker_pins[0];
19838 if (pin)
19839 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19840}
19841
19842/* pcm configuration: identical with ALC880 */
19843#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19844#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19845#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19846#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019847#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019848
19849/*
19850 * BIOS auto configuration
19851 */
19852static int alc680_parse_auto_config(struct hda_codec *codec)
19853{
19854 struct alc_spec *spec = codec->spec;
19855 int err;
19856 static hda_nid_t alc680_ignore[] = { 0 };
19857
19858 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19859 alc680_ignore);
19860 if (err < 0)
19861 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019862
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019863 if (!spec->autocfg.line_outs) {
19864 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19865 spec->multiout.max_channels = 2;
19866 spec->no_analog = 1;
19867 goto dig_only;
19868 }
19869 return 0; /* can't find valid BIOS pin config */
19870 }
19871 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19872 if (err < 0)
19873 return err;
19874
19875 spec->multiout.max_channels = 2;
19876
19877 dig_only:
19878 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019879 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019880 if (spec->kctls.list)
19881 add_mixer(spec, spec->kctls.list);
19882
19883 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019884
19885 err = alc_auto_add_mic_boost(codec);
19886 if (err < 0)
19887 return err;
19888
19889 return 1;
19890}
19891
19892#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19893
19894/* init callback for auto-configuration model -- overriding the default init */
19895static void alc680_auto_init(struct hda_codec *codec)
19896{
19897 struct alc_spec *spec = codec->spec;
19898 alc680_auto_init_multi_out(codec);
19899 alc680_auto_init_hp_out(codec);
19900 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019901 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019902 if (spec->unsol_event)
19903 alc_inithook(codec);
19904}
19905
19906/*
19907 * configuration and preset
19908 */
19909static const char *alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019910 [ALC680_BASE] = "base",
19911 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019912};
19913
19914static struct snd_pci_quirk alc680_cfg_tbl[] = {
19915 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19916 {}
19917};
19918
19919static struct alc_config_preset alc680_presets[] = {
19920 [ALC680_BASE] = {
19921 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019922 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019923 .init_verbs = { alc680_init_verbs },
19924 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19925 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019926 .dig_out_nid = ALC680_DIGOUT_NID,
19927 .num_channel_mode = ARRAY_SIZE(alc680_modes),
19928 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020019929 .unsol_event = alc680_unsol_event,
19930 .setup = alc680_base_setup,
19931 .init_hook = alc680_inithook,
19932
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019933 },
19934};
19935
19936static int patch_alc680(struct hda_codec *codec)
19937{
19938 struct alc_spec *spec;
19939 int board_config;
19940 int err;
19941
19942 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19943 if (spec == NULL)
19944 return -ENOMEM;
19945
19946 codec->spec = spec;
19947
19948 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
19949 alc680_models,
19950 alc680_cfg_tbl);
19951
19952 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
19953 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19954 codec->chip_name);
19955 board_config = ALC680_AUTO;
19956 }
19957
19958 if (board_config == ALC680_AUTO) {
19959 /* automatic parse from the BIOS config */
19960 err = alc680_parse_auto_config(codec);
19961 if (err < 0) {
19962 alc_free(codec);
19963 return err;
19964 } else if (!err) {
19965 printk(KERN_INFO
19966 "hda_codec: Cannot set up configuration "
19967 "from BIOS. Using base mode...\n");
19968 board_config = ALC680_BASE;
19969 }
19970 }
19971
19972 if (board_config != ALC680_AUTO)
19973 setup_preset(codec, &alc680_presets[board_config]);
19974
19975 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019976 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019977 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019978 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019979
19980 if (!spec->adc_nids) {
19981 spec->adc_nids = alc680_adc_nids;
19982 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
19983 }
19984
19985 if (!spec->cap_mixer)
19986 set_capture_mixer(codec);
19987
19988 spec->vmaster_nid = 0x02;
19989
19990 codec->patch_ops = alc_patch_ops;
19991 if (board_config == ALC680_AUTO)
19992 spec->init_hook = alc680_auto_init;
19993
19994 return 0;
19995}
19996
19997/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070019998 * patch entries
19999 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010020000static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070020001 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020002 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020003 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020020004 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020005 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020006 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020020007 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020008 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020009 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020010 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020011 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
20012 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
20013 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020014 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020015 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020016 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
20017 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020020018 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010020019 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010020020 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020021 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020022 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020023 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020024 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020020025 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020026 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020020027 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020028 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020029 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yang01e0f132010-11-22 10:59:36 +010020030 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc888 },
Kailang Yang44426082008-10-15 11:18:05 +020020031 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020032 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020033 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020034 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020035 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020036 {} /* terminator */
20037};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010020038
20039MODULE_ALIAS("snd-hda-codec-id:10ec*");
20040
20041MODULE_LICENSE("GPL");
20042MODULE_DESCRIPTION("Realtek HD-audio codec");
20043
20044static struct hda_codec_preset_list realtek_list = {
20045 .preset = snd_hda_preset_realtek,
20046 .owner = THIS_MODULE,
20047};
20048
20049static int __init patch_realtek_init(void)
20050{
20051 return snd_hda_add_codec_preset(&realtek_list);
20052}
20053
20054static void __exit patch_realtek_exit(void)
20055{
20056 snd_hda_delete_codec_preset(&realtek_list);
20057}
20058
20059module_init(patch_realtek_init)
20060module_exit(patch_realtek_exit)