blob: 4abe3da1240c7763d79d878518a8b6d7bc25c270 [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,
Kailang Yangea1fb292008-08-26 12:58:38 +0200234 ALC883_MEDION_MD2,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +0200235 ALC883_MEDION_WIM2160,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100236 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200237 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200238 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200239 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200240 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200241 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200242 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100243 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100244 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430245 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100246 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100247 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800248 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200249 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200250 ALC889A_INTEL,
251 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200252 ALC888_ASUS_M90V,
253 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200254 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100255 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200256 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200257 ALC882_AUTO,
258 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200259};
260
Takashi Iwaid4a86d82010-06-23 17:51:26 +0200261/* ALC680 models */
262enum {
263 ALC680_BASE,
264 ALC680_AUTO,
265 ALC680_MODEL_LAST,
266};
267
Kailang Yangdf694da2005-12-05 19:42:22 +0100268/* for GPIO Poll */
269#define GPIO_MASK 0x03
270
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200271/* extra amp-initialization sequence types */
272enum {
273 ALC_INIT_NONE,
274 ALC_INIT_DEFAULT,
275 ALC_INIT_GPIO1,
276 ALC_INIT_GPIO2,
277 ALC_INIT_GPIO3,
278};
279
Takashi Iwai6c819492009-08-10 18:47:44 +0200280struct alc_mic_route {
281 hda_nid_t pin;
282 unsigned char mux_idx;
283 unsigned char amix_idx;
284};
285
Kailang Yang9ad0e492010-09-14 23:22:00 +0200286struct alc_jack {
287 hda_nid_t nid;
288 int type;
289 struct snd_jack *jack;
290};
291
Takashi Iwai6c819492009-08-10 18:47:44 +0200292#define MUX_IDX_UNDEF ((unsigned char)-1)
293
Kailang Yangda00c242010-03-19 11:23:45 +0100294struct alc_customize_define {
295 unsigned int sku_cfg;
296 unsigned char port_connectivity;
297 unsigned char check_sum;
298 unsigned char customization;
299 unsigned char external_amp;
300 unsigned int enable_pcbeep:1;
301 unsigned int platform_type:1;
302 unsigned int swap:1;
303 unsigned int override:1;
304};
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
1090 err = alc_add_jack(codec, hp_nid, SND_JACK_HEADPHONE);
1091 if (err < 0)
1092 return err;
1093 alc_report_jack(codec, hp_nid);
1094
1095 err = alc_add_jack(codec, mic_nid, SND_JACK_MICROPHONE);
1096 if (err < 0)
1097 return err;
1098 alc_report_jack(codec, mic_nid);
1099
1100 return 0;
1101}
1102#else
1103static inline void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1104{
1105}
1106
1107static inline int alc_init_jacks(struct hda_codec *codec)
1108{
1109 return 0;
1110}
1111#endif
1112
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001113static void alc_automute_speaker(struct hda_codec *codec, int pinctl)
Kailang Yangc9b58002007-10-16 14:30:01 +02001114{
1115 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001116 unsigned int mute;
1117 hda_nid_t nid;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001118 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +02001119
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001120 spec->jack_present = 0;
1121 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1122 nid = spec->autocfg.hp_pins[i];
1123 if (!nid)
1124 break;
1125 if (snd_hda_jack_detect(codec, nid)) {
1126 spec->jack_present = 1;
1127 break;
1128 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001129 alc_report_jack(codec, spec->autocfg.hp_pins[i]);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001130 }
1131
1132 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1133 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001134 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1135 nid = spec->autocfg.speaker_pins[i];
1136 if (!nid)
1137 break;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001138 if (pinctl) {
1139 snd_hda_codec_write(codec, nid, 0,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001140 AC_VERB_SET_PIN_WIDGET_CONTROL,
1141 spec->jack_present ? 0 : PIN_OUT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001142 } else {
1143 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1144 HDA_AMP_MUTE, mute);
1145 }
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001146 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001147}
1148
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001149static void alc_automute_pin(struct hda_codec *codec)
1150{
1151 alc_automute_speaker(codec, 1);
1152}
1153
Takashi Iwai6c819492009-08-10 18:47:44 +02001154static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1155 hda_nid_t nid)
1156{
1157 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1158 int i, nums;
1159
1160 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1161 for (i = 0; i < nums; i++)
1162 if (conn[i] == nid)
1163 return i;
1164 return -1;
1165}
1166
Takashi Iwai840b64c2010-07-13 22:49:01 +02001167/* switch the current ADC according to the jack state */
1168static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1169{
1170 struct alc_spec *spec = codec->spec;
1171 unsigned int present;
1172 hda_nid_t new_adc;
1173
1174 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1175 if (present)
1176 spec->cur_adc_idx = 1;
1177 else
1178 spec->cur_adc_idx = 0;
1179 new_adc = spec->adc_nids[spec->cur_adc_idx];
1180 if (spec->cur_adc && spec->cur_adc != new_adc) {
1181 /* stream is running, let's swap the current ADC */
Takashi Iwaif0cea792010-08-13 11:56:53 +02001182 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
Takashi Iwai840b64c2010-07-13 22:49:01 +02001183 spec->cur_adc = new_adc;
1184 snd_hda_codec_setup_stream(codec, new_adc,
1185 spec->cur_adc_stream_tag, 0,
1186 spec->cur_adc_format);
1187 }
1188}
1189
Kailang Yang7fb0d782008-10-15 11:12:35 +02001190static void alc_mic_automute(struct hda_codec *codec)
1191{
1192 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001193 struct alc_mic_route *dead, *alive;
1194 unsigned int present, type;
1195 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001196
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001197 if (!spec->auto_mic)
1198 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001199 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1200 return;
1201 if (snd_BUG_ON(!spec->adc_nids))
1202 return;
1203
Takashi Iwai840b64c2010-07-13 22:49:01 +02001204 if (spec->dual_adc_switch) {
1205 alc_dual_mic_adc_auto_switch(codec);
1206 return;
1207 }
1208
Takashi Iwai6c819492009-08-10 18:47:44 +02001209 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1210
Wu Fengguang864f92b2009-11-18 12:38:02 +08001211 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001212 if (present) {
1213 alive = &spec->ext_mic;
1214 dead = &spec->int_mic;
1215 } else {
1216 alive = &spec->int_mic;
1217 dead = &spec->ext_mic;
1218 }
1219
Takashi Iwai6c819492009-08-10 18:47:44 +02001220 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1221 if (type == AC_WID_AUD_MIX) {
1222 /* Matrix-mixer style (e.g. ALC882) */
1223 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1224 alive->mux_idx,
1225 HDA_AMP_MUTE, 0);
1226 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1227 dead->mux_idx,
1228 HDA_AMP_MUTE, HDA_AMP_MUTE);
1229 } else {
1230 /* MUX style (e.g. ALC880) */
1231 snd_hda_codec_write_cache(codec, cap_nid, 0,
1232 AC_VERB_SET_CONNECT_SEL,
1233 alive->mux_idx);
1234 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001235 alc_report_jack(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001236
1237 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001238}
1239
Kailang Yangc9b58002007-10-16 14:30:01 +02001240/* unsolicited event for HP jack sensing */
1241static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1242{
1243 if (codec->vendor_id == 0x10ec0880)
1244 res >>= 28;
1245 else
1246 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001247 switch (res) {
1248 case ALC880_HP_EVENT:
1249 alc_automute_pin(codec);
1250 break;
1251 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001252 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001253 break;
1254 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001255}
1256
1257static void alc_inithook(struct hda_codec *codec)
1258{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001259 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001260 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001261}
1262
Kailang Yangf9423e72008-05-27 12:32:25 +02001263/* additional initialization for ALC888 variants */
1264static void alc888_coef_init(struct hda_codec *codec)
1265{
1266 unsigned int tmp;
1267
1268 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1269 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1270 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001271 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001272 /* alc888S-VC */
1273 snd_hda_codec_read(codec, 0x20, 0,
1274 AC_VERB_SET_PROC_COEF, 0x830);
1275 else
1276 /* alc888-VB */
1277 snd_hda_codec_read(codec, 0x20, 0,
1278 AC_VERB_SET_PROC_COEF, 0x3030);
1279}
1280
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001281static void alc889_coef_init(struct hda_codec *codec)
1282{
1283 unsigned int tmp;
1284
1285 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1286 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1287 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1288 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1289}
1290
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001291/* turn on/off EAPD control (only if available) */
1292static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1293{
1294 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1295 return;
1296 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1297 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1298 on ? 2 : 0);
1299}
1300
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001301static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001302{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001303 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001304
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001305 switch (type) {
1306 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001307 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1308 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001309 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001310 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1311 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001312 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001313 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1314 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001315 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001316 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001317 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001318 set_eapd(codec, 0x0f, 1);
1319 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001320 break;
1321 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001322 case 0x10ec0267:
1323 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001324 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001325 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001326 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001327 case 0x10ec0660:
1328 case 0x10ec0662:
1329 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001330 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001331 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001332 set_eapd(codec, 0x14, 1);
1333 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001334 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001335 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001336 switch (codec->vendor_id) {
1337 case 0x10ec0260:
1338 snd_hda_codec_write(codec, 0x1a, 0,
1339 AC_VERB_SET_COEF_INDEX, 7);
1340 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1341 AC_VERB_GET_PROC_COEF, 0);
1342 snd_hda_codec_write(codec, 0x1a, 0,
1343 AC_VERB_SET_COEF_INDEX, 7);
1344 snd_hda_codec_write(codec, 0x1a, 0,
1345 AC_VERB_SET_PROC_COEF,
1346 tmp | 0x2010);
1347 break;
1348 case 0x10ec0262:
1349 case 0x10ec0880:
1350 case 0x10ec0882:
1351 case 0x10ec0883:
1352 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001353 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001354 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001355 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001356 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001357 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001358 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001359 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001360#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001361 case 0x10ec0267:
1362 case 0x10ec0268:
1363 snd_hda_codec_write(codec, 0x20, 0,
1364 AC_VERB_SET_COEF_INDEX, 7);
1365 tmp = snd_hda_codec_read(codec, 0x20, 0,
1366 AC_VERB_GET_PROC_COEF, 0);
1367 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001368 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001369 snd_hda_codec_write(codec, 0x20, 0,
1370 AC_VERB_SET_PROC_COEF,
1371 tmp | 0x3000);
1372 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001373#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001374 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001375 break;
1376 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001377}
Kailang Yangea1fb292008-08-26 12:58:38 +02001378
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001379static void alc_init_auto_hp(struct hda_codec *codec)
1380{
1381 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001382 struct auto_pin_cfg *cfg = &spec->autocfg;
1383 int i;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001384
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001385 if (!cfg->hp_pins[0]) {
1386 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001387 return;
1388 }
1389
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001390 if (!cfg->speaker_pins[0]) {
1391 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
1392 return;
1393 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1394 sizeof(cfg->speaker_pins));
1395 cfg->speaker_outs = cfg->line_outs;
1396 }
1397
1398 if (!cfg->hp_pins[0]) {
1399 memcpy(cfg->hp_pins, cfg->line_out_pins,
1400 sizeof(cfg->hp_pins));
1401 cfg->hp_outs = cfg->line_outs;
1402 }
1403
1404 for (i = 0; i < cfg->hp_outs; i++) {
1405 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1406 cfg->hp_pins[i]);
1407 snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0,
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001408 AC_VERB_SET_UNSOLICITED_ENABLE,
1409 AC_USRSP_EN | ALC880_HP_EVENT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001410 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001411 spec->unsol_event = alc_sku_unsol_event;
1412}
1413
Takashi Iwai6c819492009-08-10 18:47:44 +02001414static void alc_init_auto_mic(struct hda_codec *codec)
1415{
1416 struct alc_spec *spec = codec->spec;
1417 struct auto_pin_cfg *cfg = &spec->autocfg;
1418 hda_nid_t fixed, ext;
1419 int i;
1420
1421 /* there must be only two mic inputs exclusively */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001422 for (i = 0; i < cfg->num_inputs; i++)
Takashi Iwai86e29592010-09-09 14:50:17 +02001423 if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
Takashi Iwai6c819492009-08-10 18:47:44 +02001424 return;
1425
1426 fixed = ext = 0;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001427 for (i = 0; i < cfg->num_inputs; i++) {
1428 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai6c819492009-08-10 18:47:44 +02001429 unsigned int defcfg;
Takashi Iwai6c819492009-08-10 18:47:44 +02001430 defcfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001431 switch (snd_hda_get_input_pin_attr(defcfg)) {
1432 case INPUT_PIN_ATTR_INT:
Takashi Iwai6c819492009-08-10 18:47:44 +02001433 if (fixed)
1434 return; /* already occupied */
1435 fixed = nid;
1436 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001437 case INPUT_PIN_ATTR_UNUSED:
1438 return; /* invalid entry */
1439 default:
Takashi Iwai6c819492009-08-10 18:47:44 +02001440 if (ext)
1441 return; /* already occupied */
1442 ext = nid;
1443 break;
Takashi Iwai6c819492009-08-10 18:47:44 +02001444 }
1445 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001446 if (!ext || !fixed)
1447 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001448 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1449 return; /* no unsol support */
1450 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1451 ext, fixed);
1452 spec->ext_mic.pin = ext;
1453 spec->int_mic.pin = fixed;
1454 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1455 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1456 spec->auto_mic = 1;
1457 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1458 AC_VERB_SET_UNSOLICITED_ENABLE,
1459 AC_USRSP_EN | ALC880_MIC_EVENT);
1460 spec->unsol_event = alc_sku_unsol_event;
1461}
1462
Kailang Yangda00c242010-03-19 11:23:45 +01001463static int alc_auto_parse_customize_define(struct hda_codec *codec)
1464{
1465 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001466 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001467 struct alc_spec *spec = codec->spec;
1468
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001469 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1470
Kailang Yangda00c242010-03-19 11:23:45 +01001471 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001472 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +01001473 goto do_sku;
1474
1475 nid = 0x1d;
1476 if (codec->vendor_id == 0x10ec0260)
1477 nid = 0x17;
1478 ass = snd_hda_codec_get_pincfg(codec, nid);
1479
1480 if (!(ass & 1)) {
1481 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1482 codec->chip_name, ass);
1483 return -1;
1484 }
1485
1486 /* check sum */
1487 tmp = 0;
1488 for (i = 1; i < 16; i++) {
1489 if ((ass >> i) & 1)
1490 tmp++;
1491 }
1492 if (((ass >> 16) & 0xf) != tmp)
1493 return -1;
1494
1495 spec->cdefine.port_connectivity = ass >> 30;
1496 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1497 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1498 spec->cdefine.customization = ass >> 8;
1499do_sku:
1500 spec->cdefine.sku_cfg = ass;
1501 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1502 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1503 spec->cdefine.swap = (ass & 0x2) >> 1;
1504 spec->cdefine.override = ass & 0x1;
1505
1506 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1507 nid, spec->cdefine.sku_cfg);
1508 snd_printd("SKU: port_connectivity=0x%x\n",
1509 spec->cdefine.port_connectivity);
1510 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1511 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1512 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1513 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1514 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1515 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1516 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1517
1518 return 0;
1519}
1520
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001521/* check subsystem ID and set up device-specific initialization;
1522 * return 1 if initialized, 0 if invalid SSID
1523 */
1524/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1525 * 31 ~ 16 : Manufacture ID
1526 * 15 ~ 8 : SKU ID
1527 * 7 ~ 0 : Assembly ID
1528 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1529 */
1530static int alc_subsystem_id(struct hda_codec *codec,
1531 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001532 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001533{
1534 unsigned int ass, tmp, i;
1535 unsigned nid;
1536 struct alc_spec *spec = codec->spec;
1537
1538 ass = codec->subsystem_id & 0xffff;
1539 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1540 goto do_sku;
1541
1542 /* invalid SSID, check the special NID pin defcfg instead */
1543 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001544 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001545 * 29~21 : reserve
1546 * 20 : PCBEEP input
1547 * 19~16 : Check sum (15:1)
1548 * 15~1 : Custom
1549 * 0 : override
1550 */
1551 nid = 0x1d;
1552 if (codec->vendor_id == 0x10ec0260)
1553 nid = 0x17;
1554 ass = snd_hda_codec_get_pincfg(codec, nid);
1555 snd_printd("realtek: No valid SSID, "
1556 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001557 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001558 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001559 return 0;
1560 if ((ass >> 30) != 1) /* no physical connection */
1561 return 0;
1562
1563 /* check sum */
1564 tmp = 0;
1565 for (i = 1; i < 16; i++) {
1566 if ((ass >> i) & 1)
1567 tmp++;
1568 }
1569 if (((ass >> 16) & 0xf) != tmp)
1570 return 0;
1571do_sku:
1572 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1573 ass & 0xffff, codec->vendor_id);
1574 /*
1575 * 0 : override
1576 * 1 : Swap Jack
1577 * 2 : 0 --> Desktop, 1 --> Laptop
1578 * 3~5 : External Amplifier control
1579 * 7~6 : Reserved
1580 */
1581 tmp = (ass & 0x38) >> 3; /* external Amp control */
1582 switch (tmp) {
1583 case 1:
1584 spec->init_amp = ALC_INIT_GPIO1;
1585 break;
1586 case 3:
1587 spec->init_amp = ALC_INIT_GPIO2;
1588 break;
1589 case 7:
1590 spec->init_amp = ALC_INIT_GPIO3;
1591 break;
1592 case 5:
1593 spec->init_amp = ALC_INIT_DEFAULT;
1594 break;
1595 }
1596
1597 /* is laptop or Desktop and enable the function "Mute internal speaker
1598 * when the external headphone out jack is plugged"
1599 */
1600 if (!(ass & 0x8000))
1601 return 1;
1602 /*
1603 * 10~8 : Jack location
1604 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1605 * 14~13: Resvered
1606 * 15 : 1 --> enable the function "Mute internal speaker
1607 * when the external headphone out jack is plugged"
1608 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001609 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001610 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001611 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1612 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001613 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001614 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001615 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001616 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001617 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001618 else if (tmp == 3)
1619 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001620 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001621 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001622 for (i = 0; i < spec->autocfg.line_outs; i++)
1623 if (spec->autocfg.line_out_pins[i] == nid)
1624 return 1;
1625 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001626 }
1627
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001628 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001629 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001630 return 1;
1631}
Kailang Yangea1fb292008-08-26 12:58:38 +02001632
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001633static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001634 hda_nid_t porta, hda_nid_t porte,
1635 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001636{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001637 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001638 struct alc_spec *spec = codec->spec;
1639 snd_printd("realtek: "
1640 "Enable default setup for auto mode as fallback\n");
1641 spec->init_amp = ALC_INIT_DEFAULT;
1642 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001643 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001644 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001645}
1646
Takashi Iwai41e41f12005-06-08 14:48:49 +02001647/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001648 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001649 */
1650
1651struct alc_pincfg {
1652 hda_nid_t nid;
1653 u32 val;
1654};
1655
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001656struct alc_fixup {
1657 const struct alc_pincfg *pins;
1658 const struct hda_verb *verbs;
1659};
1660
1661static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001662 const struct snd_pci_quirk *quirk,
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001663 const struct alc_fixup *fix,
1664 int pre_init)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001665{
1666 const struct alc_pincfg *cfg;
1667
1668 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1669 if (!quirk)
1670 return;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001671 fix += quirk->value;
1672 cfg = fix->pins;
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001673 if (pre_init && cfg) {
1674#ifdef CONFIG_SND_DEBUG_VERBOSE
1675 snd_printdd(KERN_INFO "hda_codec: %s: Apply pincfg for %s\n",
1676 codec->chip_name, quirk->name);
1677#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001678 for (; cfg->nid; cfg++)
1679 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1680 }
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001681 if (!pre_init && fix->verbs) {
1682#ifdef CONFIG_SND_DEBUG_VERBOSE
1683 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-verbs for %s\n",
1684 codec->chip_name, quirk->name);
1685#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001686 add_verb(codec->spec, fix->verbs);
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001687 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001688}
1689
Kailang Yang274693f2009-12-03 10:07:50 +01001690static int alc_read_coef_idx(struct hda_codec *codec,
1691 unsigned int coef_idx)
1692{
1693 unsigned int val;
1694 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1695 coef_idx);
1696 val = snd_hda_codec_read(codec, 0x20, 0,
1697 AC_VERB_GET_PROC_COEF, 0);
1698 return val;
1699}
1700
Kailang Yang977ddd62010-09-15 10:02:29 +02001701static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1702 unsigned int coef_val)
1703{
1704 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1705 coef_idx);
1706 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1707 coef_val);
1708}
1709
Takashi Iwai757899a2010-07-30 10:48:14 +02001710/* set right pin controls for digital I/O */
1711static void alc_auto_init_digital(struct hda_codec *codec)
1712{
1713 struct alc_spec *spec = codec->spec;
1714 int i;
1715 hda_nid_t pin;
1716
1717 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1718 pin = spec->autocfg.dig_out_pins[i];
1719 if (pin) {
1720 snd_hda_codec_write(codec, pin, 0,
1721 AC_VERB_SET_PIN_WIDGET_CONTROL,
1722 PIN_OUT);
1723 }
1724 }
1725 pin = spec->autocfg.dig_in_pin;
1726 if (pin)
1727 snd_hda_codec_write(codec, pin, 0,
1728 AC_VERB_SET_PIN_WIDGET_CONTROL,
1729 PIN_IN);
1730}
1731
1732/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1733static void alc_auto_parse_digital(struct hda_codec *codec)
1734{
1735 struct alc_spec *spec = codec->spec;
1736 int i, err;
1737 hda_nid_t dig_nid;
1738
1739 /* support multiple SPDIFs; the secondary is set up as a slave */
1740 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1741 err = snd_hda_get_connections(codec,
1742 spec->autocfg.dig_out_pins[i],
1743 &dig_nid, 1);
1744 if (err < 0)
1745 continue;
1746 if (!i) {
1747 spec->multiout.dig_out_nid = dig_nid;
1748 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1749 } else {
1750 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1751 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1752 break;
1753 spec->slave_dig_outs[i - 1] = dig_nid;
1754 }
1755 }
1756
1757 if (spec->autocfg.dig_in_pin) {
1758 hda_nid_t dig_nid;
1759 err = snd_hda_get_connections(codec,
1760 spec->autocfg.dig_in_pin,
1761 &dig_nid, 1);
1762 if (err > 0)
1763 spec->dig_in_nid = dig_nid;
1764 }
1765}
1766
Takashi Iwaif95474e2007-07-10 00:47:43 +02001767/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001768 * ALC888
1769 */
1770
1771/*
1772 * 2ch mode
1773 */
1774static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1775/* Mic-in jack as mic in */
1776 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1777 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1778/* Line-in jack as Line in */
1779 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1780 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1781/* Line-Out as Front */
1782 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1783 { } /* end */
1784};
1785
1786/*
1787 * 4ch mode
1788 */
1789static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1790/* Mic-in jack as mic in */
1791 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1792 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1793/* Line-in jack as Surround */
1794 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1795 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1796/* Line-Out as Front */
1797 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1798 { } /* end */
1799};
1800
1801/*
1802 * 6ch mode
1803 */
1804static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1805/* Mic-in jack as CLFE */
1806 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1807 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1808/* Line-in jack as Surround */
1809 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1810 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1811/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1812 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1813 { } /* end */
1814};
1815
1816/*
1817 * 8ch mode
1818 */
1819static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1820/* Mic-in jack as CLFE */
1821 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1822 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1823/* Line-in jack as Surround */
1824 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1825 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1826/* Line-Out as Side */
1827 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1828 { } /* end */
1829};
1830
1831static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1832 { 2, alc888_4ST_ch2_intel_init },
1833 { 4, alc888_4ST_ch4_intel_init },
1834 { 6, alc888_4ST_ch6_intel_init },
1835 { 8, alc888_4ST_ch8_intel_init },
1836};
1837
1838/*
1839 * ALC888 Fujitsu Siemens Amillo xa3530
1840 */
1841
1842static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1843/* Front Mic: set to PIN_IN (empty by default) */
1844 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1845/* Connect Internal HP to Front */
1846 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1847 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1848 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1849/* Connect Bass HP to Front */
1850 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1851 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1852 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1853/* Connect Line-Out side jack (SPDIF) to Side */
1854 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1855 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1856 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1857/* Connect Mic jack to CLFE */
1858 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1859 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1860 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1861/* Connect Line-in jack to Surround */
1862 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1863 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1864 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1865/* Connect HP out jack to Front */
1866 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1867 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1868 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1869/* Enable unsolicited event for HP jack and Line-out jack */
1870 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1871 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1872 {}
1873};
1874
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001875static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001876{
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001877 alc_automute_speaker(codec, 0);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001878}
1879
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001880static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1881 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001882{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001883 if (codec->vendor_id == 0x10ec0880)
1884 res >>= 28;
1885 else
1886 res >>= 26;
1887 if (res == ALC880_HP_EVENT)
1888 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001889}
1890
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001891static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001892{
1893 struct alc_spec *spec = codec->spec;
1894
1895 spec->autocfg.hp_pins[0] = 0x15;
1896 spec->autocfg.speaker_pins[0] = 0x14;
1897 spec->autocfg.speaker_pins[1] = 0x16;
1898 spec->autocfg.speaker_pins[2] = 0x17;
1899 spec->autocfg.speaker_pins[3] = 0x19;
1900 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001901}
1902
1903static void alc889_intel_init_hook(struct hda_codec *codec)
1904{
1905 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001906 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001907}
1908
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001909static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001910{
1911 struct alc_spec *spec = codec->spec;
1912
1913 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1914 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1915 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1916 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001917}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001918
1919/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001920 * ALC888 Acer Aspire 4930G model
1921 */
1922
1923static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1924/* Front Mic: set to PIN_IN (empty by default) */
1925 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1926/* Unselect Front Mic by default in input mixer 3 */
1927 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001928/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001929 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1930/* Connect Internal HP to front */
1931 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1932 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1933 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1934/* Connect HP out to front */
1935 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1936 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1937 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1938 { }
1939};
1940
Hector Martin3b315d72009-06-02 10:54:19 +02001941/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001942 * ALC888 Acer Aspire 6530G model
1943 */
1944
1945static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01001946/* Route to built-in subwoofer as well as speakers */
1947 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1948 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1949 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1950 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001951/* Bias voltage on for external mic port */
1952 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001953/* Front Mic: set to PIN_IN (empty by default) */
1954 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1955/* Unselect Front Mic by default in input mixer 3 */
1956 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001957/* Enable unsolicited event for HP jack */
1958 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1959/* Enable speaker output */
1960 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1961 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01001962 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001963/* Enable headphone output */
1964 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1965 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1966 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01001967 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001968 { }
1969};
1970
1971/*
Hector Martin018df412009-06-04 00:13:40 +02001972 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001973 */
1974
Hector Martin018df412009-06-04 00:13:40 +02001975static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001976/* Front Mic: set to PIN_IN (empty by default) */
1977 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1978/* Unselect Front Mic by default in input mixer 3 */
1979 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1980/* Enable unsolicited event for HP jack */
1981 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1982/* Connect Internal Front to Front */
1983 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1984 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1985 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1986/* Connect Internal Rear to Rear */
1987 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1988 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1989 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1990/* Connect Internal CLFE to CLFE */
1991 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1992 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1993 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1994/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001995 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001996 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1997 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1998/* Enable all DACs */
1999/* DAC DISABLE/MUTE 1? */
2000/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
2001 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
2002 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2003/* DAC DISABLE/MUTE 2? */
2004/* some bit here disables the other DACs. Init=0x4900 */
2005 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
2006 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02002007/* DMIC fix
2008 * This laptop has a stereo digital microphone. The mics are only 1cm apart
2009 * which makes the stereo useless. However, either the mic or the ALC889
2010 * makes the signal become a difference/sum signal instead of standard
2011 * stereo, which is annoying. So instead we flip this bit which makes the
2012 * codec replicate the sum signal to both channels, turning it into a
2013 * normal mono mic.
2014 */
2015/* DMIC_CONTROL? Init value = 0x0001 */
2016 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
2017 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02002018 { }
2019};
2020
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002021static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002022 /* Front mic only available on one ADC */
2023 {
2024 .num_items = 4,
2025 .items = {
2026 { "Mic", 0x0 },
2027 { "Line", 0x2 },
2028 { "CD", 0x4 },
2029 { "Front Mic", 0xb },
2030 },
2031 },
2032 {
2033 .num_items = 3,
2034 .items = {
2035 { "Mic", 0x0 },
2036 { "Line", 0x2 },
2037 { "CD", 0x4 },
2038 },
2039 }
2040};
2041
Tony Vroond2fd4b02009-06-21 00:40:10 +01002042static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2043 /* Interal mic only available on one ADC */
2044 {
Tony Vroon684a8842009-06-26 09:27:50 +01002045 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002046 .items = {
2047 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002048 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002049 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002050 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002051 { "Int Mic", 0xb },
2052 },
2053 },
2054 {
Tony Vroon684a8842009-06-26 09:27:50 +01002055 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002056 .items = {
2057 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002058 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002059 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002060 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002061 },
2062 }
2063};
2064
Hector Martin018df412009-06-04 00:13:40 +02002065static struct hda_input_mux alc889_capture_sources[3] = {
2066 /* Digital mic only available on first "ADC" */
2067 {
2068 .num_items = 5,
2069 .items = {
2070 { "Mic", 0x0 },
2071 { "Line", 0x2 },
2072 { "CD", 0x4 },
2073 { "Front Mic", 0xb },
2074 { "Input Mix", 0xa },
2075 },
2076 },
2077 {
2078 .num_items = 4,
2079 .items = {
2080 { "Mic", 0x0 },
2081 { "Line", 0x2 },
2082 { "CD", 0x4 },
2083 { "Input Mix", 0xa },
2084 },
2085 },
2086 {
2087 .num_items = 4,
2088 .items = {
2089 { "Mic", 0x0 },
2090 { "Line", 0x2 },
2091 { "CD", 0x4 },
2092 { "Input Mix", 0xa },
2093 },
2094 }
2095};
2096
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002097static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002098 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2099 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2100 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2101 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2102 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2103 HDA_OUTPUT),
2104 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2105 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2106 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2107 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2108 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2109 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2110 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2111 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2112 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2113 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2114 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2115 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002116 { } /* end */
2117};
2118
Hector Martin556eea92009-12-20 22:51:23 +01002119static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2120 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2121 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2122 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2123 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2124 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2125 HDA_OUTPUT),
2126 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2127 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2128 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2129 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2130 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2131 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2132 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2133 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2134 { } /* end */
2135};
2136
2137
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002138static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002139{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002140 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002141
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002142 spec->autocfg.hp_pins[0] = 0x15;
2143 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01002144 spec->autocfg.speaker_pins[1] = 0x16;
2145 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002146}
2147
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002148static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02002149{
2150 struct alc_spec *spec = codec->spec;
2151
2152 spec->autocfg.hp_pins[0] = 0x15;
2153 spec->autocfg.speaker_pins[0] = 0x14;
2154 spec->autocfg.speaker_pins[1] = 0x16;
2155 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02002156}
2157
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002158static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02002159{
2160 struct alc_spec *spec = codec->spec;
2161
2162 spec->autocfg.hp_pins[0] = 0x15;
2163 spec->autocfg.speaker_pins[0] = 0x14;
2164 spec->autocfg.speaker_pins[1] = 0x16;
2165 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02002166}
2167
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002168/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002169 * ALC880 3-stack model
2170 *
2171 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002172 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2173 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07002174 */
2175
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002176static hda_nid_t alc880_dac_nids[4] = {
2177 /* front, rear, clfe, rear_surr */
2178 0x02, 0x05, 0x04, 0x03
2179};
2180
2181static hda_nid_t alc880_adc_nids[3] = {
2182 /* ADC0-2 */
2183 0x07, 0x08, 0x09,
2184};
2185
2186/* The datasheet says the node 0x07 is connected from inputs,
2187 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01002188 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07002189 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002190static hda_nid_t alc880_adc_nids_alt[2] = {
2191 /* ADC1-2 */
2192 0x08, 0x09,
2193};
2194
2195#define ALC880_DIGOUT_NID 0x06
2196#define ALC880_DIGIN_NID 0x0a
2197
2198static struct hda_input_mux alc880_capture_source = {
2199 .num_items = 4,
2200 .items = {
2201 { "Mic", 0x0 },
2202 { "Front Mic", 0x3 },
2203 { "Line", 0x2 },
2204 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002205 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002206};
2207
2208/* channel source setting (2/6 channel selection for 3-stack) */
2209/* 2ch mode */
2210static struct hda_verb alc880_threestack_ch2_init[] = {
2211 /* set line-in to input, mute it */
2212 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2213 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2214 /* set mic-in to input vref 80%, mute it */
2215 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2216 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002217 { } /* end */
2218};
2219
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002220/* 6ch mode */
2221static struct hda_verb alc880_threestack_ch6_init[] = {
2222 /* set line-in to output, unmute it */
2223 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2224 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2225 /* set mic-in to output, unmute it */
2226 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2227 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2228 { } /* end */
2229};
2230
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002231static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002232 { 2, alc880_threestack_ch2_init },
2233 { 6, alc880_threestack_ch6_init },
2234};
2235
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002236static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002237 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002238 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002239 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002240 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002241 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2242 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002243 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2244 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002245 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2246 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2247 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2248 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2249 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2250 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2251 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2252 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002253 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002254 {
2255 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2256 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002257 .info = alc_ch_mode_info,
2258 .get = alc_ch_mode_get,
2259 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002260 },
2261 { } /* end */
2262};
2263
2264/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002265static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2266 struct snd_ctl_elem_info *uinfo)
2267{
2268 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2269 struct alc_spec *spec = codec->spec;
2270 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002271
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002272 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002273 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2274 HDA_INPUT);
2275 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002276 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002277 return err;
2278}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002279
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002280static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2281 unsigned int size, unsigned int __user *tlv)
2282{
2283 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2284 struct alc_spec *spec = codec->spec;
2285 int err;
2286
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002287 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002288 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2289 HDA_INPUT);
2290 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002291 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002292 return err;
2293}
2294
2295typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2296 struct snd_ctl_elem_value *ucontrol);
2297
2298static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2299 struct snd_ctl_elem_value *ucontrol,
2300 getput_call_t func)
2301{
2302 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2303 struct alc_spec *spec = codec->spec;
2304 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2305 int err;
2306
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002307 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002308 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2309 3, 0, HDA_INPUT);
2310 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002311 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002312 return err;
2313}
2314
2315static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2316 struct snd_ctl_elem_value *ucontrol)
2317{
2318 return alc_cap_getput_caller(kcontrol, ucontrol,
2319 snd_hda_mixer_amp_volume_get);
2320}
2321
2322static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2323 struct snd_ctl_elem_value *ucontrol)
2324{
2325 return alc_cap_getput_caller(kcontrol, ucontrol,
2326 snd_hda_mixer_amp_volume_put);
2327}
2328
2329/* capture mixer elements */
2330#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2331
2332static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2333 struct snd_ctl_elem_value *ucontrol)
2334{
2335 return alc_cap_getput_caller(kcontrol, ucontrol,
2336 snd_hda_mixer_amp_switch_get);
2337}
2338
2339static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2340 struct snd_ctl_elem_value *ucontrol)
2341{
2342 return alc_cap_getput_caller(kcontrol, ucontrol,
2343 snd_hda_mixer_amp_switch_put);
2344}
2345
Takashi Iwaia23b6882009-03-23 15:21:36 +01002346#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002347 { \
2348 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2349 .name = "Capture Switch", \
2350 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2351 .count = num, \
2352 .info = alc_cap_sw_info, \
2353 .get = alc_cap_sw_get, \
2354 .put = alc_cap_sw_put, \
2355 }, \
2356 { \
2357 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2358 .name = "Capture Volume", \
2359 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2360 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2361 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2362 .count = num, \
2363 .info = alc_cap_vol_info, \
2364 .get = alc_cap_vol_get, \
2365 .put = alc_cap_vol_put, \
2366 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002367 }
2368
2369#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002370 { \
2371 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2372 /* .name = "Capture Source", */ \
2373 .name = "Input Source", \
2374 .count = num, \
2375 .info = alc_mux_enum_info, \
2376 .get = alc_mux_enum_get, \
2377 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002378 }
2379
2380#define DEFINE_CAPMIX(num) \
2381static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2382 _DEFINE_CAPMIX(num), \
2383 _DEFINE_CAPSRC(num), \
2384 { } /* end */ \
2385}
2386
2387#define DEFINE_CAPMIX_NOSRC(num) \
2388static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2389 _DEFINE_CAPMIX(num), \
2390 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002391}
2392
2393/* up to three ADCs */
2394DEFINE_CAPMIX(1);
2395DEFINE_CAPMIX(2);
2396DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002397DEFINE_CAPMIX_NOSRC(1);
2398DEFINE_CAPMIX_NOSRC(2);
2399DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002400
2401/*
2402 * ALC880 5-stack model
2403 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002404 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2405 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002406 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2407 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2408 */
2409
2410/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002411static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002412 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002413 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002414 { } /* end */
2415};
2416
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002417/* channel source setting (6/8 channel selection for 5-stack) */
2418/* 6ch mode */
2419static struct hda_verb alc880_fivestack_ch6_init[] = {
2420 /* set line-in to input, mute it */
2421 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2422 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002423 { } /* end */
2424};
2425
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002426/* 8ch mode */
2427static struct hda_verb alc880_fivestack_ch8_init[] = {
2428 /* set line-in to output, unmute it */
2429 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2430 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2431 { } /* end */
2432};
2433
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002434static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002435 { 6, alc880_fivestack_ch6_init },
2436 { 8, alc880_fivestack_ch8_init },
2437};
2438
2439
2440/*
2441 * ALC880 6-stack model
2442 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002443 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2444 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002445 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2446 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2447 */
2448
2449static hda_nid_t alc880_6st_dac_nids[4] = {
2450 /* front, rear, clfe, rear_surr */
2451 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002452};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002453
2454static struct hda_input_mux alc880_6stack_capture_source = {
2455 .num_items = 4,
2456 .items = {
2457 { "Mic", 0x0 },
2458 { "Front Mic", 0x1 },
2459 { "Line", 0x2 },
2460 { "CD", 0x4 },
2461 },
2462};
2463
2464/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002465static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002466 { 8, NULL },
2467};
2468
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002469static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002470 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002471 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002472 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002473 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002474 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2475 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002476 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2477 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002478 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002479 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002480 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2481 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2482 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2483 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2484 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2485 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2486 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2487 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002488 {
2489 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2490 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002491 .info = alc_ch_mode_info,
2492 .get = alc_ch_mode_get,
2493 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002494 },
2495 { } /* end */
2496};
2497
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002498
2499/*
2500 * ALC880 W810 model
2501 *
2502 * W810 has rear IO for:
2503 * Front (DAC 02)
2504 * Surround (DAC 03)
2505 * Center/LFE (DAC 04)
2506 * Digital out (06)
2507 *
2508 * The system also has a pair of internal speakers, and a headphone jack.
2509 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002510 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002511 * There is a variable resistor to control the speaker or headphone
2512 * volume. This is a hardware-only device without a software API.
2513 *
2514 * Plugging headphones in will disable the internal speakers. This is
2515 * implemented in hardware, not via the driver using jack sense. In
2516 * a similar fashion, plugging into the rear socket marked "front" will
2517 * disable both the speakers and headphones.
2518 *
2519 * For input, there's a microphone jack, and an "audio in" jack.
2520 * These may not do anything useful with this driver yet, because I
2521 * haven't setup any initialization verbs for these yet...
2522 */
2523
2524static hda_nid_t alc880_w810_dac_nids[3] = {
2525 /* front, rear/surround, clfe */
2526 0x02, 0x03, 0x04
2527};
2528
2529/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002530static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002531 { 6, NULL }
2532};
2533
2534/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002535static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002536 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002537 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002538 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002539 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002540 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2541 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002542 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2543 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002544 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2545 { } /* end */
2546};
2547
2548
2549/*
2550 * Z710V model
2551 *
2552 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002553 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2554 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002555 */
2556
2557static hda_nid_t alc880_z71v_dac_nids[1] = {
2558 0x02
2559};
2560#define ALC880_Z71V_HP_DAC 0x03
2561
2562/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002563static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002564 { 2, NULL }
2565};
2566
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002567static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002568 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002569 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002570 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002571 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002572 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2573 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2574 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2575 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2576 { } /* end */
2577};
2578
2579
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002580/*
2581 * ALC880 F1734 model
2582 *
2583 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2584 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2585 */
2586
2587static hda_nid_t alc880_f1734_dac_nids[1] = {
2588 0x03
2589};
2590#define ALC880_F1734_HP_DAC 0x02
2591
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002592static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002593 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002594 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002595 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2596 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002597 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2598 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002599 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2600 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002601 { } /* end */
2602};
2603
Takashi Iwai937b4162008-02-11 14:52:36 +01002604static struct hda_input_mux alc880_f1734_capture_source = {
2605 .num_items = 2,
2606 .items = {
2607 { "Mic", 0x1 },
2608 { "CD", 0x4 },
2609 },
2610};
2611
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002612
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002613/*
2614 * ALC880 ASUS model
2615 *
2616 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2617 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2618 * Mic = 0x18, Line = 0x1a
2619 */
2620
2621#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2622#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2623
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002624static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002625 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002626 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002627 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002628 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002629 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2630 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002631 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2632 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002633 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2634 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2635 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2636 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2637 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2638 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002639 {
2640 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2641 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002642 .info = alc_ch_mode_info,
2643 .get = alc_ch_mode_get,
2644 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002645 },
2646 { } /* end */
2647};
2648
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002649/*
2650 * ALC880 ASUS W1V model
2651 *
2652 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2653 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2654 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2655 */
2656
2657/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002658static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002659 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2660 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002661 { } /* end */
2662};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002663
Kailang Yangdf694da2005-12-05 19:42:22 +01002664/* TCL S700 */
2665static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2666 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2667 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2668 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2669 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2670 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2671 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2672 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2673 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2674 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002675 { } /* end */
2676};
2677
Kailang Yangccc656c2006-10-17 12:32:26 +02002678/* Uniwill */
2679static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002680 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2681 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2682 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2683 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002684 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2685 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2686 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2687 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2688 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2689 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2690 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2691 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2692 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2693 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2694 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2695 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002696 {
2697 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2698 .name = "Channel Mode",
2699 .info = alc_ch_mode_info,
2700 .get = alc_ch_mode_get,
2701 .put = alc_ch_mode_put,
2702 },
2703 { } /* end */
2704};
2705
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002706static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2707 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2708 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2709 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2710 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2711 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2712 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2713 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2714 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2715 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2716 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2717 { } /* end */
2718};
2719
Kailang Yangccc656c2006-10-17 12:32:26 +02002720static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002721 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2722 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2723 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2724 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002725 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2726 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2727 { } /* end */
2728};
2729
Linus Torvalds1da177e2005-04-16 15:20:36 -07002730/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002731 * virtual master controls
2732 */
2733
2734/*
2735 * slave controls for virtual master
2736 */
2737static const char *alc_slave_vols[] = {
2738 "Front Playback Volume",
2739 "Surround Playback Volume",
2740 "Center Playback Volume",
2741 "LFE Playback Volume",
2742 "Side Playback Volume",
2743 "Headphone Playback Volume",
2744 "Speaker Playback Volume",
2745 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002746 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002747 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002748 NULL,
2749};
2750
2751static const char *alc_slave_sws[] = {
2752 "Front Playback Switch",
2753 "Surround Playback Switch",
2754 "Center Playback Switch",
2755 "LFE Playback Switch",
2756 "Side Playback Switch",
2757 "Headphone Playback Switch",
2758 "Speaker Playback Switch",
2759 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002760 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002761 "Line-Out Playback Switch",
2762 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002763 NULL,
2764};
2765
2766/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002767 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002768 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002769
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002770#define NID_MAPPING (-1)
2771
2772#define SUBDEV_SPEAKER_ (0 << 6)
2773#define SUBDEV_HP_ (1 << 6)
2774#define SUBDEV_LINE_ (2 << 6)
2775#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2776#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2777#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2778
Takashi Iwai603c4012008-07-30 15:01:44 +02002779static void alc_free_kctls(struct hda_codec *codec);
2780
Takashi Iwai67d634c2009-11-16 15:35:59 +01002781#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002782/* additional beep mixers; the actual parameters are overwritten at build */
2783static struct snd_kcontrol_new alc_beep_mixer[] = {
2784 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002785 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002786 { } /* end */
2787};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002788#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002789
Linus Torvalds1da177e2005-04-16 15:20:36 -07002790static int alc_build_controls(struct hda_codec *codec)
2791{
2792 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02002793 struct snd_kcontrol *kctl = NULL;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002794 struct snd_kcontrol_new *knew;
2795 int i, j, err;
2796 unsigned int u;
2797 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002798
2799 for (i = 0; i < spec->num_mixers; i++) {
2800 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2801 if (err < 0)
2802 return err;
2803 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002804 if (spec->cap_mixer) {
2805 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2806 if (err < 0)
2807 return err;
2808 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002809 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002810 err = snd_hda_create_spdif_out_ctls(codec,
2811 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002812 if (err < 0)
2813 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002814 if (!spec->no_analog) {
2815 err = snd_hda_create_spdif_share_sw(codec,
2816 &spec->multiout);
2817 if (err < 0)
2818 return err;
2819 spec->multiout.share_spdif = 1;
2820 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002821 }
2822 if (spec->dig_in_nid) {
2823 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2824 if (err < 0)
2825 return err;
2826 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002827
Takashi Iwai67d634c2009-11-16 15:35:59 +01002828#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002829 /* create beep controls if needed */
2830 if (spec->beep_amp) {
2831 struct snd_kcontrol_new *knew;
2832 for (knew = alc_beep_mixer; knew->name; knew++) {
2833 struct snd_kcontrol *kctl;
2834 kctl = snd_ctl_new1(knew, codec);
2835 if (!kctl)
2836 return -ENOMEM;
2837 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002838 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002839 if (err < 0)
2840 return err;
2841 }
2842 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002843#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002844
Takashi Iwai2134ea42008-01-10 16:53:55 +01002845 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002846 if (!spec->no_analog &&
2847 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002848 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002849 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002850 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002851 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002852 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002853 if (err < 0)
2854 return err;
2855 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002856 if (!spec->no_analog &&
2857 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002858 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2859 NULL, alc_slave_sws);
2860 if (err < 0)
2861 return err;
2862 }
2863
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002864 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02002865 if (spec->capsrc_nids || spec->adc_nids) {
2866 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2867 if (!kctl)
2868 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2869 for (i = 0; kctl && i < kctl->count; i++) {
2870 hda_nid_t *nids = spec->capsrc_nids;
2871 if (!nids)
2872 nids = spec->adc_nids;
2873 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
2874 if (err < 0)
2875 return err;
2876 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002877 }
2878 if (spec->cap_mixer) {
2879 const char *kname = kctl ? kctl->id.name : NULL;
2880 for (knew = spec->cap_mixer; knew->name; knew++) {
2881 if (kname && strcmp(knew->name, kname) == 0)
2882 continue;
2883 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2884 for (i = 0; kctl && i < kctl->count; i++) {
2885 err = snd_hda_add_nid(codec, kctl, i,
2886 spec->adc_nids[i]);
2887 if (err < 0)
2888 return err;
2889 }
2890 }
2891 }
2892
2893 /* other nid->control mapping */
2894 for (i = 0; i < spec->num_mixers; i++) {
2895 for (knew = spec->mixers[i]; knew->name; knew++) {
2896 if (knew->iface != NID_MAPPING)
2897 continue;
2898 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2899 if (kctl == NULL)
2900 continue;
2901 u = knew->subdevice;
2902 for (j = 0; j < 4; j++, u >>= 8) {
2903 nid = u & 0x3f;
2904 if (nid == 0)
2905 continue;
2906 switch (u & 0xc0) {
2907 case SUBDEV_SPEAKER_:
2908 nid = spec->autocfg.speaker_pins[nid];
2909 break;
2910 case SUBDEV_LINE_:
2911 nid = spec->autocfg.line_out_pins[nid];
2912 break;
2913 case SUBDEV_HP_:
2914 nid = spec->autocfg.hp_pins[nid];
2915 break;
2916 default:
2917 continue;
2918 }
2919 err = snd_hda_add_nid(codec, kctl, 0, nid);
2920 if (err < 0)
2921 return err;
2922 }
2923 u = knew->private_value;
2924 for (j = 0; j < 4; j++, u >>= 8) {
2925 nid = u & 0xff;
2926 if (nid == 0)
2927 continue;
2928 err = snd_hda_add_nid(codec, kctl, 0, nid);
2929 if (err < 0)
2930 return err;
2931 }
2932 }
2933 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01002934
2935 alc_free_kctls(codec); /* no longer needed */
2936
Linus Torvalds1da177e2005-04-16 15:20:36 -07002937 return 0;
2938}
2939
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002940
Linus Torvalds1da177e2005-04-16 15:20:36 -07002941/*
2942 * initialize the codec volumes, etc
2943 */
2944
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002945/*
2946 * generic initialization of ADC, input mixers and output mixers
2947 */
2948static struct hda_verb alc880_volume_init_verbs[] = {
2949 /*
2950 * Unmute ADC0-2 and set the default input to mic-in
2951 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002952 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002953 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002954 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002955 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002956 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002957 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002958
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002959 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2960 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002961 * Note: PASD motherboards uses the Line In 2 as the input for front
2962 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002963 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002964 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002965 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2966 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2967 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2968 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2969 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2970 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2971 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002972
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002973 /*
2974 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002975 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002976 /* set vol=0 to output mixers */
2977 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2978 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2979 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2980 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2981 /* set up input amps for analog loopback */
2982 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002983 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2984 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002985 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2986 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002987 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2988 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002989 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2990 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002991
2992 { }
2993};
2994
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002995/*
2996 * 3-stack pin configuration:
2997 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2998 */
2999static struct hda_verb alc880_pin_3stack_init_verbs[] = {
3000 /*
3001 * preset connection lists of input pins
3002 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3003 */
3004 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3005 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3006 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3007
3008 /*
3009 * Set pin mode and muting
3010 */
3011 /* set front pin widgets 0x14 for output */
3012 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3013 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3014 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3015 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3016 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3017 /* Mic2 (as headphone out) for HP output */
3018 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3019 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3020 /* Line In pin widget for input */
3021 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3022 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3023 /* Line2 (as front mic) pin widget for input and vref at 80% */
3024 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3025 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3026 /* CD pin widget for input */
3027 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3028
3029 { }
3030};
3031
3032/*
3033 * 5-stack pin configuration:
3034 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3035 * line-in/side = 0x1a, f-mic = 0x1b
3036 */
3037static struct hda_verb alc880_pin_5stack_init_verbs[] = {
3038 /*
3039 * preset connection lists of input pins
3040 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3041 */
3042 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3043 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3044
3045 /*
3046 * Set pin mode and muting
3047 */
3048 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02003049 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3050 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3051 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3052 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003053 /* unmute pins for output (no gain on this amp) */
3054 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3055 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3056 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3057 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3058
Linus Torvalds1da177e2005-04-16 15:20:36 -07003059 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003060 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003061 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3062 /* Mic2 (as headphone out) for HP output */
3063 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003064 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003065 /* Line In pin widget for input */
3066 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3067 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3068 /* Line2 (as front mic) pin widget for input and vref at 80% */
3069 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3070 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3071 /* CD pin widget for input */
3072 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003073
3074 { }
3075};
3076
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003077/*
3078 * W810 pin configuration:
3079 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3080 */
3081static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003082 /* hphone/speaker input selector: front DAC */
3083 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3084
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003085 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3086 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3087 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3088 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3089 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3090 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3091
3092 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003093 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003094
Linus Torvalds1da177e2005-04-16 15:20:36 -07003095 { }
3096};
3097
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003098/*
3099 * Z71V pin configuration:
3100 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3101 */
3102static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003103 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003104 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02003105 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003106 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003107
Takashi Iwai16ded522005-06-10 19:58:24 +02003108 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003109 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003110 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003111 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003112
3113 { }
3114};
3115
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003116/*
3117 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003118 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3119 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003120 */
3121static struct hda_verb alc880_pin_6stack_init_verbs[] = {
3122 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3123
Takashi Iwai16ded522005-06-10 19:58:24 +02003124 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003125 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003126 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003127 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003128 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003129 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003130 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003131 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3132
Takashi Iwai16ded522005-06-10 19:58:24 +02003133 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003134 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003135 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003136 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003137 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003138 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003139 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003140 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003141 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003142
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003143 { }
3144};
Takashi Iwai16ded522005-06-10 19:58:24 +02003145
Kailang Yangccc656c2006-10-17 12:32:26 +02003146/*
3147 * Uniwill pin configuration:
3148 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3149 * line = 0x1a
3150 */
3151static struct hda_verb alc880_uniwill_init_verbs[] = {
3152 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3153
3154 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3155 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3156 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3157 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3158 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3159 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3160 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3161 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3162 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3163 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3164 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3165 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3166 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3167 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3168
3169 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3170 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3171 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3172 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3173 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3174 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3175 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3176 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3177 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3178
3179 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3180 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3181
3182 { }
3183};
3184
3185/*
3186* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003187* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003188 */
3189static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3190 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3191
3192 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3193 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3194 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3195 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3196 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3197 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3198 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3199 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3200 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3201 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3202 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3203 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3204
3205 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3206 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3207 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3208 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3209 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3210 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3211
3212 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3213 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3214
3215 { }
3216};
3217
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003218static struct hda_verb alc880_beep_init_verbs[] = {
3219 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3220 { }
3221};
3222
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003223/* auto-toggle front mic */
3224static void alc880_uniwill_mic_automute(struct hda_codec *codec)
3225{
3226 unsigned int present;
3227 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003228
Wu Fengguang864f92b2009-11-18 12:38:02 +08003229 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003230 bits = present ? HDA_AMP_MUTE : 0;
3231 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003232}
3233
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003234static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003235{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003236 struct alc_spec *spec = codec->spec;
3237
3238 spec->autocfg.hp_pins[0] = 0x14;
3239 spec->autocfg.speaker_pins[0] = 0x15;
3240 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003241}
3242
3243static void alc880_uniwill_init_hook(struct hda_codec *codec)
3244{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003245 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003246 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003247}
3248
3249static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3250 unsigned int res)
3251{
3252 /* Looks like the unsol event is incompatible with the standard
3253 * definition. 4bit tag is placed at 28 bit!
3254 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003255 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003256 case ALC880_MIC_EVENT:
3257 alc880_uniwill_mic_automute(codec);
3258 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003259 default:
3260 alc_automute_amp_unsol_event(codec, res);
3261 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003262 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003263}
3264
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003265static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003266{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003267 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003268
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003269 spec->autocfg.hp_pins[0] = 0x14;
3270 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02003271}
3272
3273static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3274{
3275 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003276
Kailang Yangccc656c2006-10-17 12:32:26 +02003277 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003278 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3279 present &= HDA_AMP_VOLMASK;
3280 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3281 HDA_AMP_VOLMASK, present);
3282 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3283 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003284}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003285
Kailang Yangccc656c2006-10-17 12:32:26 +02003286static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3287 unsigned int res)
3288{
3289 /* Looks like the unsol event is incompatible with the standard
3290 * definition. 4bit tag is placed at 28 bit!
3291 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003292 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003293 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003294 else
3295 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003296}
3297
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003298/*
3299 * F1734 pin configuration:
3300 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3301 */
3302static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003303 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003304 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3305 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3306 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3307 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3308
3309 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3310 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3311 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3312 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3313
3314 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3315 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003316 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003317 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3318 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3319 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3320 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3321 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3322 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003323
Takashi Iwai937b4162008-02-11 14:52:36 +01003324 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3325 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3326
Takashi Iwai16ded522005-06-10 19:58:24 +02003327 { }
3328};
3329
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003330/*
3331 * ASUS pin configuration:
3332 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3333 */
3334static struct hda_verb alc880_pin_asus_init_verbs[] = {
3335 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3336 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3337 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3338 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3339
3340 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3341 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3342 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3343 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3344 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3345 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3346 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3347 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3348
3349 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3350 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3351 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3352 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3353 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3354 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3355 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3356 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3357 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003358
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003359 { }
3360};
3361
3362/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003363#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3364#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003365#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003366
Kailang Yangdf694da2005-12-05 19:42:22 +01003367/* Clevo m520g init */
3368static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3369 /* headphone output */
3370 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3371 /* line-out */
3372 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3373 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3374 /* Line-in */
3375 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3376 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3377 /* CD */
3378 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3379 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3380 /* Mic1 (rear panel) */
3381 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3382 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3383 /* Mic2 (front panel) */
3384 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3385 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3386 /* headphone */
3387 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3388 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3389 /* change to EAPD mode */
3390 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3391 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3392
3393 { }
3394};
3395
3396static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003397 /* change to EAPD mode */
3398 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3399 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3400
Kailang Yangdf694da2005-12-05 19:42:22 +01003401 /* Headphone output */
3402 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3403 /* Front output*/
3404 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3405 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3406
3407 /* Line In pin widget for input */
3408 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3409 /* CD pin widget for input */
3410 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3411 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3412 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3413
3414 /* change to EAPD mode */
3415 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3416 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3417
3418 { }
3419};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003420
3421/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003422 * LG m1 express dual
3423 *
3424 * Pin assignment:
3425 * Rear Line-In/Out (blue): 0x14
3426 * Build-in Mic-In: 0x15
3427 * Speaker-out: 0x17
3428 * HP-Out (green): 0x1b
3429 * Mic-In/Out (red): 0x19
3430 * SPDIF-Out: 0x1e
3431 */
3432
3433/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3434static hda_nid_t alc880_lg_dac_nids[3] = {
3435 0x05, 0x02, 0x03
3436};
3437
3438/* seems analog CD is not working */
3439static struct hda_input_mux alc880_lg_capture_source = {
3440 .num_items = 3,
3441 .items = {
3442 { "Mic", 0x1 },
3443 { "Line", 0x5 },
3444 { "Internal Mic", 0x6 },
3445 },
3446};
3447
3448/* 2,4,6 channel modes */
3449static struct hda_verb alc880_lg_ch2_init[] = {
3450 /* set line-in and mic-in to input */
3451 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3452 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3453 { }
3454};
3455
3456static struct hda_verb alc880_lg_ch4_init[] = {
3457 /* set line-in to out and mic-in to input */
3458 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3459 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3460 { }
3461};
3462
3463static struct hda_verb alc880_lg_ch6_init[] = {
3464 /* set line-in and mic-in to output */
3465 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3466 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3467 { }
3468};
3469
3470static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3471 { 2, alc880_lg_ch2_init },
3472 { 4, alc880_lg_ch4_init },
3473 { 6, alc880_lg_ch6_init },
3474};
3475
3476static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003477 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3478 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003479 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3480 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3481 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3482 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3483 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3484 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3485 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3486 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3487 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3488 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3489 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3490 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3491 {
3492 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3493 .name = "Channel Mode",
3494 .info = alc_ch_mode_info,
3495 .get = alc_ch_mode_get,
3496 .put = alc_ch_mode_put,
3497 },
3498 { } /* end */
3499};
3500
3501static struct hda_verb alc880_lg_init_verbs[] = {
3502 /* set capture source to mic-in */
3503 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3504 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3505 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3506 /* mute all amp mixer inputs */
3507 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003508 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3509 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003510 /* line-in to input */
3511 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3512 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3513 /* built-in mic */
3514 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3515 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3516 /* speaker-out */
3517 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3518 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3519 /* mic-in to input */
3520 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3521 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3522 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3523 /* HP-out */
3524 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3525 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3526 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3527 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003528 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003529 { }
3530};
3531
3532/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003533static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003534{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003535 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003536
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003537 spec->autocfg.hp_pins[0] = 0x1b;
3538 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003539}
3540
3541/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003542 * LG LW20
3543 *
3544 * Pin assignment:
3545 * Speaker-out: 0x14
3546 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003547 * Built-in Mic-In: 0x19
3548 * Line-In: 0x1b
3549 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003550 * SPDIF-Out: 0x1e
3551 */
3552
Takashi Iwaid6815182006-03-23 16:06:23 +01003553static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003554 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003555 .items = {
3556 { "Mic", 0x0 },
3557 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003558 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003559 },
3560};
3561
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003562#define alc880_lg_lw_modes alc880_threestack_modes
3563
Takashi Iwaid6815182006-03-23 16:06:23 +01003564static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003565 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3566 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3567 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3568 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3569 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3570 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3571 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3572 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3573 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3574 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003575 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3576 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3577 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3578 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003579 {
3580 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3581 .name = "Channel Mode",
3582 .info = alc_ch_mode_info,
3583 .get = alc_ch_mode_get,
3584 .put = alc_ch_mode_put,
3585 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003586 { } /* end */
3587};
3588
3589static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003590 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3591 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3592 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3593
Takashi Iwaid6815182006-03-23 16:06:23 +01003594 /* set capture source to mic-in */
3595 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3596 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3597 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003598 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003599 /* speaker-out */
3600 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3601 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3602 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003603 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3604 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3605 /* mic-in to input */
3606 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3607 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3608 /* built-in mic */
3609 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3610 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3611 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003612 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003613 { }
3614};
3615
3616/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003617static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003618{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003619 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003620
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003621 spec->autocfg.hp_pins[0] = 0x1b;
3622 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003623}
3624
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003625static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3626 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3627 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3628 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3629 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3630 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3631 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3632 { } /* end */
3633};
3634
3635static struct hda_input_mux alc880_medion_rim_capture_source = {
3636 .num_items = 2,
3637 .items = {
3638 { "Mic", 0x0 },
3639 { "Internal Mic", 0x1 },
3640 },
3641};
3642
3643static struct hda_verb alc880_medion_rim_init_verbs[] = {
3644 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3645
3646 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3647 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3648
3649 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3650 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3651 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3652 /* Mic2 (as headphone out) for HP output */
3653 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3654 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3655 /* Internal Speaker */
3656 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3657 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3658
3659 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3660 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3661
3662 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3663 { }
3664};
3665
3666/* toggle speaker-output according to the hp-jack state */
3667static void alc880_medion_rim_automute(struct hda_codec *codec)
3668{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003669 struct alc_spec *spec = codec->spec;
3670 alc_automute_amp(codec);
3671 /* toggle EAPD */
3672 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003673 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3674 else
3675 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3676}
3677
3678static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3679 unsigned int res)
3680{
3681 /* Looks like the unsol event is incompatible with the standard
3682 * definition. 4bit tag is placed at 28 bit!
3683 */
3684 if ((res >> 28) == ALC880_HP_EVENT)
3685 alc880_medion_rim_automute(codec);
3686}
3687
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003688static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003689{
3690 struct alc_spec *spec = codec->spec;
3691
3692 spec->autocfg.hp_pins[0] = 0x14;
3693 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003694}
3695
Takashi Iwaicb53c622007-08-10 17:21:45 +02003696#ifdef CONFIG_SND_HDA_POWER_SAVE
3697static struct hda_amp_list alc880_loopbacks[] = {
3698 { 0x0b, HDA_INPUT, 0 },
3699 { 0x0b, HDA_INPUT, 1 },
3700 { 0x0b, HDA_INPUT, 2 },
3701 { 0x0b, HDA_INPUT, 3 },
3702 { 0x0b, HDA_INPUT, 4 },
3703 { } /* end */
3704};
3705
3706static struct hda_amp_list alc880_lg_loopbacks[] = {
3707 { 0x0b, HDA_INPUT, 1 },
3708 { 0x0b, HDA_INPUT, 6 },
3709 { 0x0b, HDA_INPUT, 7 },
3710 { } /* end */
3711};
3712#endif
3713
Takashi Iwaid6815182006-03-23 16:06:23 +01003714/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003715 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003716 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003717
Linus Torvalds1da177e2005-04-16 15:20:36 -07003718static int alc_init(struct hda_codec *codec)
3719{
3720 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003721 unsigned int i;
3722
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003723 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003724 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003725
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003726 for (i = 0; i < spec->num_init_verbs; i++)
3727 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003728
3729 if (spec->init_hook)
3730 spec->init_hook(codec);
3731
Takashi Iwaiad358792010-03-30 18:00:59 +02003732#ifdef CONFIG_SND_HDA_POWER_SAVE
3733 if (codec->patch_ops.check_power_status)
3734 codec->patch_ops.check_power_status(codec, 0x01);
3735#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003736 return 0;
3737}
3738
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003739static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3740{
3741 struct alc_spec *spec = codec->spec;
3742
3743 if (spec->unsol_event)
3744 spec->unsol_event(codec, res);
3745}
3746
Takashi Iwaicb53c622007-08-10 17:21:45 +02003747#ifdef CONFIG_SND_HDA_POWER_SAVE
3748static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3749{
3750 struct alc_spec *spec = codec->spec;
3751 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3752}
3753#endif
3754
Linus Torvalds1da177e2005-04-16 15:20:36 -07003755/*
3756 * Analog playback callbacks
3757 */
3758static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3759 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003760 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003761{
3762 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003763 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3764 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003765}
3766
3767static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3768 struct hda_codec *codec,
3769 unsigned int stream_tag,
3770 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003771 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003772{
3773 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003774 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3775 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003776}
3777
3778static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3779 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003780 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003781{
3782 struct alc_spec *spec = codec->spec;
3783 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3784}
3785
3786/*
3787 * Digital out
3788 */
3789static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3790 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003791 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003792{
3793 struct alc_spec *spec = codec->spec;
3794 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3795}
3796
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003797static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3798 struct hda_codec *codec,
3799 unsigned int stream_tag,
3800 unsigned int format,
3801 struct snd_pcm_substream *substream)
3802{
3803 struct alc_spec *spec = codec->spec;
3804 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3805 stream_tag, format, substream);
3806}
3807
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003808static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3809 struct hda_codec *codec,
3810 struct snd_pcm_substream *substream)
3811{
3812 struct alc_spec *spec = codec->spec;
3813 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3814}
3815
Linus Torvalds1da177e2005-04-16 15:20:36 -07003816static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3817 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003818 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003819{
3820 struct alc_spec *spec = codec->spec;
3821 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3822}
3823
3824/*
3825 * Analog capture
3826 */
Takashi Iwai63300792008-01-24 15:31:36 +01003827static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003828 struct hda_codec *codec,
3829 unsigned int stream_tag,
3830 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003831 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003832{
3833 struct alc_spec *spec = codec->spec;
3834
Takashi Iwai63300792008-01-24 15:31:36 +01003835 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003836 stream_tag, 0, format);
3837 return 0;
3838}
3839
Takashi Iwai63300792008-01-24 15:31:36 +01003840static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003841 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003842 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003843{
3844 struct alc_spec *spec = codec->spec;
3845
Takashi Iwai888afa12008-03-18 09:57:50 +01003846 snd_hda_codec_cleanup_stream(codec,
3847 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003848 return 0;
3849}
3850
Takashi Iwai840b64c2010-07-13 22:49:01 +02003851/* analog capture with dynamic dual-adc changes */
3852static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3853 struct hda_codec *codec,
3854 unsigned int stream_tag,
3855 unsigned int format,
3856 struct snd_pcm_substream *substream)
3857{
3858 struct alc_spec *spec = codec->spec;
3859 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
3860 spec->cur_adc_stream_tag = stream_tag;
3861 spec->cur_adc_format = format;
3862 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
3863 return 0;
3864}
3865
3866static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3867 struct hda_codec *codec,
3868 struct snd_pcm_substream *substream)
3869{
3870 struct alc_spec *spec = codec->spec;
3871 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
3872 spec->cur_adc = 0;
3873 return 0;
3874}
3875
3876static struct hda_pcm_stream dualmic_pcm_analog_capture = {
3877 .substreams = 1,
3878 .channels_min = 2,
3879 .channels_max = 2,
3880 .nid = 0, /* fill later */
3881 .ops = {
3882 .prepare = dualmic_capture_pcm_prepare,
3883 .cleanup = dualmic_capture_pcm_cleanup
3884 },
3885};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003886
3887/*
3888 */
3889static struct hda_pcm_stream alc880_pcm_analog_playback = {
3890 .substreams = 1,
3891 .channels_min = 2,
3892 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003893 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003894 .ops = {
3895 .open = alc880_playback_pcm_open,
3896 .prepare = alc880_playback_pcm_prepare,
3897 .cleanup = alc880_playback_pcm_cleanup
3898 },
3899};
3900
3901static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003902 .substreams = 1,
3903 .channels_min = 2,
3904 .channels_max = 2,
3905 /* NID is set in alc_build_pcms */
3906};
3907
3908static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3909 .substreams = 1,
3910 .channels_min = 2,
3911 .channels_max = 2,
3912 /* NID is set in alc_build_pcms */
3913};
3914
3915static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3916 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003917 .channels_min = 2,
3918 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003919 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003920 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003921 .prepare = alc880_alt_capture_pcm_prepare,
3922 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003923 },
3924};
3925
3926static struct hda_pcm_stream alc880_pcm_digital_playback = {
3927 .substreams = 1,
3928 .channels_min = 2,
3929 .channels_max = 2,
3930 /* NID is set in alc_build_pcms */
3931 .ops = {
3932 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003933 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003934 .prepare = alc880_dig_playback_pcm_prepare,
3935 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003936 },
3937};
3938
3939static struct hda_pcm_stream alc880_pcm_digital_capture = {
3940 .substreams = 1,
3941 .channels_min = 2,
3942 .channels_max = 2,
3943 /* NID is set in alc_build_pcms */
3944};
3945
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003946/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003947static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003948 .substreams = 0,
3949 .channels_min = 0,
3950 .channels_max = 0,
3951};
3952
Linus Torvalds1da177e2005-04-16 15:20:36 -07003953static int alc_build_pcms(struct hda_codec *codec)
3954{
3955 struct alc_spec *spec = codec->spec;
3956 struct hda_pcm *info = spec->pcm_rec;
3957 int i;
3958
3959 codec->num_pcms = 1;
3960 codec->pcm_info = info;
3961
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003962 if (spec->no_analog)
3963 goto skip_analog;
3964
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003965 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3966 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003967 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003968
Takashi Iwai4a471b72005-12-07 13:56:29 +01003969 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003970 if (snd_BUG_ON(!spec->multiout.dac_nids))
3971 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003972 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3973 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3974 }
3975 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003976 if (snd_BUG_ON(!spec->adc_nids))
3977 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003978 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3979 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3980 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003981
Takashi Iwai4a471b72005-12-07 13:56:29 +01003982 if (spec->channel_mode) {
3983 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3984 for (i = 0; i < spec->num_channel_mode; i++) {
3985 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3986 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3987 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003988 }
3989 }
3990
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003991 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003992 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003993 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003994 snprintf(spec->stream_name_digital,
3995 sizeof(spec->stream_name_digital),
3996 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003997 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003998 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003999 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004000 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01004001 if (spec->dig_out_type)
4002 info->pcm_type = spec->dig_out_type;
4003 else
4004 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004005 if (spec->multiout.dig_out_nid &&
4006 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004007 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
4008 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
4009 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004010 if (spec->dig_in_nid &&
4011 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004012 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
4013 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
4014 }
Takashi Iwai963f8032008-08-11 10:04:40 +02004015 /* FIXME: do we need this for all Realtek codec models? */
4016 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004017 }
4018
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004019 if (spec->no_analog)
4020 return 0;
4021
Takashi Iwaie08a0072006-09-07 17:52:14 +02004022 /* If the use of more than one ADC is requested for the current
4023 * model, configure a second analog capture-only PCM.
4024 */
4025 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01004026 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
4027 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02004028 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004029 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004030 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01004031 if (spec->alt_dac_nid) {
4032 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4033 *spec->stream_analog_alt_playback;
4034 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
4035 spec->alt_dac_nid;
4036 } else {
4037 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4038 alc_pcm_null_stream;
4039 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
4040 }
4041 if (spec->num_adc_nids > 1) {
4042 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4043 *spec->stream_analog_alt_capture;
4044 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
4045 spec->adc_nids[1];
4046 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
4047 spec->num_adc_nids - 1;
4048 } else {
4049 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4050 alc_pcm_null_stream;
4051 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004052 }
4053 }
4054
Linus Torvalds1da177e2005-04-16 15:20:36 -07004055 return 0;
4056}
4057
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004058static inline void alc_shutup(struct hda_codec *codec)
4059{
4060 snd_hda_shutup_pins(codec);
4061}
4062
Takashi Iwai603c4012008-07-30 15:01:44 +02004063static void alc_free_kctls(struct hda_codec *codec)
4064{
4065 struct alc_spec *spec = codec->spec;
4066
4067 if (spec->kctls.list) {
4068 struct snd_kcontrol_new *kctl = spec->kctls.list;
4069 int i;
4070 for (i = 0; i < spec->kctls.used; i++)
4071 kfree(kctl[i].name);
4072 }
4073 snd_array_free(&spec->kctls);
4074}
4075
Linus Torvalds1da177e2005-04-16 15:20:36 -07004076static void alc_free(struct hda_codec *codec)
4077{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004078 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004079
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004080 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004081 return;
4082
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004083 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02004084 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004085 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004086 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004087}
4088
Hector Martinf5de24b2009-12-20 22:51:31 +01004089#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05004090static void alc_power_eapd(struct hda_codec *codec)
4091{
4092 /* We currently only handle front, HP */
4093 switch (codec->vendor_id) {
4094 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004095 set_eapd(codec, 0x0f, 0);
4096 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004097 break;
4098 case 0x10ec0262:
4099 case 0x10ec0267:
4100 case 0x10ec0268:
4101 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004102 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05004103 case 0x10ec0272:
4104 case 0x10ec0660:
4105 case 0x10ec0662:
4106 case 0x10ec0663:
4107 case 0x10ec0862:
4108 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004109 set_eapd(codec, 0x14, 0);
4110 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004111 break;
4112 }
4113}
4114
Hector Martinf5de24b2009-12-20 22:51:31 +01004115static int alc_suspend(struct hda_codec *codec, pm_message_t state)
4116{
4117 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004118 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004119 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05004120 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004121 return 0;
4122}
4123#endif
4124
Takashi Iwaie044c392008-10-27 16:56:24 +01004125#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01004126static int alc_resume(struct hda_codec *codec)
4127{
Takashi Iwaie044c392008-10-27 16:56:24 +01004128 codec->patch_ops.init(codec);
4129 snd_hda_codec_resume_amp(codec);
4130 snd_hda_codec_resume_cache(codec);
Takashi Iwaiad358792010-03-30 18:00:59 +02004131#ifdef CONFIG_SND_HDA_POWER_SAVE
4132 if (codec->patch_ops.check_power_status)
4133 codec->patch_ops.check_power_status(codec, 0x01);
4134#endif
Takashi Iwaie044c392008-10-27 16:56:24 +01004135 return 0;
4136}
Takashi Iwaie044c392008-10-27 16:56:24 +01004137#endif
4138
Linus Torvalds1da177e2005-04-16 15:20:36 -07004139/*
4140 */
4141static struct hda_codec_ops alc_patch_ops = {
4142 .build_controls = alc_build_controls,
4143 .build_pcms = alc_build_pcms,
4144 .init = alc_init,
4145 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004146 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004147#ifdef SND_HDA_NEEDS_RESUME
4148 .resume = alc_resume,
4149#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004150#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004151 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004152 .check_power_status = alc_check_power_status,
4153#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004154 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004155};
4156
Kailang Yangc027ddc2010-03-19 11:33:06 +01004157/* replace the codec chip_name with the given string */
4158static int alc_codec_rename(struct hda_codec *codec, const char *name)
4159{
4160 kfree(codec->chip_name);
4161 codec->chip_name = kstrdup(name, GFP_KERNEL);
4162 if (!codec->chip_name) {
4163 alc_free(codec);
4164 return -ENOMEM;
4165 }
4166 return 0;
4167}
4168
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004169/*
4170 * Test configuration for debugging
4171 *
4172 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4173 * enum controls.
4174 */
4175#ifdef CONFIG_SND_DEBUG
4176static hda_nid_t alc880_test_dac_nids[4] = {
4177 0x02, 0x03, 0x04, 0x05
4178};
4179
4180static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004181 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004182 .items = {
4183 { "In-1", 0x0 },
4184 { "In-2", 0x1 },
4185 { "In-3", 0x2 },
4186 { "In-4", 0x3 },
4187 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004188 { "Front", 0x5 },
4189 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004190 },
4191};
4192
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004193static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004194 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004195 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004196 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004197 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004198};
4199
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004200static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4201 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004202{
4203 static char *texts[] = {
4204 "N/A", "Line Out", "HP Out",
4205 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4206 };
4207 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4208 uinfo->count = 1;
4209 uinfo->value.enumerated.items = 8;
4210 if (uinfo->value.enumerated.item >= 8)
4211 uinfo->value.enumerated.item = 7;
4212 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4213 return 0;
4214}
4215
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004216static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4217 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004218{
4219 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4220 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4221 unsigned int pin_ctl, item = 0;
4222
4223 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4224 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4225 if (pin_ctl & AC_PINCTL_OUT_EN) {
4226 if (pin_ctl & AC_PINCTL_HP_EN)
4227 item = 2;
4228 else
4229 item = 1;
4230 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4231 switch (pin_ctl & AC_PINCTL_VREFEN) {
4232 case AC_PINCTL_VREF_HIZ: item = 3; break;
4233 case AC_PINCTL_VREF_50: item = 4; break;
4234 case AC_PINCTL_VREF_GRD: item = 5; break;
4235 case AC_PINCTL_VREF_80: item = 6; break;
4236 case AC_PINCTL_VREF_100: item = 7; break;
4237 }
4238 }
4239 ucontrol->value.enumerated.item[0] = item;
4240 return 0;
4241}
4242
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004243static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
4244 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004245{
4246 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4247 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4248 static unsigned int ctls[] = {
4249 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4250 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4251 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4252 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4253 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4254 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4255 };
4256 unsigned int old_ctl, new_ctl;
4257
4258 old_ctl = snd_hda_codec_read(codec, nid, 0,
4259 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4260 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4261 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004262 int val;
4263 snd_hda_codec_write_cache(codec, nid, 0,
4264 AC_VERB_SET_PIN_WIDGET_CONTROL,
4265 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004266 val = ucontrol->value.enumerated.item[0] >= 3 ?
4267 HDA_AMP_MUTE : 0;
4268 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4269 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004270 return 1;
4271 }
4272 return 0;
4273}
4274
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004275static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4276 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004277{
4278 static char *texts[] = {
4279 "Front", "Surround", "CLFE", "Side"
4280 };
4281 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4282 uinfo->count = 1;
4283 uinfo->value.enumerated.items = 4;
4284 if (uinfo->value.enumerated.item >= 4)
4285 uinfo->value.enumerated.item = 3;
4286 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4287 return 0;
4288}
4289
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004290static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4291 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004292{
4293 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4294 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4295 unsigned int sel;
4296
4297 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4298 ucontrol->value.enumerated.item[0] = sel & 3;
4299 return 0;
4300}
4301
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004302static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4303 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004304{
4305 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4306 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4307 unsigned int sel;
4308
4309 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4310 if (ucontrol->value.enumerated.item[0] != sel) {
4311 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004312 snd_hda_codec_write_cache(codec, nid, 0,
4313 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004314 return 1;
4315 }
4316 return 0;
4317}
4318
4319#define PIN_CTL_TEST(xname,nid) { \
4320 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4321 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004322 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004323 .info = alc_test_pin_ctl_info, \
4324 .get = alc_test_pin_ctl_get, \
4325 .put = alc_test_pin_ctl_put, \
4326 .private_value = nid \
4327 }
4328
4329#define PIN_SRC_TEST(xname,nid) { \
4330 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4331 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004332 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004333 .info = alc_test_pin_src_info, \
4334 .get = alc_test_pin_src_get, \
4335 .put = alc_test_pin_src_put, \
4336 .private_value = nid \
4337 }
4338
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004339static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004340 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4341 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4342 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4343 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004344 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4345 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4346 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4347 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004348 PIN_CTL_TEST("Front Pin Mode", 0x14),
4349 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4350 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4351 PIN_CTL_TEST("Side Pin Mode", 0x17),
4352 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4353 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4354 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4355 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4356 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4357 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4358 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4359 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4360 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4361 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4362 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4363 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4364 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4365 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4366 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4367 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4368 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4369 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004370 {
4371 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4372 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004373 .info = alc_ch_mode_info,
4374 .get = alc_ch_mode_get,
4375 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004376 },
4377 { } /* end */
4378};
4379
4380static struct hda_verb alc880_test_init_verbs[] = {
4381 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004382 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4383 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4384 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4385 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4386 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4387 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4388 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4389 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004390 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004391 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4392 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4393 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4394 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004395 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004396 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4397 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4398 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4399 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004400 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004401 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4402 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4403 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4404 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004405 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004406 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4407 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004408 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4409 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4410 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004411 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004412 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4413 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4414 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4415 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004416 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004417 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004418 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004419 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004420 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004421 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004422 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004423 /* Analog input/passthru */
4424 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4425 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4426 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4427 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4428 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004429 { }
4430};
4431#endif
4432
Linus Torvalds1da177e2005-04-16 15:20:36 -07004433/*
4434 */
4435
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004436static const char *alc880_models[ALC880_MODEL_LAST] = {
4437 [ALC880_3ST] = "3stack",
4438 [ALC880_TCL_S700] = "tcl",
4439 [ALC880_3ST_DIG] = "3stack-digout",
4440 [ALC880_CLEVO] = "clevo",
4441 [ALC880_5ST] = "5stack",
4442 [ALC880_5ST_DIG] = "5stack-digout",
4443 [ALC880_W810] = "w810",
4444 [ALC880_Z71V] = "z71v",
4445 [ALC880_6ST] = "6stack",
4446 [ALC880_6ST_DIG] = "6stack-digout",
4447 [ALC880_ASUS] = "asus",
4448 [ALC880_ASUS_W1V] = "asus-w1v",
4449 [ALC880_ASUS_DIG] = "asus-dig",
4450 [ALC880_ASUS_DIG2] = "asus-dig2",
4451 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004452 [ALC880_UNIWILL_P53] = "uniwill-p53",
4453 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004454 [ALC880_F1734] = "F1734",
4455 [ALC880_LG] = "lg",
4456 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004457 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004458#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004459 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004460#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004461 [ALC880_AUTO] = "auto",
4462};
4463
4464static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004465 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004466 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4467 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4468 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4469 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4470 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4471 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4472 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4473 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004474 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4475 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004476 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4477 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4478 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4479 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4480 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4481 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4482 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4483 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4484 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4485 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004486 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004487 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4488 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4489 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004490 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004491 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004492 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4493 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004494 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4495 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004496 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4497 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4498 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4499 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004500 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4501 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004502 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004503 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004504 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004505 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004506 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4507 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004508 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004509 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004510 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004511 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004512 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004513 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004514 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004515 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004516 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004517 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4518 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004519 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004520 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4521 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4522 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4523 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004524 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4525 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004526 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004527 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004528 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4529 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004530 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4531 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4532 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004533 /* default Intel */
4534 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004535 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4536 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004537 {}
4538};
4539
Takashi Iwai16ded522005-06-10 19:58:24 +02004540/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004541 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004542 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004543static struct alc_config_preset alc880_presets[] = {
4544 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004545 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004546 .init_verbs = { alc880_volume_init_verbs,
4547 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004548 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004549 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004550 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4551 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004552 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004553 .input_mux = &alc880_capture_source,
4554 },
4555 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004556 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004557 .init_verbs = { alc880_volume_init_verbs,
4558 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004559 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004560 .dac_nids = alc880_dac_nids,
4561 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004562 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4563 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004564 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004565 .input_mux = &alc880_capture_source,
4566 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004567 [ALC880_TCL_S700] = {
4568 .mixers = { alc880_tcl_s700_mixer },
4569 .init_verbs = { alc880_volume_init_verbs,
4570 alc880_pin_tcl_S700_init_verbs,
4571 alc880_gpio2_init_verbs },
4572 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4573 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004574 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4575 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004576 .hp_nid = 0x03,
4577 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4578 .channel_mode = alc880_2_jack_modes,
4579 .input_mux = &alc880_capture_source,
4580 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004581 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004582 .mixers = { alc880_three_stack_mixer,
4583 alc880_five_stack_mixer},
4584 .init_verbs = { alc880_volume_init_verbs,
4585 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004586 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4587 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004588 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4589 .channel_mode = alc880_fivestack_modes,
4590 .input_mux = &alc880_capture_source,
4591 },
4592 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004593 .mixers = { alc880_three_stack_mixer,
4594 alc880_five_stack_mixer },
4595 .init_verbs = { alc880_volume_init_verbs,
4596 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004597 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4598 .dac_nids = alc880_dac_nids,
4599 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004600 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4601 .channel_mode = alc880_fivestack_modes,
4602 .input_mux = &alc880_capture_source,
4603 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004604 [ALC880_6ST] = {
4605 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004606 .init_verbs = { alc880_volume_init_verbs,
4607 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004608 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4609 .dac_nids = alc880_6st_dac_nids,
4610 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4611 .channel_mode = alc880_sixstack_modes,
4612 .input_mux = &alc880_6stack_capture_source,
4613 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004614 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004615 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004616 .init_verbs = { alc880_volume_init_verbs,
4617 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004618 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4619 .dac_nids = alc880_6st_dac_nids,
4620 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004621 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4622 .channel_mode = alc880_sixstack_modes,
4623 .input_mux = &alc880_6stack_capture_source,
4624 },
4625 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004626 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004627 .init_verbs = { alc880_volume_init_verbs,
4628 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004629 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004630 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4631 .dac_nids = alc880_w810_dac_nids,
4632 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004633 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4634 .channel_mode = alc880_w810_modes,
4635 .input_mux = &alc880_capture_source,
4636 },
4637 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004638 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004639 .init_verbs = { alc880_volume_init_verbs,
4640 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004641 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4642 .dac_nids = alc880_z71v_dac_nids,
4643 .dig_out_nid = ALC880_DIGOUT_NID,
4644 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004645 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4646 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004647 .input_mux = &alc880_capture_source,
4648 },
4649 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004650 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004651 .init_verbs = { alc880_volume_init_verbs,
4652 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004653 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4654 .dac_nids = alc880_f1734_dac_nids,
4655 .hp_nid = 0x02,
4656 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4657 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004658 .input_mux = &alc880_f1734_capture_source,
4659 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004660 .setup = alc880_uniwill_p53_setup,
4661 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004662 },
4663 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004664 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004665 .init_verbs = { alc880_volume_init_verbs,
4666 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004667 alc880_gpio1_init_verbs },
4668 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4669 .dac_nids = alc880_asus_dac_nids,
4670 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4671 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004672 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004673 .input_mux = &alc880_capture_source,
4674 },
4675 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004676 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004677 .init_verbs = { alc880_volume_init_verbs,
4678 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004679 alc880_gpio1_init_verbs },
4680 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4681 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004682 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004683 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4684 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004685 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004686 .input_mux = &alc880_capture_source,
4687 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004688 [ALC880_ASUS_DIG2] = {
4689 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004690 .init_verbs = { alc880_volume_init_verbs,
4691 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004692 alc880_gpio2_init_verbs }, /* use GPIO2 */
4693 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4694 .dac_nids = alc880_asus_dac_nids,
4695 .dig_out_nid = ALC880_DIGOUT_NID,
4696 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4697 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004698 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004699 .input_mux = &alc880_capture_source,
4700 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004701 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004702 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004703 .init_verbs = { alc880_volume_init_verbs,
4704 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004705 alc880_gpio1_init_verbs },
4706 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4707 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004708 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004709 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4710 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004711 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004712 .input_mux = &alc880_capture_source,
4713 },
4714 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004715 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004716 .init_verbs = { alc880_volume_init_verbs,
4717 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004718 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4719 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004720 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004721 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4722 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004723 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004724 .input_mux = &alc880_capture_source,
4725 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004726 [ALC880_UNIWILL] = {
4727 .mixers = { alc880_uniwill_mixer },
4728 .init_verbs = { alc880_volume_init_verbs,
4729 alc880_uniwill_init_verbs },
4730 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4731 .dac_nids = alc880_asus_dac_nids,
4732 .dig_out_nid = ALC880_DIGOUT_NID,
4733 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4734 .channel_mode = alc880_threestack_modes,
4735 .need_dac_fix = 1,
4736 .input_mux = &alc880_capture_source,
4737 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004738 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004739 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004740 },
4741 [ALC880_UNIWILL_P53] = {
4742 .mixers = { alc880_uniwill_p53_mixer },
4743 .init_verbs = { alc880_volume_init_verbs,
4744 alc880_uniwill_p53_init_verbs },
4745 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4746 .dac_nids = alc880_asus_dac_nids,
4747 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004748 .channel_mode = alc880_threestack_modes,
4749 .input_mux = &alc880_capture_source,
4750 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004751 .setup = alc880_uniwill_p53_setup,
4752 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004753 },
4754 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004755 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004756 .init_verbs = { alc880_volume_init_verbs,
4757 alc880_uniwill_p53_init_verbs,
4758 alc880_beep_init_verbs },
4759 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4760 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004761 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004762 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4763 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004764 .input_mux = &alc880_capture_source,
4765 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004766 .setup = alc880_uniwill_p53_setup,
4767 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004768 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004769 [ALC880_CLEVO] = {
4770 .mixers = { alc880_three_stack_mixer },
4771 .init_verbs = { alc880_volume_init_verbs,
4772 alc880_pin_clevo_init_verbs },
4773 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4774 .dac_nids = alc880_dac_nids,
4775 .hp_nid = 0x03,
4776 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4777 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004778 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004779 .input_mux = &alc880_capture_source,
4780 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004781 [ALC880_LG] = {
4782 .mixers = { alc880_lg_mixer },
4783 .init_verbs = { alc880_volume_init_verbs,
4784 alc880_lg_init_verbs },
4785 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4786 .dac_nids = alc880_lg_dac_nids,
4787 .dig_out_nid = ALC880_DIGOUT_NID,
4788 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4789 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004790 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004791 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004792 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004793 .setup = alc880_lg_setup,
4794 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004795#ifdef CONFIG_SND_HDA_POWER_SAVE
4796 .loopbacks = alc880_lg_loopbacks,
4797#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004798 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004799 [ALC880_LG_LW] = {
4800 .mixers = { alc880_lg_lw_mixer },
4801 .init_verbs = { alc880_volume_init_verbs,
4802 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004803 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004804 .dac_nids = alc880_dac_nids,
4805 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004806 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4807 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004808 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004809 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004810 .setup = alc880_lg_lw_setup,
4811 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004812 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004813 [ALC880_MEDION_RIM] = {
4814 .mixers = { alc880_medion_rim_mixer },
4815 .init_verbs = { alc880_volume_init_verbs,
4816 alc880_medion_rim_init_verbs,
4817 alc_gpio2_init_verbs },
4818 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4819 .dac_nids = alc880_dac_nids,
4820 .dig_out_nid = ALC880_DIGOUT_NID,
4821 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4822 .channel_mode = alc880_2_jack_modes,
4823 .input_mux = &alc880_medion_rim_capture_source,
4824 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004825 .setup = alc880_medion_rim_setup,
4826 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004827 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004828#ifdef CONFIG_SND_DEBUG
4829 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004830 .mixers = { alc880_test_mixer },
4831 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004832 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4833 .dac_nids = alc880_test_dac_nids,
4834 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004835 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4836 .channel_mode = alc880_test_modes,
4837 .input_mux = &alc880_test_capture_source,
4838 },
4839#endif
4840};
4841
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004842/*
4843 * Automatic parse of I/O pins from the BIOS configuration
4844 */
4845
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004846enum {
4847 ALC_CTL_WIDGET_VOL,
4848 ALC_CTL_WIDGET_MUTE,
4849 ALC_CTL_BIND_MUTE,
4850};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004851static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004852 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4853 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004854 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004855};
4856
4857/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004858static int add_control(struct alc_spec *spec, int type, const char *name,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004859 int cidx, unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004860{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004861 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004862
Takashi Iwai603c4012008-07-30 15:01:44 +02004863 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4864 knew = snd_array_new(&spec->kctls);
4865 if (!knew)
4866 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004867 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004868 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004869 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004870 return -ENOMEM;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004871 knew->index = cidx;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004872 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004873 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004874 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004875 return 0;
4876}
4877
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004878static int add_control_with_pfx(struct alc_spec *spec, int type,
4879 const char *pfx, const char *dir,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004880 const char *sfx, int cidx, unsigned long val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004881{
4882 char name[32];
4883 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004884 return add_control(spec, type, name, cidx, val);
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004885}
4886
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004887#define add_pb_vol_ctrl(spec, type, pfx, val) \
4888 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
4889#define add_pb_sw_ctrl(spec, type, pfx, val) \
4890 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
4891#define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
4892 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
4893#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
4894 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004895
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004896#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4897#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4898#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4899#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004900#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4901#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4902#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4903#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4904#define ALC880_PIN_CD_NID 0x1c
4905
4906/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004907static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4908 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004909{
4910 hda_nid_t nid;
4911 int assigned[4];
4912 int i, j;
4913
4914 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004915 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004916
4917 /* check the pins hardwired to audio widget */
4918 for (i = 0; i < cfg->line_outs; i++) {
4919 nid = cfg->line_out_pins[i];
4920 if (alc880_is_fixed_pin(nid)) {
4921 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004922 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004923 assigned[idx] = 1;
4924 }
4925 }
4926 /* left pins can be connect to any audio widget */
4927 for (i = 0; i < cfg->line_outs; i++) {
4928 nid = cfg->line_out_pins[i];
4929 if (alc880_is_fixed_pin(nid))
4930 continue;
4931 /* search for an empty channel */
4932 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004933 if (!assigned[j]) {
4934 spec->multiout.dac_nids[i] =
4935 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004936 assigned[j] = 1;
4937 break;
4938 }
4939 }
4940 }
4941 spec->multiout.num_dacs = cfg->line_outs;
4942 return 0;
4943}
4944
4945/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004946static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4947 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004948{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004949 static const char *chname[4] = {
4950 "Front", "Surround", NULL /*CLFE*/, "Side"
4951 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004952 hda_nid_t nid;
4953 int i, err;
4954
4955 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004956 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004957 continue;
4958 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4959 if (i == 2) {
4960 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004961 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4962 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004963 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4964 HDA_OUTPUT));
4965 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004966 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004967 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4968 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004969 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4970 HDA_OUTPUT));
4971 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004972 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004973 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4974 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004975 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4976 HDA_INPUT));
4977 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004978 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004979 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4980 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004981 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4982 HDA_INPUT));
4983 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004984 return err;
4985 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004986 const char *pfx;
4987 if (cfg->line_outs == 1 &&
4988 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4989 pfx = "Speaker";
4990 else
4991 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004992 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004993 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4994 HDA_OUTPUT));
4995 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004996 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004997 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004998 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4999 HDA_INPUT));
5000 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005001 return err;
5002 }
5003 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005004 return 0;
5005}
5006
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005007/* add playback controls for speaker and HP outputs */
5008static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
5009 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005010{
5011 hda_nid_t nid;
5012 int err;
5013
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005014 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005015 return 0;
5016
5017 if (alc880_is_fixed_pin(pin)) {
5018 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01005019 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005020 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005021 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005022 else
5023 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005024 /* control HP volume/switch on the output mixer amp */
5025 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005026 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005027 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
5028 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005029 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005030 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005031 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
5032 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005033 return err;
5034 } else if (alc880_is_multi_pin(pin)) {
5035 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005036 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005037 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005038 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
5039 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005040 return err;
5041 }
5042 return 0;
5043}
5044
5045/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005046static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005047 const char *ctlname, int ctlidx,
Kailang Yangdf694da2005-12-05 19:42:22 +01005048 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005049{
Kailang Yangdf694da2005-12-05 19:42:22 +01005050 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005051
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005052 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005053 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5054 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005055 return err;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005056 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005057 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5058 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005059 return err;
5060 return 0;
5061}
5062
Takashi Iwai05f5f472009-08-25 13:10:18 +02005063static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005064{
Takashi Iwai05f5f472009-08-25 13:10:18 +02005065 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
5066 return (pincap & AC_PINCAP_IN) != 0;
5067}
5068
5069/* create playback/capture controls for input pins */
5070static int alc_auto_create_input_ctls(struct hda_codec *codec,
5071 const struct auto_pin_cfg *cfg,
5072 hda_nid_t mixer,
5073 hda_nid_t cap1, hda_nid_t cap2)
5074{
5075 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005076 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005077 int i, err, idx, type, type_idx = 0;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005078
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005079 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02005080 hda_nid_t pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005081 const char *label;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005082
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005083 pin = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005084 if (!alc_is_input_pin(codec, pin))
5085 continue;
5086
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005087 type = cfg->inputs[i].type;
5088 if (i > 0 && type == cfg->inputs[i - 1].type)
5089 type_idx++;
5090 else
5091 type_idx = 0;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005092 label = hda_get_autocfg_input_label(codec, cfg, i);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005093 if (mixer) {
5094 idx = get_connection_index(codec, mixer, pin);
5095 if (idx >= 0) {
5096 err = new_analog_input(spec, pin,
Takashi Iwai10a20af2010-09-09 16:28:02 +02005097 label, type_idx,
5098 idx, mixer);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005099 if (err < 0)
5100 return err;
5101 }
5102 }
5103
5104 if (!cap1)
5105 continue;
5106 idx = get_connection_index(codec, cap1, pin);
5107 if (idx < 0 && cap2)
5108 idx = get_connection_index(codec, cap2, pin);
Takashi Iwai10a20af2010-09-09 16:28:02 +02005109 if (idx >= 0)
5110 snd_hda_add_imux_item(imux, label, idx, NULL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005111 }
5112 return 0;
5113}
5114
Takashi Iwai05f5f472009-08-25 13:10:18 +02005115static int alc880_auto_create_input_ctls(struct hda_codec *codec,
5116 const struct auto_pin_cfg *cfg)
5117{
5118 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
5119}
5120
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005121static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
5122 unsigned int pin_type)
5123{
5124 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5125 pin_type);
5126 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01005127 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5128 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005129}
5130
Kailang Yangdf694da2005-12-05 19:42:22 +01005131static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
5132 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005133 int dac_idx)
5134{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005135 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005136 /* need the manual connection? */
5137 if (alc880_is_multi_pin(nid)) {
5138 struct alc_spec *spec = codec->spec;
5139 int idx = alc880_multi_pin_idx(nid);
5140 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
5141 AC_VERB_SET_CONNECT_SEL,
5142 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
5143 }
5144}
5145
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005146static int get_pin_type(int line_out_type)
5147{
5148 if (line_out_type == AUTO_PIN_HP_OUT)
5149 return PIN_HP;
5150 else
5151 return PIN_OUT;
5152}
5153
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005154static void alc880_auto_init_multi_out(struct hda_codec *codec)
5155{
5156 struct alc_spec *spec = codec->spec;
5157 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005158
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005159 for (i = 0; i < spec->autocfg.line_outs; i++) {
5160 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005161 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5162 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005163 }
5164}
5165
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005166static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005167{
5168 struct alc_spec *spec = codec->spec;
5169 hda_nid_t pin;
5170
Takashi Iwai82bc9552006-03-21 11:24:42 +01005171 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005172 if (pin) /* connect to front */
5173 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005174 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005175 if (pin) /* connect to front */
5176 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5177}
5178
5179static void alc880_auto_init_analog_input(struct hda_codec *codec)
5180{
5181 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005182 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005183 int i;
5184
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005185 for (i = 0; i < cfg->num_inputs; i++) {
5186 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005187 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02005188 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005189 if (nid != ALC880_PIN_CD_NID &&
5190 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005191 snd_hda_codec_write(codec, nid, 0,
5192 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005193 AMP_OUT_MUTE);
5194 }
5195 }
5196}
5197
Takashi Iwai7f311a42010-04-09 17:32:23 +02005198static void alc880_auto_init_input_src(struct hda_codec *codec)
5199{
5200 struct alc_spec *spec = codec->spec;
5201 int c;
5202
5203 for (c = 0; c < spec->num_adc_nids; c++) {
5204 unsigned int mux_idx;
5205 const struct hda_input_mux *imux;
5206 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5207 imux = &spec->input_mux[mux_idx];
5208 if (!imux->num_items && mux_idx > 0)
5209 imux = &spec->input_mux[0];
5210 if (imux)
5211 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5212 AC_VERB_SET_CONNECT_SEL,
5213 imux->items[0].index);
5214 }
5215}
5216
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005217/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005218/* return 1 if successful, 0 if the proper config is not found,
5219 * or a negative error code
5220 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005221static int alc880_parse_auto_config(struct hda_codec *codec)
5222{
5223 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005224 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005225 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005226
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005227 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5228 alc880_ignore);
5229 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005230 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005231 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005232 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005233
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005234 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5235 if (err < 0)
5236 return err;
5237 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5238 if (err < 0)
5239 return err;
5240 err = alc880_auto_create_extra_out(spec,
5241 spec->autocfg.speaker_pins[0],
5242 "Speaker");
5243 if (err < 0)
5244 return err;
5245 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5246 "Headphone");
5247 if (err < 0)
5248 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005249 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005250 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005251 return err;
5252
5253 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5254
Takashi Iwai757899a2010-07-30 10:48:14 +02005255 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005256
Takashi Iwai603c4012008-07-30 15:01:44 +02005257 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005258 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005259
Takashi Iwaid88897e2008-10-31 15:01:37 +01005260 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005261
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005262 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005263 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005264
Kailang Yang6227cdc2010-02-25 08:36:52 +01005265 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005266
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005267 return 1;
5268}
5269
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005270/* additional initialization for auto-configuration model */
5271static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005272{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005273 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005274 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005275 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005276 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005277 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005278 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005279 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005280 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005281}
5282
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005283/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5284 * one of two digital mic pins, e.g. on ALC272
5285 */
5286static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005287{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005288 struct alc_spec *spec = codec->spec;
5289 int i;
5290
5291 for (i = 0; i < spec->num_adc_nids; i++) {
5292 hda_nid_t cap = spec->capsrc_nids ?
5293 spec->capsrc_nids[i] : spec->adc_nids[i];
5294 int iidx, eidx;
5295
5296 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5297 if (iidx < 0)
5298 continue;
5299 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5300 if (eidx < 0)
5301 continue;
5302 spec->int_mic.mux_idx = iidx;
5303 spec->ext_mic.mux_idx = eidx;
5304 if (spec->capsrc_nids)
5305 spec->capsrc_nids += i;
5306 spec->adc_nids += i;
5307 spec->num_adc_nids = 1;
5308 return;
5309 }
5310 snd_printd(KERN_INFO "hda_codec: %s: "
5311 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5312 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5313 spec->auto_mic = 0; /* disable auto-mic to be sure */
5314}
5315
Takashi Iwai748cce42010-08-04 07:37:39 +02005316/* select or unmute the given capsrc route */
5317static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5318 int idx)
5319{
5320 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5321 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5322 HDA_AMP_MUTE, 0);
5323 } else {
5324 snd_hda_codec_write_cache(codec, cap, 0,
5325 AC_VERB_SET_CONNECT_SEL, idx);
5326 }
5327}
5328
Takashi Iwai840b64c2010-07-13 22:49:01 +02005329/* set the default connection to that pin */
5330static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5331{
5332 struct alc_spec *spec = codec->spec;
5333 int i;
5334
5335 for (i = 0; i < spec->num_adc_nids; i++) {
5336 hda_nid_t cap = spec->capsrc_nids ?
5337 spec->capsrc_nids[i] : spec->adc_nids[i];
5338 int idx;
5339
5340 idx = get_connection_index(codec, cap, pin);
5341 if (idx < 0)
5342 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005343 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005344 return i; /* return the found index */
5345 }
5346 return -1; /* not found */
5347}
5348
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005349/* choose the ADC/MUX containing the input pin and initialize the setup */
5350static void fixup_single_adc(struct hda_codec *codec)
5351{
5352 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005353 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005354 int i;
5355
5356 /* search for the input pin; there must be only one */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005357 if (cfg->num_inputs != 1)
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005358 return;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005359 i = init_capsrc_for_pin(codec, cfg->inputs[0].pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005360 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005361 /* use only this ADC */
5362 if (spec->capsrc_nids)
5363 spec->capsrc_nids += i;
5364 spec->adc_nids += i;
5365 spec->num_adc_nids = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005366 }
5367}
5368
Takashi Iwai840b64c2010-07-13 22:49:01 +02005369/* initialize dual adcs */
5370static void fixup_dual_adc_switch(struct hda_codec *codec)
5371{
5372 struct alc_spec *spec = codec->spec;
5373 init_capsrc_for_pin(codec, spec->ext_mic.pin);
5374 init_capsrc_for_pin(codec, spec->int_mic.pin);
5375}
5376
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005377static void set_capture_mixer(struct hda_codec *codec)
5378{
5379 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005380 static struct snd_kcontrol_new *caps[2][3] = {
5381 { alc_capture_mixer_nosrc1,
5382 alc_capture_mixer_nosrc2,
5383 alc_capture_mixer_nosrc3 },
5384 { alc_capture_mixer1,
5385 alc_capture_mixer2,
5386 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005387 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005388 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005389 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005390 int num_adcs = spec->num_adc_nids;
5391 if (spec->dual_adc_switch)
5392 fixup_dual_adc_switch(codec);
5393 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005394 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005395 else if (spec->input_mux) {
5396 if (spec->input_mux->num_items > 1)
5397 mux = 1;
5398 else if (spec->input_mux->num_items == 1)
5399 fixup_single_adc(codec);
5400 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005401 if (spec->dual_adc_switch)
5402 num_adcs = 1;
5403 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005404 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005405}
5406
Takashi Iwai66946352010-03-29 17:21:45 +02005407/* fill adc_nids (and capsrc_nids) containing all active input pins */
5408static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5409 int num_nids)
5410{
5411 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005412 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai66946352010-03-29 17:21:45 +02005413 int n;
5414 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5415
5416 for (n = 0; n < num_nids; n++) {
5417 hda_nid_t adc, cap;
5418 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5419 int nconns, i, j;
5420
5421 adc = nids[n];
5422 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5423 continue;
5424 cap = adc;
5425 nconns = snd_hda_get_connections(codec, cap, conn,
5426 ARRAY_SIZE(conn));
5427 if (nconns == 1) {
5428 cap = conn[0];
5429 nconns = snd_hda_get_connections(codec, cap, conn,
5430 ARRAY_SIZE(conn));
5431 }
5432 if (nconns <= 0)
5433 continue;
5434 if (!fallback_adc) {
5435 fallback_adc = adc;
5436 fallback_cap = cap;
5437 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005438 for (i = 0; i < cfg->num_inputs; i++) {
5439 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai66946352010-03-29 17:21:45 +02005440 for (j = 0; j < nconns; j++) {
5441 if (conn[j] == nid)
5442 break;
5443 }
5444 if (j >= nconns)
5445 break;
5446 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005447 if (i >= cfg->num_inputs) {
Takashi Iwai66946352010-03-29 17:21:45 +02005448 int num_adcs = spec->num_adc_nids;
5449 spec->private_adc_nids[num_adcs] = adc;
5450 spec->private_capsrc_nids[num_adcs] = cap;
5451 spec->num_adc_nids++;
5452 spec->adc_nids = spec->private_adc_nids;
5453 if (adc != cap)
5454 spec->capsrc_nids = spec->private_capsrc_nids;
5455 }
5456 }
5457 if (!spec->num_adc_nids) {
5458 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005459 " using fallback 0x%x\n",
5460 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005461 spec->private_adc_nids[0] = fallback_adc;
5462 spec->adc_nids = spec->private_adc_nids;
5463 if (fallback_adc != fallback_cap) {
5464 spec->private_capsrc_nids[0] = fallback_cap;
5465 spec->capsrc_nids = spec->private_adc_nids;
5466 }
5467 }
5468}
5469
Takashi Iwai67d634c2009-11-16 15:35:59 +01005470#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005471#define set_beep_amp(spec, nid, idx, dir) \
5472 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005473
5474static struct snd_pci_quirk beep_white_list[] = {
5475 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005476 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005477 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005478 {}
5479};
5480
5481static inline int has_cdefine_beep(struct hda_codec *codec)
5482{
5483 struct alc_spec *spec = codec->spec;
5484 const struct snd_pci_quirk *q;
5485 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5486 if (q)
5487 return q->value;
5488 return spec->cdefine.enable_pcbeep;
5489}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005490#else
5491#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005492#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005493#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005494
5495/*
5496 * OK, here we have finally the patch for ALC880
5497 */
5498
Linus Torvalds1da177e2005-04-16 15:20:36 -07005499static int patch_alc880(struct hda_codec *codec)
5500{
5501 struct alc_spec *spec;
5502 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005503 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005504
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005505 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005506 if (spec == NULL)
5507 return -ENOMEM;
5508
5509 codec->spec = spec;
5510
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005511 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5512 alc880_models,
5513 alc880_cfg_tbl);
5514 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005515 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5516 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005517 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005518 }
5519
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005520 if (board_config == ALC880_AUTO) {
5521 /* automatic parse from the BIOS config */
5522 err = alc880_parse_auto_config(codec);
5523 if (err < 0) {
5524 alc_free(codec);
5525 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005526 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005527 printk(KERN_INFO
5528 "hda_codec: Cannot set up configuration "
5529 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005530 board_config = ALC880_3ST;
5531 }
5532 }
5533
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005534 err = snd_hda_attach_beep_device(codec, 0x1);
5535 if (err < 0) {
5536 alc_free(codec);
5537 return err;
5538 }
5539
Kailang Yangdf694da2005-12-05 19:42:22 +01005540 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005541 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005542
Linus Torvalds1da177e2005-04-16 15:20:36 -07005543 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5544 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005545 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005546
Linus Torvalds1da177e2005-04-16 15:20:36 -07005547 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5548 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5549
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005550 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005551 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005552 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005553 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005554 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005555 if (wcap != AC_WID_AUD_IN) {
5556 spec->adc_nids = alc880_adc_nids_alt;
5557 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005558 } else {
5559 spec->adc_nids = alc880_adc_nids;
5560 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005561 }
5562 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005563 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005564 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005565
Takashi Iwai2134ea42008-01-10 16:53:55 +01005566 spec->vmaster_nid = 0x0c;
5567
Linus Torvalds1da177e2005-04-16 15:20:36 -07005568 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005569 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005570 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005571#ifdef CONFIG_SND_HDA_POWER_SAVE
5572 if (!spec->loopback.amplist)
5573 spec->loopback.amplist = alc880_loopbacks;
5574#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005575
5576 return 0;
5577}
5578
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005579
Linus Torvalds1da177e2005-04-16 15:20:36 -07005580/*
5581 * ALC260 support
5582 */
5583
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005584static hda_nid_t alc260_dac_nids[1] = {
5585 /* front */
5586 0x02,
5587};
5588
5589static hda_nid_t alc260_adc_nids[1] = {
5590 /* ADC0 */
5591 0x04,
5592};
5593
Kailang Yangdf694da2005-12-05 19:42:22 +01005594static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005595 /* ADC1 */
5596 0x05,
5597};
5598
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005599/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5600 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5601 */
5602static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005603 /* ADC0, ADC1 */
5604 0x04, 0x05
5605};
5606
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005607#define ALC260_DIGOUT_NID 0x03
5608#define ALC260_DIGIN_NID 0x06
5609
5610static struct hda_input_mux alc260_capture_source = {
5611 .num_items = 4,
5612 .items = {
5613 { "Mic", 0x0 },
5614 { "Front Mic", 0x1 },
5615 { "Line", 0x2 },
5616 { "CD", 0x4 },
5617 },
5618};
5619
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005620/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005621 * headphone jack and the internal CD lines since these are the only pins at
5622 * which audio can appear. For flexibility, also allow the option of
5623 * recording the mixer output on the second ADC (ADC0 doesn't have a
5624 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005625 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005626static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5627 {
5628 .num_items = 3,
5629 .items = {
5630 { "Mic/Line", 0x0 },
5631 { "CD", 0x4 },
5632 { "Headphone", 0x2 },
5633 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005634 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005635 {
5636 .num_items = 4,
5637 .items = {
5638 { "Mic/Line", 0x0 },
5639 { "CD", 0x4 },
5640 { "Headphone", 0x2 },
5641 { "Mixer", 0x5 },
5642 },
5643 },
5644
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005645};
5646
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005647/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5648 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005649 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005650static struct hda_input_mux alc260_acer_capture_sources[2] = {
5651 {
5652 .num_items = 4,
5653 .items = {
5654 { "Mic", 0x0 },
5655 { "Line", 0x2 },
5656 { "CD", 0x4 },
5657 { "Headphone", 0x5 },
5658 },
5659 },
5660 {
5661 .num_items = 5,
5662 .items = {
5663 { "Mic", 0x0 },
5664 { "Line", 0x2 },
5665 { "CD", 0x4 },
5666 { "Headphone", 0x6 },
5667 { "Mixer", 0x5 },
5668 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005669 },
5670};
Michael Schwingencc959482009-02-22 18:58:45 +01005671
5672/* Maxdata Favorit 100XS */
5673static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5674 {
5675 .num_items = 2,
5676 .items = {
5677 { "Line/Mic", 0x0 },
5678 { "CD", 0x4 },
5679 },
5680 },
5681 {
5682 .num_items = 3,
5683 .items = {
5684 { "Line/Mic", 0x0 },
5685 { "CD", 0x4 },
5686 { "Mixer", 0x5 },
5687 },
5688 },
5689};
5690
Linus Torvalds1da177e2005-04-16 15:20:36 -07005691/*
5692 * This is just place-holder, so there's something for alc_build_pcms to look
5693 * at when it calculates the maximum number of channels. ALC260 has no mixer
5694 * element which allows changing the channel mode, so the verb list is
5695 * never used.
5696 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005697static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005698 { 2, NULL },
5699};
5700
Kailang Yangdf694da2005-12-05 19:42:22 +01005701
5702/* Mixer combinations
5703 *
5704 * basic: base_output + input + pc_beep + capture
5705 * HP: base_output + input + capture_alt
5706 * HP_3013: hp_3013 + input + capture
5707 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005708 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005709 */
5710
5711static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005712 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005713 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005714 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5715 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5716 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5717 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5718 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005719};
Kailang Yangdf694da2005-12-05 19:42:22 +01005720
5721static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005722 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5723 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5724 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5725 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5726 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5727 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5728 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5729 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005730 { } /* end */
5731};
5732
Takashi Iwaibec15c32008-01-28 18:16:30 +01005733/* update HP, line and mono out pins according to the master switch */
5734static void alc260_hp_master_update(struct hda_codec *codec,
5735 hda_nid_t hp, hda_nid_t line,
5736 hda_nid_t mono)
5737{
5738 struct alc_spec *spec = codec->spec;
5739 unsigned int val = spec->master_sw ? PIN_HP : 0;
5740 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005741 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005742 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005743 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005744 val);
5745 /* mono (speaker) depending on the HP jack sense */
5746 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005747 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005748 val);
5749}
5750
5751static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5752 struct snd_ctl_elem_value *ucontrol)
5753{
5754 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5755 struct alc_spec *spec = codec->spec;
5756 *ucontrol->value.integer.value = spec->master_sw;
5757 return 0;
5758}
5759
5760static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5761 struct snd_ctl_elem_value *ucontrol)
5762{
5763 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5764 struct alc_spec *spec = codec->spec;
5765 int val = !!*ucontrol->value.integer.value;
5766 hda_nid_t hp, line, mono;
5767
5768 if (val == spec->master_sw)
5769 return 0;
5770 spec->master_sw = val;
5771 hp = (kcontrol->private_value >> 16) & 0xff;
5772 line = (kcontrol->private_value >> 8) & 0xff;
5773 mono = kcontrol->private_value & 0xff;
5774 alc260_hp_master_update(codec, hp, line, mono);
5775 return 1;
5776}
5777
5778static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5779 {
5780 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5781 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005782 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005783 .info = snd_ctl_boolean_mono_info,
5784 .get = alc260_hp_master_sw_get,
5785 .put = alc260_hp_master_sw_put,
5786 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5787 },
5788 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5789 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5790 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5791 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5792 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5793 HDA_OUTPUT),
5794 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5795 { } /* end */
5796};
5797
5798static struct hda_verb alc260_hp_unsol_verbs[] = {
5799 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5800 {},
5801};
5802
5803static void alc260_hp_automute(struct hda_codec *codec)
5804{
5805 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005806
Wu Fengguang864f92b2009-11-18 12:38:02 +08005807 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005808 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5809}
5810
5811static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5812{
5813 if ((res >> 26) == ALC880_HP_EVENT)
5814 alc260_hp_automute(codec);
5815}
5816
Kailang Yangdf694da2005-12-05 19:42:22 +01005817static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005818 {
5819 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5820 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005821 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005822 .info = snd_ctl_boolean_mono_info,
5823 .get = alc260_hp_master_sw_get,
5824 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005825 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005826 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005827 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5828 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5829 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5830 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5831 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5832 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005833 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5834 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005835 { } /* end */
5836};
5837
Kailang Yang3f878302008-08-26 13:02:23 +02005838static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5839 .ops = &snd_hda_bind_vol,
5840 .values = {
5841 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5842 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5843 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5844 0
5845 },
5846};
5847
5848static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5849 .ops = &snd_hda_bind_sw,
5850 .values = {
5851 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5852 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5853 0
5854 },
5855};
5856
5857static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5858 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5859 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5860 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5861 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5862 { } /* end */
5863};
5864
Takashi Iwaibec15c32008-01-28 18:16:30 +01005865static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5866 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5867 {},
5868};
5869
5870static void alc260_hp_3013_automute(struct hda_codec *codec)
5871{
5872 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005873
Wu Fengguang864f92b2009-11-18 12:38:02 +08005874 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005875 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005876}
5877
5878static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5879 unsigned int res)
5880{
5881 if ((res >> 26) == ALC880_HP_EVENT)
5882 alc260_hp_3013_automute(codec);
5883}
5884
Kailang Yang3f878302008-08-26 13:02:23 +02005885static void alc260_hp_3012_automute(struct hda_codec *codec)
5886{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005887 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005888
Kailang Yang3f878302008-08-26 13:02:23 +02005889 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5890 bits);
5891 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5892 bits);
5893 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5894 bits);
5895}
5896
5897static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5898 unsigned int res)
5899{
5900 if ((res >> 26) == ALC880_HP_EVENT)
5901 alc260_hp_3012_automute(codec);
5902}
5903
5904/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005905 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5906 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005907static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005908 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005909 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005910 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005911 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5912 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5913 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5914 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005915 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005916 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5917 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005918 { } /* end */
5919};
5920
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005921/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5922 * versions of the ALC260 don't act on requests to enable mic bias from NID
5923 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5924 * datasheet doesn't mention this restriction. At this stage it's not clear
5925 * whether this behaviour is intentional or is a hardware bug in chip
5926 * revisions available in early 2006. Therefore for now allow the
5927 * "Headphone Jack Mode" control to span all choices, but if it turns out
5928 * that the lack of mic bias for this NID is intentional we could change the
5929 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5930 *
5931 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5932 * don't appear to make the mic bias available from the "line" jack, even
5933 * though the NID used for this jack (0x14) can supply it. The theory is
5934 * that perhaps Acer have included blocking capacitors between the ALC260
5935 * and the output jack. If this turns out to be the case for all such
5936 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5937 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005938 *
5939 * The C20x Tablet series have a mono internal speaker which is controlled
5940 * via the chip's Mono sum widget and pin complex, so include the necessary
5941 * controls for such models. On models without a "mono speaker" the control
5942 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005943 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005944static struct snd_kcontrol_new alc260_acer_mixer[] = {
5945 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5946 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005947 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005948 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005949 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005950 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005951 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005952 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5953 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5954 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5955 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5956 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5957 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5958 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5959 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005960 { } /* end */
5961};
5962
Michael Schwingencc959482009-02-22 18:58:45 +01005963/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5964 */
5965static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5966 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5967 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5968 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5969 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5970 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5971 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5972 { } /* end */
5973};
5974
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005975/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5976 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5977 */
5978static struct snd_kcontrol_new alc260_will_mixer[] = {
5979 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5980 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5981 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5982 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5983 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5984 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5985 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5986 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5987 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5988 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005989 { } /* end */
5990};
5991
5992/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5993 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5994 */
5995static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5996 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5997 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5998 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5999 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6000 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6001 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
6002 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
6003 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6004 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6005 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6006 { } /* end */
6007};
6008
Kailang Yangdf694da2005-12-05 19:42:22 +01006009/*
6010 * initialization verbs
6011 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006012static struct hda_verb alc260_init_verbs[] = {
6013 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006014 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006015 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006016 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006017 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006018 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006019 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006020 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006021 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02006022 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006023 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01006024 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006025 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02006026 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006027 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02006028 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006029 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02006030 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6031 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02006032 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006033 /* set connection select to line in (default select for this ADC) */
6034 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02006035 /* mute capture amp left and right */
6036 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6037 /* set connection select to line in (default select for this ADC) */
6038 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02006039 /* set vol=0 Line-Out mixer amp left and right */
6040 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6041 /* unmute pin widget amp left and right (no gain on this amp) */
6042 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6043 /* set vol=0 HP mixer amp left and right */
6044 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6045 /* unmute pin widget amp left and right (no gain on this amp) */
6046 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6047 /* set vol=0 Mono mixer amp left and right */
6048 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6049 /* unmute pin widget amp left and right (no gain on this amp) */
6050 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6051 /* unmute LINE-2 out pin */
6052 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006053 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6054 * Line In 2 = 0x03
6055 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006056 /* mute analog inputs */
6057 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6058 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6059 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6060 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6061 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006062 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006063 /* mute Front out path */
6064 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6065 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6066 /* mute Headphone out path */
6067 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6068 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6069 /* mute Mono out path */
6070 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6071 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006072 { }
6073};
6074
Takashi Iwai474167d2006-05-17 17:17:43 +02006075#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01006076static struct hda_verb alc260_hp_init_verbs[] = {
6077 /* Headphone and output */
6078 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6079 /* mono output */
6080 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6081 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6082 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6083 /* Mic2 (front panel) pin widget for input and vref at 80% */
6084 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6085 /* Line In pin widget for input */
6086 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6087 /* Line-2 pin widget for output */
6088 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6089 /* CD pin widget for input */
6090 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6091 /* unmute amp left and right */
6092 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6093 /* set connection select to line in (default select for this ADC) */
6094 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6095 /* unmute Line-Out mixer amp left and right (volume = 0) */
6096 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6097 /* mute pin widget amp left and right (no gain on this amp) */
6098 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6099 /* unmute HP mixer amp left and right (volume = 0) */
6100 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6101 /* mute pin widget amp left and right (no gain on this amp) */
6102 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006103 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6104 * Line In 2 = 0x03
6105 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006106 /* mute analog inputs */
6107 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6108 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6109 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6110 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6111 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006112 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6113 /* Unmute Front out path */
6114 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6115 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6116 /* Unmute Headphone out path */
6117 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6118 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6119 /* Unmute Mono out path */
6120 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6121 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6122 { }
6123};
Takashi Iwai474167d2006-05-17 17:17:43 +02006124#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006125
6126static struct hda_verb alc260_hp_3013_init_verbs[] = {
6127 /* Line out and output */
6128 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6129 /* mono output */
6130 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6131 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6132 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6133 /* Mic2 (front panel) pin widget for input and vref at 80% */
6134 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6135 /* Line In pin widget for input */
6136 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6137 /* Headphone pin widget for output */
6138 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6139 /* CD pin widget for input */
6140 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6141 /* unmute amp left and right */
6142 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6143 /* set connection select to line in (default select for this ADC) */
6144 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6145 /* unmute Line-Out mixer amp left and right (volume = 0) */
6146 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6147 /* mute pin widget amp left and right (no gain on this amp) */
6148 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6149 /* unmute HP mixer amp left and right (volume = 0) */
6150 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6151 /* mute pin widget amp left and right (no gain on this amp) */
6152 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006153 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6154 * Line In 2 = 0x03
6155 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006156 /* mute analog inputs */
6157 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6158 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6159 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6160 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6161 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006162 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6163 /* Unmute Front out path */
6164 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6165 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6166 /* Unmute Headphone out path */
6167 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6168 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6169 /* Unmute Mono out path */
6170 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6171 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6172 { }
6173};
6174
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006175/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006176 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6177 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006178 */
6179static struct hda_verb alc260_fujitsu_init_verbs[] = {
6180 /* Disable all GPIOs */
6181 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6182 /* Internal speaker is connected to headphone pin */
6183 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6184 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6185 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006186 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6187 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6188 /* Ensure all other unused pins are disabled and muted. */
6189 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6190 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006191 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006192 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006193 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006194 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6195 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6196 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006197
Jonathan Woithef7ace402006-02-28 11:46:14 +01006198 /* Disable digital (SPDIF) pins */
6199 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6200 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006201
Kailang Yangea1fb292008-08-26 12:58:38 +02006202 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006203 * when acting as an output.
6204 */
6205 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6206
6207 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006208 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6209 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6210 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6211 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6212 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6213 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6214 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6215 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6216 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006217
Jonathan Woithef7ace402006-02-28 11:46:14 +01006218 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6219 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6220 /* Unmute Line1 pin widget output buffer since it starts as an output.
6221 * If the pin mode is changed by the user the pin mode control will
6222 * take care of enabling the pin's input/output buffers as needed.
6223 * Therefore there's no need to enable the input buffer at this
6224 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006225 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006226 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006227 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006228 * mixer ctrl)
6229 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006230 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006231
Jonathan Woithef7ace402006-02-28 11:46:14 +01006232 /* Mute capture amp left and right */
6233 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006234 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006235 * in (on mic1 pin)
6236 */
6237 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006238
Jonathan Woithef7ace402006-02-28 11:46:14 +01006239 /* Do the same for the second ADC: mute capture input amp and
6240 * set ADC connection to line in (on mic1 pin)
6241 */
6242 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6243 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006244
Jonathan Woithef7ace402006-02-28 11:46:14 +01006245 /* Mute all inputs to mixer widget (even unconnected ones) */
6246 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6247 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6248 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6249 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6250 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6251 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6252 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6253 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006254
6255 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006256};
6257
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006258/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6259 * similar laptops (adapted from Fujitsu init verbs).
6260 */
6261static struct hda_verb alc260_acer_init_verbs[] = {
6262 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6263 * the headphone jack. Turn this on and rely on the standard mute
6264 * methods whenever the user wants to turn these outputs off.
6265 */
6266 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6267 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6268 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6269 /* Internal speaker/Headphone jack is connected to Line-out pin */
6270 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6271 /* Internal microphone/Mic jack is connected to Mic1 pin */
6272 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6273 /* Line In jack is connected to Line1 pin */
6274 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006275 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6276 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006277 /* Ensure all other unused pins are disabled and muted. */
6278 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6279 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006280 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6281 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6282 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6283 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6284 /* Disable digital (SPDIF) pins */
6285 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6286 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6287
Kailang Yangea1fb292008-08-26 12:58:38 +02006288 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006289 * bus when acting as outputs.
6290 */
6291 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6292 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6293
6294 /* Start with output sum widgets muted and their output gains at min */
6295 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6296 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6297 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6298 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6299 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6300 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6301 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6302 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6303 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6304
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006305 /* Unmute Line-out pin widget amp left and right
6306 * (no equiv mixer ctrl)
6307 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006308 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006309 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6310 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006311 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6312 * inputs. If the pin mode is changed by the user the pin mode control
6313 * will take care of enabling the pin's input/output buffers as needed.
6314 * Therefore there's no need to enable the input buffer at this
6315 * stage.
6316 */
6317 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6318 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6319
6320 /* Mute capture amp left and right */
6321 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6322 /* Set ADC connection select to match default mixer setting - mic
6323 * (on mic1 pin)
6324 */
6325 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6326
6327 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006328 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006329 */
6330 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006331 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006332
6333 /* Mute all inputs to mixer widget (even unconnected ones) */
6334 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6335 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6336 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6337 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6338 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6339 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6340 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6341 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6342
6343 { }
6344};
6345
Michael Schwingencc959482009-02-22 18:58:45 +01006346/* Initialisation sequence for Maxdata Favorit 100XS
6347 * (adapted from Acer init verbs).
6348 */
6349static struct hda_verb alc260_favorit100_init_verbs[] = {
6350 /* GPIO 0 enables the output jack.
6351 * Turn this on and rely on the standard mute
6352 * methods whenever the user wants to turn these outputs off.
6353 */
6354 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6355 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6356 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6357 /* Line/Mic input jack is connected to Mic1 pin */
6358 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6359 /* Ensure all other unused pins are disabled and muted. */
6360 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6361 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6362 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6363 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6364 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6365 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6366 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6367 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6368 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6369 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6370 /* Disable digital (SPDIF) pins */
6371 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6372 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6373
6374 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6375 * bus when acting as outputs.
6376 */
6377 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6378 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6379
6380 /* Start with output sum widgets muted and their output gains at min */
6381 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6382 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6383 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6384 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6385 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6386 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6387 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6388 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6389 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6390
6391 /* Unmute Line-out pin widget amp left and right
6392 * (no equiv mixer ctrl)
6393 */
6394 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6395 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6396 * inputs. If the pin mode is changed by the user the pin mode control
6397 * will take care of enabling the pin's input/output buffers as needed.
6398 * Therefore there's no need to enable the input buffer at this
6399 * stage.
6400 */
6401 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6402
6403 /* Mute capture amp left and right */
6404 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6405 /* Set ADC connection select to match default mixer setting - mic
6406 * (on mic1 pin)
6407 */
6408 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6409
6410 /* Do similar with the second ADC: mute capture input amp and
6411 * set ADC connection to mic to match ALSA's default state.
6412 */
6413 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6414 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6415
6416 /* Mute all inputs to mixer widget (even unconnected ones) */
6417 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6418 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6419 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6420 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6421 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6422 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6423 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6424 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6425
6426 { }
6427};
6428
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006429static struct hda_verb alc260_will_verbs[] = {
6430 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6431 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6432 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6433 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6434 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6435 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6436 {}
6437};
6438
6439static struct hda_verb alc260_replacer_672v_verbs[] = {
6440 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6441 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6442 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6443
6444 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6445 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6446 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6447
6448 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6449 {}
6450};
6451
6452/* toggle speaker-output according to the hp-jack state */
6453static void alc260_replacer_672v_automute(struct hda_codec *codec)
6454{
6455 unsigned int present;
6456
6457 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006458 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006459 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006460 snd_hda_codec_write_cache(codec, 0x01, 0,
6461 AC_VERB_SET_GPIO_DATA, 1);
6462 snd_hda_codec_write_cache(codec, 0x0f, 0,
6463 AC_VERB_SET_PIN_WIDGET_CONTROL,
6464 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006465 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006466 snd_hda_codec_write_cache(codec, 0x01, 0,
6467 AC_VERB_SET_GPIO_DATA, 0);
6468 snd_hda_codec_write_cache(codec, 0x0f, 0,
6469 AC_VERB_SET_PIN_WIDGET_CONTROL,
6470 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006471 }
6472}
6473
6474static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6475 unsigned int res)
6476{
6477 if ((res >> 26) == ALC880_HP_EVENT)
6478 alc260_replacer_672v_automute(codec);
6479}
6480
Kailang Yang3f878302008-08-26 13:02:23 +02006481static struct hda_verb alc260_hp_dc7600_verbs[] = {
6482 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6483 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6484 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6485 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6486 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6487 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6488 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6489 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6490 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6491 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6492 {}
6493};
6494
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006495/* Test configuration for debugging, modelled after the ALC880 test
6496 * configuration.
6497 */
6498#ifdef CONFIG_SND_DEBUG
6499static hda_nid_t alc260_test_dac_nids[1] = {
6500 0x02,
6501};
6502static hda_nid_t alc260_test_adc_nids[2] = {
6503 0x04, 0x05,
6504};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006505/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006506 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006507 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006508 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006509static struct hda_input_mux alc260_test_capture_sources[2] = {
6510 {
6511 .num_items = 7,
6512 .items = {
6513 { "MIC1 pin", 0x0 },
6514 { "MIC2 pin", 0x1 },
6515 { "LINE1 pin", 0x2 },
6516 { "LINE2 pin", 0x3 },
6517 { "CD pin", 0x4 },
6518 { "LINE-OUT pin", 0x5 },
6519 { "HP-OUT pin", 0x6 },
6520 },
6521 },
6522 {
6523 .num_items = 8,
6524 .items = {
6525 { "MIC1 pin", 0x0 },
6526 { "MIC2 pin", 0x1 },
6527 { "LINE1 pin", 0x2 },
6528 { "LINE2 pin", 0x3 },
6529 { "CD pin", 0x4 },
6530 { "Mixer", 0x5 },
6531 { "LINE-OUT pin", 0x6 },
6532 { "HP-OUT pin", 0x7 },
6533 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006534 },
6535};
6536static struct snd_kcontrol_new alc260_test_mixer[] = {
6537 /* Output driver widgets */
6538 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6539 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6540 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6541 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6542 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6543 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6544
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006545 /* Modes for retasking pin widgets
6546 * Note: the ALC260 doesn't seem to act on requests to enable mic
6547 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6548 * mention this restriction. At this stage it's not clear whether
6549 * this behaviour is intentional or is a hardware bug in chip
6550 * revisions available at least up until early 2006. Therefore for
6551 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6552 * choices, but if it turns out that the lack of mic bias for these
6553 * NIDs is intentional we could change their modes from
6554 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6555 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006556 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6557 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6558 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6559 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6560 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6561 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6562
6563 /* Loopback mixer controls */
6564 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6565 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6566 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6567 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6568 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6569 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6570 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6571 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6572 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6573 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006574 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6575 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6576 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6577 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006578
6579 /* Controls for GPIO pins, assuming they are configured as outputs */
6580 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6581 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6582 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6583 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6584
Jonathan Woithe92621f12006-02-28 11:47:47 +01006585 /* Switches to allow the digital IO pins to be enabled. The datasheet
6586 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006587 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006588 */
6589 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6590 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6591
Jonathan Woithef8225f62008-01-08 12:16:54 +01006592 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6593 * this output to turn on an external amplifier.
6594 */
6595 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6596 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6597
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006598 { } /* end */
6599};
6600static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006601 /* Enable all GPIOs as outputs with an initial value of 0 */
6602 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6603 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6604 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6605
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006606 /* Enable retasking pins as output, initially without power amp */
6607 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6608 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6609 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6610 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6611 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6612 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6613
Jonathan Woithe92621f12006-02-28 11:47:47 +01006614 /* Disable digital (SPDIF) pins initially, but users can enable
6615 * them via a mixer switch. In the case of SPDIF-out, this initverb
6616 * payload also sets the generation to 0, output to be in "consumer"
6617 * PCM format, copyright asserted, no pre-emphasis and no validity
6618 * control.
6619 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006620 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6621 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6622
Kailang Yangea1fb292008-08-26 12:58:38 +02006623 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006624 * OUT1 sum bus when acting as an output.
6625 */
6626 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6627 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6628 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6629 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6630
6631 /* Start with output sum widgets muted and their output gains at min */
6632 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6633 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6634 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6635 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6636 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6637 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6638 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6639 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6640 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6641
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006642 /* Unmute retasking pin widget output buffers since the default
6643 * state appears to be output. As the pin mode is changed by the
6644 * user the pin mode control will take care of enabling the pin's
6645 * input/output buffers as needed.
6646 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006647 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6648 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6649 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6650 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6651 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6652 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6653 /* Also unmute the mono-out pin widget */
6654 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6655
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006656 /* Mute capture amp left and right */
6657 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006658 /* Set ADC connection select to match default mixer setting (mic1
6659 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006660 */
6661 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6662
6663 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006664 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006665 */
6666 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6667 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6668
6669 /* Mute all inputs to mixer widget (even unconnected ones) */
6670 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6671 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6672 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6673 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6674 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6675 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6676 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6677 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6678
6679 { }
6680};
6681#endif
6682
Takashi Iwai63300792008-01-24 15:31:36 +01006683#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6684#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006685
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006686#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6687#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6688
Kailang Yangdf694da2005-12-05 19:42:22 +01006689/*
6690 * for BIOS auto-configuration
6691 */
6692
6693static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006694 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006695{
6696 hda_nid_t nid_vol;
6697 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006698 int err;
6699
6700 if (nid >= 0x0f && nid < 0x11) {
6701 nid_vol = nid - 0x7;
6702 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6703 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6704 } else if (nid == 0x11) {
6705 nid_vol = nid - 0x7;
6706 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6707 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6708 } else if (nid >= 0x12 && nid <= 0x15) {
6709 nid_vol = 0x08;
6710 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6711 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6712 } else
6713 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006714
Takashi Iwai863b4512008-10-21 17:01:47 +02006715 if (!(*vol_bits & (1 << nid_vol))) {
6716 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006717 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006718 if (err < 0)
6719 return err;
6720 *vol_bits |= (1 << nid_vol);
6721 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006722 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006723 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006724 return err;
6725 return 1;
6726}
6727
6728/* add playback controls from the parsed DAC table */
6729static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6730 const struct auto_pin_cfg *cfg)
6731{
6732 hda_nid_t nid;
6733 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006734 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006735
6736 spec->multiout.num_dacs = 1;
6737 spec->multiout.dac_nids = spec->private_dac_nids;
6738 spec->multiout.dac_nids[0] = 0x02;
6739
6740 nid = cfg->line_out_pins[0];
6741 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006742 const char *pfx;
6743 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6744 pfx = "Master";
6745 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6746 pfx = "Speaker";
6747 else
6748 pfx = "Front";
6749 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006750 if (err < 0)
6751 return err;
6752 }
6753
Takashi Iwai82bc9552006-03-21 11:24:42 +01006754 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006755 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006756 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006757 if (err < 0)
6758 return err;
6759 }
6760
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006761 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006762 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006763 err = alc260_add_playback_controls(spec, nid, "Headphone",
6764 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006765 if (err < 0)
6766 return err;
6767 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006768 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006769}
6770
6771/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006772static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006773 const struct auto_pin_cfg *cfg)
6774{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006775 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006776}
6777
6778static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6779 hda_nid_t nid, int pin_type,
6780 int sel_idx)
6781{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006782 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006783 /* need the manual connection? */
6784 if (nid >= 0x12) {
6785 int idx = nid - 0x12;
6786 snd_hda_codec_write(codec, idx + 0x0b, 0,
6787 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006788 }
6789}
6790
6791static void alc260_auto_init_multi_out(struct hda_codec *codec)
6792{
6793 struct alc_spec *spec = codec->spec;
6794 hda_nid_t nid;
6795
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006796 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006797 if (nid) {
6798 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6799 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6800 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006801
Takashi Iwai82bc9552006-03-21 11:24:42 +01006802 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006803 if (nid)
6804 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6805
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006806 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006807 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006808 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006809}
Kailang Yangdf694da2005-12-05 19:42:22 +01006810
6811#define ALC260_PIN_CD_NID 0x16
6812static void alc260_auto_init_analog_input(struct hda_codec *codec)
6813{
6814 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006815 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +01006816 int i;
6817
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006818 for (i = 0; i < cfg->num_inputs; i++) {
6819 hda_nid_t nid = cfg->inputs[i].pin;
Kailang Yangdf694da2005-12-05 19:42:22 +01006820 if (nid >= 0x12) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02006821 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006822 if (nid != ALC260_PIN_CD_NID &&
6823 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006824 snd_hda_codec_write(codec, nid, 0,
6825 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006826 AMP_OUT_MUTE);
6827 }
6828 }
6829}
6830
Takashi Iwai7f311a42010-04-09 17:32:23 +02006831#define alc260_auto_init_input_src alc880_auto_init_input_src
6832
Kailang Yangdf694da2005-12-05 19:42:22 +01006833/*
6834 * generic initialization of ADC, input mixers and output mixers
6835 */
6836static struct hda_verb alc260_volume_init_verbs[] = {
6837 /*
6838 * Unmute ADC0-1 and set the default input to mic-in
6839 */
6840 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6841 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6842 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6843 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006844
Kailang Yangdf694da2005-12-05 19:42:22 +01006845 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6846 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006847 * Note: PASD motherboards uses the Line In 2 as the input for
6848 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006849 */
6850 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006851 /* mute analog inputs */
6852 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6853 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6854 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6855 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6856 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006857
6858 /*
6859 * Set up output mixers (0x08 - 0x0a)
6860 */
6861 /* set vol=0 to output mixers */
6862 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6863 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6864 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6865 /* set up input amps for analog loopback */
6866 /* Amp Indices: DAC = 0, mixer = 1 */
6867 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6868 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6869 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6870 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6871 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6872 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006873
Kailang Yangdf694da2005-12-05 19:42:22 +01006874 { }
6875};
6876
6877static int alc260_parse_auto_config(struct hda_codec *codec)
6878{
6879 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006880 int err;
6881 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6882
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006883 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6884 alc260_ignore);
6885 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006886 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006887 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6888 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006889 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006890 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006891 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006892 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006893 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006894 return err;
6895
6896 spec->multiout.max_channels = 2;
6897
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006898 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006899 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006900 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006901 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006902
Takashi Iwaid88897e2008-10-31 15:01:37 +01006903 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006904
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006905 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006906 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006907
Kailang Yang6227cdc2010-02-25 08:36:52 +01006908 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006909
Kailang Yangdf694da2005-12-05 19:42:22 +01006910 return 1;
6911}
6912
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006913/* additional initialization for auto-configuration model */
6914static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006915{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006916 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006917 alc260_auto_init_multi_out(codec);
6918 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02006919 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02006920 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006921 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006922 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006923}
6924
Takashi Iwaicb53c622007-08-10 17:21:45 +02006925#ifdef CONFIG_SND_HDA_POWER_SAVE
6926static struct hda_amp_list alc260_loopbacks[] = {
6927 { 0x07, HDA_INPUT, 0 },
6928 { 0x07, HDA_INPUT, 1 },
6929 { 0x07, HDA_INPUT, 2 },
6930 { 0x07, HDA_INPUT, 3 },
6931 { 0x07, HDA_INPUT, 4 },
6932 { } /* end */
6933};
6934#endif
6935
Kailang Yangdf694da2005-12-05 19:42:22 +01006936/*
Takashi Iwaifc091762010-08-04 23:53:36 +02006937 * Pin config fixes
6938 */
6939enum {
6940 PINFIX_HP_DC5750,
6941};
6942
Takashi Iwaifc091762010-08-04 23:53:36 +02006943static const struct alc_fixup alc260_fixups[] = {
6944 [PINFIX_HP_DC5750] = {
Takashi Iwai73413b12010-08-30 09:39:57 +02006945 .pins = (const struct alc_pincfg[]) {
6946 { 0x11, 0x90130110 }, /* speaker */
6947 { }
6948 }
Takashi Iwaifc091762010-08-04 23:53:36 +02006949 },
6950};
6951
6952static struct snd_pci_quirk alc260_fixup_tbl[] = {
6953 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
6954 {}
6955};
6956
6957/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006958 * ALC260 configurations
6959 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006960static const char *alc260_models[ALC260_MODEL_LAST] = {
6961 [ALC260_BASIC] = "basic",
6962 [ALC260_HP] = "hp",
6963 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006964 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006965 [ALC260_FUJITSU_S702X] = "fujitsu",
6966 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006967 [ALC260_WILL] = "will",
6968 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006969 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006970#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006971 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006972#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006973 [ALC260_AUTO] = "auto",
6974};
6975
6976static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006977 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006978 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006979 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006980 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006981 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006982 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006983 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006984 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006985 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006986 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6987 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6988 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6989 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6990 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6991 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6992 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6993 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6994 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006995 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006996 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006997 {}
6998};
6999
Kailang Yangdf694da2005-12-05 19:42:22 +01007000static struct alc_config_preset alc260_presets[] = {
7001 [ALC260_BASIC] = {
7002 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007003 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007004 .init_verbs = { alc260_init_verbs },
7005 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7006 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007007 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01007008 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007009 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7010 .channel_mode = alc260_modes,
7011 .input_mux = &alc260_capture_source,
7012 },
7013 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01007014 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007015 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007016 .init_verbs = { alc260_init_verbs,
7017 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007018 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7019 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007020 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7021 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007022 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7023 .channel_mode = alc260_modes,
7024 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007025 .unsol_event = alc260_hp_unsol_event,
7026 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007027 },
Kailang Yang3f878302008-08-26 13:02:23 +02007028 [ALC260_HP_DC7600] = {
7029 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007030 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02007031 .init_verbs = { alc260_init_verbs,
7032 alc260_hp_dc7600_verbs },
7033 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7034 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007035 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7036 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02007037 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7038 .channel_mode = alc260_modes,
7039 .input_mux = &alc260_capture_source,
7040 .unsol_event = alc260_hp_3012_unsol_event,
7041 .init_hook = alc260_hp_3012_automute,
7042 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007043 [ALC260_HP_3013] = {
7044 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007045 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007046 .init_verbs = { alc260_hp_3013_init_verbs,
7047 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007048 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7049 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007050 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7051 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007052 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7053 .channel_mode = alc260_modes,
7054 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007055 .unsol_event = alc260_hp_3013_unsol_event,
7056 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007057 },
7058 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007059 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007060 .init_verbs = { alc260_fujitsu_init_verbs },
7061 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7062 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01007063 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7064 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007065 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7066 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007067 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
7068 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01007069 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007070 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007071 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007072 .init_verbs = { alc260_acer_init_verbs },
7073 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7074 .dac_nids = alc260_dac_nids,
7075 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7076 .adc_nids = alc260_dual_adc_nids,
7077 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7078 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007079 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
7080 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007081 },
Michael Schwingencc959482009-02-22 18:58:45 +01007082 [ALC260_FAVORIT100] = {
7083 .mixers = { alc260_favorit100_mixer },
7084 .init_verbs = { alc260_favorit100_init_verbs },
7085 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7086 .dac_nids = alc260_dac_nids,
7087 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7088 .adc_nids = alc260_dual_adc_nids,
7089 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7090 .channel_mode = alc260_modes,
7091 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
7092 .input_mux = alc260_favorit100_capture_sources,
7093 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007094 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007095 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007096 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
7097 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7098 .dac_nids = alc260_dac_nids,
7099 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7100 .adc_nids = alc260_adc_nids,
7101 .dig_out_nid = ALC260_DIGOUT_NID,
7102 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7103 .channel_mode = alc260_modes,
7104 .input_mux = &alc260_capture_source,
7105 },
7106 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007107 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007108 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
7109 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7110 .dac_nids = alc260_dac_nids,
7111 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7112 .adc_nids = alc260_adc_nids,
7113 .dig_out_nid = ALC260_DIGOUT_NID,
7114 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7115 .channel_mode = alc260_modes,
7116 .input_mux = &alc260_capture_source,
7117 .unsol_event = alc260_replacer_672v_unsol_event,
7118 .init_hook = alc260_replacer_672v_automute,
7119 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007120#ifdef CONFIG_SND_DEBUG
7121 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007122 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007123 .init_verbs = { alc260_test_init_verbs },
7124 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
7125 .dac_nids = alc260_test_dac_nids,
7126 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
7127 .adc_nids = alc260_test_adc_nids,
7128 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7129 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007130 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7131 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007132 },
7133#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007134};
7135
Linus Torvalds1da177e2005-04-16 15:20:36 -07007136static int patch_alc260(struct hda_codec *codec)
7137{
7138 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007139 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007140
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007141 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007142 if (spec == NULL)
7143 return -ENOMEM;
7144
7145 codec->spec = spec;
7146
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007147 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7148 alc260_models,
7149 alc260_cfg_tbl);
7150 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007151 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007152 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007153 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007154 }
7155
Takashi Iwaifc091762010-08-04 23:53:36 +02007156 if (board_config == ALC260_AUTO)
7157 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 1);
7158
Kailang Yangdf694da2005-12-05 19:42:22 +01007159 if (board_config == ALC260_AUTO) {
7160 /* automatic parse from the BIOS config */
7161 err = alc260_parse_auto_config(codec);
7162 if (err < 0) {
7163 alc_free(codec);
7164 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007165 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007166 printk(KERN_INFO
7167 "hda_codec: Cannot set up configuration "
7168 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007169 board_config = ALC260_BASIC;
7170 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007171 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007172
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007173 err = snd_hda_attach_beep_device(codec, 0x1);
7174 if (err < 0) {
7175 alc_free(codec);
7176 return err;
7177 }
7178
Kailang Yangdf694da2005-12-05 19:42:22 +01007179 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007180 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007181
Linus Torvalds1da177e2005-04-16 15:20:36 -07007182 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7183 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307184 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007185
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007186 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7187 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7188
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007189 if (!spec->adc_nids && spec->input_mux) {
7190 /* check whether NID 0x04 is valid */
7191 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007192 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007193 /* get type */
7194 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7195 spec->adc_nids = alc260_adc_nids_alt;
7196 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7197 } else {
7198 spec->adc_nids = alc260_adc_nids;
7199 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7200 }
7201 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007202 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007203 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007204
Takashi Iwaifc091762010-08-04 23:53:36 +02007205 if (board_config == ALC260_AUTO)
7206 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 0);
7207
Takashi Iwai2134ea42008-01-10 16:53:55 +01007208 spec->vmaster_nid = 0x08;
7209
Linus Torvalds1da177e2005-04-16 15:20:36 -07007210 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007211 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007212 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007213#ifdef CONFIG_SND_HDA_POWER_SAVE
7214 if (!spec->loopback.amplist)
7215 spec->loopback.amplist = alc260_loopbacks;
7216#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007217
7218 return 0;
7219}
7220
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007221
Linus Torvalds1da177e2005-04-16 15:20:36 -07007222/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007223 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007224 *
7225 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7226 * configuration. Each pin widget can choose any input DACs and a mixer.
7227 * Each ADC is connected from a mixer of all inputs. This makes possible
7228 * 6-channel independent captures.
7229 *
7230 * In addition, an independent DAC for the multi-playback (not used in this
7231 * driver yet).
7232 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007233#define ALC882_DIGOUT_NID 0x06
7234#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007235#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7236#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7237#define ALC1200_DIGOUT_NID 0x10
7238
Linus Torvalds1da177e2005-04-16 15:20:36 -07007239
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007240static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007241 { 8, NULL }
7242};
7243
Takashi Iwai4953550a2009-06-30 15:28:30 +02007244/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007245static hda_nid_t alc882_dac_nids[4] = {
7246 /* front, rear, clfe, rear_surr */
7247 0x02, 0x03, 0x04, 0x05
7248};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007249#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007250
Takashi Iwai4953550a2009-06-30 15:28:30 +02007251/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007252#define alc882_adc_nids alc880_adc_nids
7253#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007254#define alc883_adc_nids alc882_adc_nids_alt
7255static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7256static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7257#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007258
Takashi Iwaie1406342008-02-11 18:32:32 +01007259static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7260static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007261#define alc883_capsrc_nids alc882_capsrc_nids_alt
7262static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7263#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007264
Linus Torvalds1da177e2005-04-16 15:20:36 -07007265/* input MUX */
7266/* FIXME: should be a matrix-type input source selection */
7267
7268static struct hda_input_mux alc882_capture_source = {
7269 .num_items = 4,
7270 .items = {
7271 { "Mic", 0x0 },
7272 { "Front Mic", 0x1 },
7273 { "Line", 0x2 },
7274 { "CD", 0x4 },
7275 },
7276};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007277
Takashi Iwai4953550a2009-06-30 15:28:30 +02007278#define alc883_capture_source alc882_capture_source
7279
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007280static struct hda_input_mux alc889_capture_source = {
7281 .num_items = 3,
7282 .items = {
7283 { "Front Mic", 0x0 },
7284 { "Mic", 0x3 },
7285 { "Line", 0x2 },
7286 },
7287};
7288
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007289static struct hda_input_mux mb5_capture_source = {
7290 .num_items = 3,
7291 .items = {
7292 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307293 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007294 { "CD", 0x4 },
7295 },
7296};
7297
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007298static struct hda_input_mux macmini3_capture_source = {
7299 .num_items = 2,
7300 .items = {
7301 { "Line", 0x2 },
7302 { "CD", 0x4 },
7303 },
7304};
7305
Takashi Iwai4953550a2009-06-30 15:28:30 +02007306static struct hda_input_mux alc883_3stack_6ch_intel = {
7307 .num_items = 4,
7308 .items = {
7309 { "Mic", 0x1 },
7310 { "Front Mic", 0x0 },
7311 { "Line", 0x2 },
7312 { "CD", 0x4 },
7313 },
7314};
7315
7316static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7317 .num_items = 2,
7318 .items = {
7319 { "Mic", 0x1 },
7320 { "Line", 0x2 },
7321 },
7322};
7323
7324static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7325 .num_items = 4,
7326 .items = {
7327 { "Mic", 0x0 },
David Henningsson150b4322010-07-29 14:46:42 +02007328 { "Int Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007329 { "Line", 0x2 },
7330 { "CD", 0x4 },
7331 },
7332};
7333
7334static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7335 .num_items = 2,
7336 .items = {
7337 { "Mic", 0x0 },
7338 { "Int Mic", 0x1 },
7339 },
7340};
7341
7342static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7343 .num_items = 3,
7344 .items = {
7345 { "Mic", 0x0 },
7346 { "Front Mic", 0x1 },
7347 { "Line", 0x4 },
7348 },
7349};
7350
7351static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7352 .num_items = 2,
7353 .items = {
7354 { "Mic", 0x0 },
7355 { "Line", 0x2 },
7356 },
7357};
7358
7359static struct hda_input_mux alc889A_mb31_capture_source = {
7360 .num_items = 2,
7361 .items = {
7362 { "Mic", 0x0 },
7363 /* Front Mic (0x01) unused */
7364 { "Line", 0x2 },
7365 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007366 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007367 },
7368};
7369
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007370static struct hda_input_mux alc889A_imac91_capture_source = {
7371 .num_items = 2,
7372 .items = {
7373 { "Mic", 0x01 },
7374 { "Line", 0x2 }, /* Not sure! */
7375 },
7376};
7377
Takashi Iwai4953550a2009-06-30 15:28:30 +02007378/*
7379 * 2ch mode
7380 */
7381static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7382 { 2, NULL }
7383};
7384
Kailang Yangdf694da2005-12-05 19:42:22 +01007385/*
Kailang Yang272a5272007-05-14 11:00:38 +02007386 * 2ch mode
7387 */
7388static struct hda_verb alc882_3ST_ch2_init[] = {
7389 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7390 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7391 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7392 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7393 { } /* end */
7394};
7395
7396/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007397 * 4ch mode
7398 */
7399static struct hda_verb alc882_3ST_ch4_init[] = {
7400 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7401 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7402 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7403 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7404 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7405 { } /* end */
7406};
7407
7408/*
Kailang Yang272a5272007-05-14 11:00:38 +02007409 * 6ch mode
7410 */
7411static struct hda_verb alc882_3ST_ch6_init[] = {
7412 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7413 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7414 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7415 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7416 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7417 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7418 { } /* end */
7419};
7420
Takashi Iwai4953550a2009-06-30 15:28:30 +02007421static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007422 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007423 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007424 { 6, alc882_3ST_ch6_init },
7425};
7426
Takashi Iwai4953550a2009-06-30 15:28:30 +02007427#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7428
Kailang Yang272a5272007-05-14 11:00:38 +02007429/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307430 * 2ch mode
7431 */
7432static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7433 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7434 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7435 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7436 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7437 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7438 { } /* end */
7439};
7440
7441/*
7442 * 4ch mode
7443 */
7444static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7445 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7446 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7447 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7448 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7449 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7450 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7451 { } /* end */
7452};
7453
7454/*
7455 * 6ch mode
7456 */
7457static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7458 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7459 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7460 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7461 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7462 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7463 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7464 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7465 { } /* end */
7466};
7467
7468static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7469 { 2, alc883_3ST_ch2_clevo_init },
7470 { 4, alc883_3ST_ch4_clevo_init },
7471 { 6, alc883_3ST_ch6_clevo_init },
7472};
7473
7474
7475/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007476 * 6ch mode
7477 */
7478static struct hda_verb alc882_sixstack_ch6_init[] = {
7479 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7480 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7481 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7482 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7483 { } /* end */
7484};
7485
7486/*
7487 * 8ch mode
7488 */
7489static struct hda_verb alc882_sixstack_ch8_init[] = {
7490 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7491 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7492 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7493 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7494 { } /* end */
7495};
7496
7497static struct hda_channel_mode alc882_sixstack_modes[2] = {
7498 { 6, alc882_sixstack_ch6_init },
7499 { 8, alc882_sixstack_ch8_init },
7500};
7501
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007502
7503/* Macbook Air 2,1 */
7504
7505static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7506 { 2, NULL },
7507};
7508
Takashi Iwai87350ad2007-08-16 18:19:38 +02007509/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007510 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007511 */
7512
7513/*
7514 * 2ch mode
7515 */
7516static struct hda_verb alc885_mbp_ch2_init[] = {
7517 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7518 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7519 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7520 { } /* end */
7521};
7522
7523/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007524 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007525 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007526static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007527 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7528 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7529 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7530 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7531 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7532 { } /* end */
7533};
7534
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007535static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007536 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007537 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007538};
7539
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007540/*
7541 * 2ch
7542 * Speakers/Woofer/HP = Front
7543 * LineIn = Input
7544 */
7545static struct hda_verb alc885_mb5_ch2_init[] = {
7546 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7547 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7548 { } /* end */
7549};
7550
7551/*
7552 * 6ch mode
7553 * Speakers/HP = Front
7554 * Woofer = LFE
7555 * LineIn = Surround
7556 */
7557static struct hda_verb alc885_mb5_ch6_init[] = {
7558 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7559 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7560 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7561 { } /* end */
7562};
7563
7564static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7565 { 2, alc885_mb5_ch2_init },
7566 { 6, alc885_mb5_ch6_init },
7567};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007568
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007569#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007570
7571/*
7572 * 2ch mode
7573 */
7574static struct hda_verb alc883_4ST_ch2_init[] = {
7575 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7576 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7577 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7578 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7579 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7580 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7581 { } /* end */
7582};
7583
7584/*
7585 * 4ch mode
7586 */
7587static struct hda_verb alc883_4ST_ch4_init[] = {
7588 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7589 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7590 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7591 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7592 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7593 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7594 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7595 { } /* end */
7596};
7597
7598/*
7599 * 6ch mode
7600 */
7601static struct hda_verb alc883_4ST_ch6_init[] = {
7602 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7603 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7604 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7605 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7606 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7607 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7608 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7609 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7610 { } /* end */
7611};
7612
7613/*
7614 * 8ch mode
7615 */
7616static struct hda_verb alc883_4ST_ch8_init[] = {
7617 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7618 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7619 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7620 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7621 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7622 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7623 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7624 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7625 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7626 { } /* end */
7627};
7628
7629static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7630 { 2, alc883_4ST_ch2_init },
7631 { 4, alc883_4ST_ch4_init },
7632 { 6, alc883_4ST_ch6_init },
7633 { 8, alc883_4ST_ch8_init },
7634};
7635
7636
7637/*
7638 * 2ch mode
7639 */
7640static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7641 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7642 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7643 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7644 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7645 { } /* end */
7646};
7647
7648/*
7649 * 4ch mode
7650 */
7651static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7652 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7653 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7654 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7655 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7656 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7657 { } /* end */
7658};
7659
7660/*
7661 * 6ch mode
7662 */
7663static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7664 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7665 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7666 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7667 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7668 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7669 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7670 { } /* end */
7671};
7672
7673static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7674 { 2, alc883_3ST_ch2_intel_init },
7675 { 4, alc883_3ST_ch4_intel_init },
7676 { 6, alc883_3ST_ch6_intel_init },
7677};
7678
7679/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007680 * 2ch mode
7681 */
7682static struct hda_verb alc889_ch2_intel_init[] = {
7683 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7684 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7685 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7686 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7687 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7688 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7689 { } /* end */
7690};
7691
7692/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007693 * 6ch mode
7694 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007695static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007696 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7697 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7698 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7699 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7700 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007701 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7702 { } /* end */
7703};
7704
7705/*
7706 * 8ch mode
7707 */
7708static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007709 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7710 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7711 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7712 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7713 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007714 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7715 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007716 { } /* end */
7717};
7718
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007719static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7720 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007721 { 6, alc889_ch6_intel_init },
7722 { 8, alc889_ch8_intel_init },
7723};
7724
7725/*
7726 * 6ch mode
7727 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007728static struct hda_verb alc883_sixstack_ch6_init[] = {
7729 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7730 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7731 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7732 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7733 { } /* end */
7734};
7735
7736/*
7737 * 8ch mode
7738 */
7739static struct hda_verb alc883_sixstack_ch8_init[] = {
7740 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7741 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7742 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7743 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7744 { } /* end */
7745};
7746
7747static struct hda_channel_mode alc883_sixstack_modes[2] = {
7748 { 6, alc883_sixstack_ch6_init },
7749 { 8, alc883_sixstack_ch8_init },
7750};
7751
7752
Linus Torvalds1da177e2005-04-16 15:20:36 -07007753/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7754 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7755 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007756static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007757 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007758 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007759 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007760 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007761 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7762 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007763 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7764 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007765 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007766 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007767 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7768 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7769 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7770 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7771 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7772 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007773 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007774 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7775 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007776 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007777 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007778 { } /* end */
7779};
7780
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007781/* Macbook Air 2,1 same control for HP and internal Speaker */
7782
7783static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7784 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7785 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7786 { }
7787};
7788
7789
Takashi Iwai87350ad2007-08-16 18:19:38 +02007790static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007791 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7792 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7793 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7794 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7795 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007796 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7797 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007798 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7799 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007800 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007801 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7802 { } /* end */
7803};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007804
7805static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007806 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7807 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7808 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7809 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7810 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7811 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307812 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7813 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09307814 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7815 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007816 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7817 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7818 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7819 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7820 { } /* end */
7821};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007822
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007823static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7824 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7825 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7826 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7827 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7828 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7829 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7830 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7831 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7832 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7833 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7834 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7835 { } /* end */
7836};
7837
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007838static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007839 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7840 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007841 { } /* end */
7842};
7843
7844
Kailang Yangbdd148a2007-05-08 15:19:08 +02007845static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7846 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7847 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7848 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7849 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7850 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7851 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7852 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7853 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7854 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007855 { } /* end */
7856};
7857
Kailang Yang272a5272007-05-14 11:00:38 +02007858static struct snd_kcontrol_new alc882_targa_mixer[] = {
7859 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7860 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7861 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7862 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7863 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7864 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7865 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7866 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7867 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007868 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007869 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7870 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007871 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007872 { } /* end */
7873};
7874
7875/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7876 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7877 */
7878static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7879 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7880 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7881 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7882 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7883 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7884 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7885 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7886 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7887 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7888 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7889 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7890 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007891 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007892 { } /* end */
7893};
7894
Takashi Iwai914759b2007-09-06 14:52:04 +02007895static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7896 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7897 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7898 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7899 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7900 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7901 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7902 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7903 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7904 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7905 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007906 { } /* end */
7907};
7908
Kailang Yangdf694da2005-12-05 19:42:22 +01007909static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7910 {
7911 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7912 .name = "Channel Mode",
7913 .info = alc_ch_mode_info,
7914 .get = alc_ch_mode_get,
7915 .put = alc_ch_mode_put,
7916 },
7917 { } /* end */
7918};
7919
Takashi Iwai4953550a2009-06-30 15:28:30 +02007920static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007921 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007922 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7923 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007924 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007925 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7926 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007927 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007928 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7929 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007930 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007931 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7932 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007933
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007934 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007935 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007936 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007937 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007938 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007939 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007940 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007941 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007942 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007943 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007944 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007945 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007946 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007947 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007948 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007949 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007950 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007951 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007952 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7953 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007954 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007955 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7956 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007957 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007958 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7959 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7960 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7961 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7962 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007963 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007964 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007965
7966 /* FIXME: use matrix-type input source selection */
7967 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007968 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007969 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007970 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007971 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007972 /* ADC2: mute amp left and right */
7973 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007974 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007975 /* ADC3: mute amp left and right */
7976 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007977 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007978
7979 { }
7980};
7981
Takashi Iwai4953550a2009-06-30 15:28:30 +02007982static struct hda_verb alc882_adc1_init_verbs[] = {
7983 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7984 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7985 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7986 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7987 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7988 /* ADC1: mute amp left and right */
7989 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7990 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7991 { }
7992};
7993
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007994static struct hda_verb alc882_eapd_verbs[] = {
7995 /* change to EAPD mode */
7996 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007997 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007998 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007999};
8000
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008001static struct hda_verb alc889_eapd_verbs[] = {
8002 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8003 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8004 { }
8005};
8006
Wu Fengguang6732bd02009-07-30 09:19:14 +02008007static struct hda_verb alc_hp15_unsol_verbs[] = {
8008 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8009 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8010 {}
8011};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008012
8013static struct hda_verb alc885_init_verbs[] = {
8014 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01008015 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8016 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008017 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008018 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8019 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008020 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008021 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8022 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008023 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008024 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8025 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008026
8027 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02008028 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008029 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8030 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8031 /* Front Pin: output 0 (0x0c) */
8032 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8033 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8034 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8035 /* Rear Pin: output 1 (0x0d) */
8036 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8037 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8038 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
8039 /* CLFE Pin: output 2 (0x0e) */
8040 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8041 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8042 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8043 /* Side Pin: output 3 (0x0f) */
8044 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8045 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8046 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8047 /* Mic (rear) pin: input vref at 80% */
8048 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8049 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8050 /* Front Mic pin: input vref at 80% */
8051 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8052 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8053 /* Line In pin: input */
8054 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8055 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8056
8057 /* Mixer elements: 0x18, , 0x1a, 0x1b */
8058 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01008059 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008060 /* Input mixer2 */
8061 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008062 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008063 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008064 /* ADC2: mute amp left and right */
8065 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8066 /* ADC3: mute amp left and right */
8067 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8068
8069 { }
8070};
8071
8072static struct hda_verb alc885_init_input_verbs[] = {
8073 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8074 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8075 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8076 { }
8077};
8078
8079
8080/* Unmute Selector 24h and set the default input to front mic */
8081static struct hda_verb alc889_init_input_verbs[] = {
8082 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8083 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8084 { }
8085};
8086
8087
Takashi Iwai4953550a2009-06-30 15:28:30 +02008088#define alc883_init_verbs alc882_base_init_verbs
8089
Tobin Davis9102cd12006-12-15 10:02:12 +01008090/* Mac Pro test */
8091static struct snd_kcontrol_new alc882_macpro_mixer[] = {
8092 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8093 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8094 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
8095 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8096 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008097 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01008098 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
8099 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008100 */
Tobin Davis9102cd12006-12-15 10:02:12 +01008101 { } /* end */
8102};
8103
8104static struct hda_verb alc882_macpro_init_verbs[] = {
8105 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8106 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8107 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8108 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8109 /* Front Pin: output 0 (0x0c) */
8110 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8111 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8112 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8113 /* Front Mic pin: input vref at 80% */
8114 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8115 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8116 /* Speaker: output */
8117 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8118 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8119 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
8120 /* Headphone output (output 0 - 0x0c) */
8121 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8122 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8123 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8124
8125 /* FIXME: use matrix-type input source selection */
8126 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8127 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8128 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8129 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8130 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8131 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8132 /* Input mixer2 */
8133 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8134 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8135 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8136 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8137 /* Input mixer3 */
8138 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8139 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8140 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8141 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8142 /* ADC1: mute amp left and right */
8143 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8144 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8145 /* ADC2: mute amp left and right */
8146 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8147 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8148 /* ADC3: mute amp left and right */
8149 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8150 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8151
8152 { }
8153};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008154
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008155/* Macbook 5,1 */
8156static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008157 /* DACs */
8158 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8159 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8160 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8161 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008162 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008163 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8164 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8165 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008166 /* Surround mixer */
8167 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8168 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8169 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8170 /* LFE mixer */
8171 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8172 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8173 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8174 /* HP mixer */
8175 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8176 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8177 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8178 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008179 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8180 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008181 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8182 /* LFE Pin (0x0e) */
8183 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8184 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8185 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8186 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008187 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8188 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008189 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308190 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008191 /* Front Mic pin: input vref at 80% */
8192 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8193 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8194 /* Line In pin */
8195 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8196 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8197
Alex Murrayb8f171e2010-06-14 12:08:43 +09308198 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8199 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8200 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008201 { }
8202};
8203
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008204/* Macmini 3,1 */
8205static struct hda_verb alc885_macmini3_init_verbs[] = {
8206 /* DACs */
8207 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8208 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8209 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8210 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8211 /* Front mixer */
8212 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8213 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8214 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8215 /* Surround mixer */
8216 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8217 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8218 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8219 /* LFE mixer */
8220 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8221 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8222 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8223 /* HP mixer */
8224 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8225 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8226 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8227 /* Front Pin (0x0c) */
8228 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8229 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8230 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8231 /* LFE Pin (0x0e) */
8232 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8233 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8234 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8235 /* HP Pin (0x0f) */
8236 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8237 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8238 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8239 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8240 /* Line In pin */
8241 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8242 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8243
8244 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8245 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8246 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8247 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8248 { }
8249};
8250
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008251
8252static struct hda_verb alc885_mba21_init_verbs[] = {
8253 /*Internal and HP Speaker Mixer*/
8254 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8255 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8256 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8257 /*Internal Speaker Pin (0x0c)*/
8258 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8259 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8260 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8261 /* HP Pin: output 0 (0x0e) */
8262 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8263 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8264 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8265 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8266 /* Line in (is hp when jack connected)*/
8267 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8268 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8269
8270 { }
8271 };
8272
8273
Takashi Iwai87350ad2007-08-16 18:19:38 +02008274/* Macbook Pro rev3 */
8275static struct hda_verb alc885_mbp3_init_verbs[] = {
8276 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8277 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8278 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8279 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8280 /* Rear mixer */
8281 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8282 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8283 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008284 /* HP mixer */
8285 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8286 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8287 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008288 /* Front Pin: output 0 (0x0c) */
8289 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8290 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8291 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008292 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008293 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008294 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8295 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008296 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8297 /* Mic (rear) pin: input vref at 80% */
8298 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8299 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8300 /* Front Mic pin: input vref at 80% */
8301 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8302 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8303 /* Line In pin: use output 1 when in LineOut mode */
8304 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8305 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8306 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8307
8308 /* FIXME: use matrix-type input source selection */
8309 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8310 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8311 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8312 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8313 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8314 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8315 /* Input mixer2 */
8316 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8317 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8318 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8319 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8320 /* Input mixer3 */
8321 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8322 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8323 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8324 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8325 /* ADC1: mute amp left and right */
8326 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8327 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8328 /* ADC2: mute amp left and right */
8329 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8330 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8331 /* ADC3: mute amp left and right */
8332 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8333 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8334
8335 { }
8336};
8337
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008338/* iMac 9,1 */
8339static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008340 /* Internal Speaker Pin (0x0c) */
8341 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8342 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8343 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8344 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8345 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8346 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8347 /* HP Pin: Rear */
8348 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8349 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8350 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8351 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8352 /* Line in Rear */
8353 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8354 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8355 /* Front Mic pin: input vref at 80% */
8356 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8357 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008358 /* Rear mixer */
8359 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8360 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8361 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008362 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8363 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8364 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8365 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8366 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008367 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8368 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8369 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8370 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008371 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008372 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8373 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8374 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8375 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008376 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008377 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8378 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8379 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8380 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008381 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008382 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8383 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008384 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008385 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8386 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008387 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008388 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8389 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008390 { }
8391};
8392
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008393/* iMac 24 mixer. */
8394static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8395 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8396 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8397 { } /* end */
8398};
8399
8400/* iMac 24 init verbs. */
8401static struct hda_verb alc885_imac24_init_verbs[] = {
8402 /* Internal speakers: output 0 (0x0c) */
8403 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8404 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8405 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8406 /* Internal speakers: output 0 (0x0c) */
8407 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8408 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8409 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8410 /* Headphone: output 0 (0x0c) */
8411 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8412 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8413 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8414 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8415 /* Front Mic: input vref at 80% */
8416 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8417 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8418 { }
8419};
8420
8421/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008422static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008423{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008424 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008425
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008426 spec->autocfg.hp_pins[0] = 0x14;
8427 spec->autocfg.speaker_pins[0] = 0x18;
8428 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008429}
8430
Takashi Iwai9d54f082010-02-22 08:34:40 +01008431#define alc885_mb5_setup alc885_imac24_setup
8432#define alc885_macmini3_setup alc885_imac24_setup
8433
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008434/* Macbook Air 2,1 */
8435static void alc885_mba21_setup(struct hda_codec *codec)
8436{
8437 struct alc_spec *spec = codec->spec;
8438
8439 spec->autocfg.hp_pins[0] = 0x14;
8440 spec->autocfg.speaker_pins[0] = 0x18;
8441}
8442
8443
8444
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008445static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008446{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008447 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008448
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008449 spec->autocfg.hp_pins[0] = 0x15;
8450 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008451}
8452
Takashi Iwai9d54f082010-02-22 08:34:40 +01008453static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308454{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008455 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308456
Takashi Iwai9d54f082010-02-22 08:34:40 +01008457 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008458 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008459 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008460}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008461
Kailang Yang272a5272007-05-14 11:00:38 +02008462static struct hda_verb alc882_targa_verbs[] = {
8463 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8464 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8465
8466 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8467 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008468
Kailang Yang272a5272007-05-14 11:00:38 +02008469 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8470 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8471 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8472
8473 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008474 { } /* end */
8475};
8476
8477/* toggle speaker-output according to the hp-jack state */
8478static void alc882_targa_automute(struct hda_codec *codec)
8479{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008480 struct alc_spec *spec = codec->spec;
8481 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008482 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008483 spec->jack_present ? 1 : 3);
8484}
8485
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008486static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008487{
8488 struct alc_spec *spec = codec->spec;
8489
8490 spec->autocfg.hp_pins[0] = 0x14;
8491 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008492}
8493
8494static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8495{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008496 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008497 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008498}
8499
8500static struct hda_verb alc882_asus_a7j_verbs[] = {
8501 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8502 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8503
8504 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8505 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8506 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008507
Kailang Yang272a5272007-05-14 11:00:38 +02008508 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8509 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8510 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8511
8512 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8513 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8514 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8515 { } /* end */
8516};
8517
Takashi Iwai914759b2007-09-06 14:52:04 +02008518static struct hda_verb alc882_asus_a7m_verbs[] = {
8519 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8520 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8521
8522 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8523 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8524 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008525
Takashi Iwai914759b2007-09-06 14:52:04 +02008526 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8527 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8528 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8529
8530 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8531 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8532 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8533 { } /* end */
8534};
8535
Tobin Davis9102cd12006-12-15 10:02:12 +01008536static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8537{
8538 unsigned int gpiostate, gpiomask, gpiodir;
8539
8540 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8541 AC_VERB_GET_GPIO_DATA, 0);
8542
8543 if (!muted)
8544 gpiostate |= (1 << pin);
8545 else
8546 gpiostate &= ~(1 << pin);
8547
8548 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8549 AC_VERB_GET_GPIO_MASK, 0);
8550 gpiomask |= (1 << pin);
8551
8552 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8553 AC_VERB_GET_GPIO_DIRECTION, 0);
8554 gpiodir |= (1 << pin);
8555
8556
8557 snd_hda_codec_write(codec, codec->afg, 0,
8558 AC_VERB_SET_GPIO_MASK, gpiomask);
8559 snd_hda_codec_write(codec, codec->afg, 0,
8560 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8561
8562 msleep(1);
8563
8564 snd_hda_codec_write(codec, codec->afg, 0,
8565 AC_VERB_SET_GPIO_DATA, gpiostate);
8566}
8567
Takashi Iwai7debbe52007-08-16 15:01:03 +02008568/* set up GPIO at initialization */
8569static void alc885_macpro_init_hook(struct hda_codec *codec)
8570{
8571 alc882_gpio_mute(codec, 0, 0);
8572 alc882_gpio_mute(codec, 1, 0);
8573}
8574
8575/* set up GPIO and update auto-muting at initialization */
8576static void alc885_imac24_init_hook(struct hda_codec *codec)
8577{
8578 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008579 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008580}
8581
Kailang Yangdf694da2005-12-05 19:42:22 +01008582/*
8583 * generic initialization of ADC, input mixers and output mixers
8584 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008585static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008586 /*
8587 * Unmute ADC0-2 and set the default input to mic-in
8588 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008589 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8590 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8591 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8592 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8593
Kailang Yangdf694da2005-12-05 19:42:22 +01008594 /*
8595 * Set up output mixers (0x0c - 0x0f)
8596 */
8597 /* set vol=0 to output mixers */
8598 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8599 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8600 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8601 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8602 /* set up input amps for analog loopback */
8603 /* Amp Indices: DAC = 0, mixer = 1 */
8604 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8605 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8606 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8607 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8608 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8609 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8610 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8611 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8612 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8613 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8614
8615 /* FIXME: use matrix-type input source selection */
8616 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008617 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008618 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008619 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008620 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008621 { }
8622};
8623
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008624/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8625static struct hda_verb alc889A_mb31_ch2_init[] = {
8626 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8627 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8628 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8629 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8630 { } /* end */
8631};
8632
8633/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8634static struct hda_verb alc889A_mb31_ch4_init[] = {
8635 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8636 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8637 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8638 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8639 { } /* end */
8640};
8641
8642/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8643static struct hda_verb alc889A_mb31_ch5_init[] = {
8644 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8645 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8646 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8647 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8648 { } /* end */
8649};
8650
8651/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8652static struct hda_verb alc889A_mb31_ch6_init[] = {
8653 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8654 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8655 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8656 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8657 { } /* end */
8658};
8659
8660static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8661 { 2, alc889A_mb31_ch2_init },
8662 { 4, alc889A_mb31_ch4_init },
8663 { 5, alc889A_mb31_ch5_init },
8664 { 6, alc889A_mb31_ch6_init },
8665};
8666
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008667static struct hda_verb alc883_medion_eapd_verbs[] = {
8668 /* eanable EAPD on medion laptop */
8669 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8670 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8671 { }
8672};
8673
Takashi Iwai4953550a2009-06-30 15:28:30 +02008674#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008675
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008676static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8677 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8678 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8679 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8680 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8681 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8682 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8683 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8684 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8685 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8686 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8687 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8688 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8689 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008690 { } /* end */
8691};
8692
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008693static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008694 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8695 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8696 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8697 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8698 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8699 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8700 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8701 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8702 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8703 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008704 { } /* end */
8705};
8706
Jiang zhefb97dc62008-03-06 11:07:11 +01008707static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8708 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8709 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8710 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8711 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8712 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8713 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8714 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8715 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8716 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8717 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008718 { } /* end */
8719};
8720
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008721static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8722 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8723 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8724 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8725 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8726 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8727 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8728 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8729 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008730 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008731 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8732 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008733 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008734 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008735 { } /* end */
8736};
8737
8738static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8739 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8740 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8741 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8742 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8743 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8744 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8745 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8746 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8747 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8748 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8749 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8750 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8751 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8752 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008753 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008754 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8755 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008756 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008757 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008758 { } /* end */
8759};
8760
Jiang zhe17bba1b2008-06-04 12:11:07 +02008761static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8762 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8763 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8764 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8765 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8766 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8767 HDA_OUTPUT),
8768 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8769 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8770 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8771 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8772 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8773 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8774 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8775 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8776 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8777 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8778 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8779 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8780 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8781 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008782 { } /* end */
8783};
8784
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008785static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8786 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8787 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8788 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8789 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8790 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8791 HDA_OUTPUT),
8792 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8793 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8794 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8795 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8796 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8797 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8798 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8799 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8800 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8801 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8802 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8803 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8804 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8805 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8806 { } /* end */
8807};
8808
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008809static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008810 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008811 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008812 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008813 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008814 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8815 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008816 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8817 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008818 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8819 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8820 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8821 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8822 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8823 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008824 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008825 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8826 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008827 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008828 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008829 { } /* end */
8830};
8831
Sasha Alexandrc2592492009-06-16 14:52:54 -04008832static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008833 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008834 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008835 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008836 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008837 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8838 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8839 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8840 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8841 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8842 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8843 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8844 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8845 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8846 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8847 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008848 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008849 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008850 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008851};
Kailang Yangccc656c2006-10-17 12:32:26 +02008852
Sasha Alexandrc2592492009-06-16 14:52:54 -04008853static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008854 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008855 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008856 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008857 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008858 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8859 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8860 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008861 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008862 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008863 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8864 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8865 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008866 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008867};
Kailang Yangccc656c2006-10-17 12:32:26 +02008868
Takashi Iwaib99dba32009-09-17 18:23:00 +02008869static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8870 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8871 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8872 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8873 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8874 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8875 { } /* end */
8876};
8877
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008878static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8879 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8880 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008881 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8882 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008883 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8884 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8885 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8886 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008887 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008888};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008889
Kailang Yang272a5272007-05-14 11:00:38 +02008890static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8891 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8892 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8893 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8894 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8895 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8896 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8897 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson150b4322010-07-29 14:46:42 +02008898 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8899 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008900 { } /* end */
8901};
8902
8903static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8904 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8905 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8906 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8907 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8908 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8909 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8910 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8911 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8912 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008913 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008914};
Kailang Yang272a5272007-05-14 11:00:38 +02008915
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02008916static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
8917 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8918 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8919 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8920 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
8921 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
8922 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
8923 { } /* end */
8924};
8925
8926static struct hda_verb alc883_medion_wim2160_verbs[] = {
8927 /* Unmute front mixer */
8928 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8929 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8930
8931 /* Set speaker pin to front mixer */
8932 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8933
8934 /* Init headphone pin */
8935 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8936 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8937 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8938 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8939
8940 { } /* end */
8941};
8942
8943/* toggle speaker-output according to the hp-jack state */
8944static void alc883_medion_wim2160_setup(struct hda_codec *codec)
8945{
8946 struct alc_spec *spec = codec->spec;
8947
8948 spec->autocfg.hp_pins[0] = 0x1a;
8949 spec->autocfg.speaker_pins[0] = 0x15;
8950}
8951
Tobin Davis2880a862007-08-07 11:50:26 +02008952static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008953 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8954 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008955 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008956 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8957 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008958 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8959 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8960 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008961 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008962};
Tobin Davis2880a862007-08-07 11:50:26 +02008963
Tony Vroond2fd4b02009-06-21 00:40:10 +01008964static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8965 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008966 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008967 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8968 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008969 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8970 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8971 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8972 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8973 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8974 { } /* end */
8975};
8976
Kailang Yange2757d52008-08-26 13:17:46 +02008977static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8978 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8979 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8980 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8981 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8982 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8983 0x0d, 1, 0x0, HDA_OUTPUT),
8984 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8985 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8986 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8987 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8988 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008989 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8990 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8991 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8992 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8993 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8994 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8995 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8996 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8997 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8998 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008999 { } /* end */
9000};
9001
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009002static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
9003 /* Output mixers */
9004 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
9005 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
9006 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
9007 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
9008 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
9009 HDA_OUTPUT),
9010 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
9011 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
9012 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
9013 /* Output switches */
9014 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
9015 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
9016 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
9017 /* Boost mixers */
9018 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
9019 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
9020 /* Input mixers */
9021 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
9022 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
9023 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9024 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9025 { } /* end */
9026};
9027
Guido Günther3e1647c2009-06-05 00:47:26 +02009028static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
9029 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9030 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9031 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9032 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9033 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
9034 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9035 { } /* end */
9036};
9037
Kailang Yange2757d52008-08-26 13:17:46 +02009038static struct hda_bind_ctls alc883_bind_cap_vol = {
9039 .ops = &snd_hda_bind_vol,
9040 .values = {
9041 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9042 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9043 0
9044 },
9045};
9046
9047static struct hda_bind_ctls alc883_bind_cap_switch = {
9048 .ops = &snd_hda_bind_sw,
9049 .values = {
9050 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9051 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9052 0
9053 },
9054};
9055
9056static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
9057 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9058 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9059 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9060 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9061 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9062 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9063 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9064 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009065 { } /* end */
9066};
9067
9068static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009069 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
9070 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
9071 {
9072 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9073 /* .name = "Capture Source", */
9074 .name = "Input Source",
9075 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009076 .info = alc_mux_enum_info,
9077 .get = alc_mux_enum_get,
9078 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02009079 },
9080 { } /* end */
9081};
9082
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009083static struct snd_kcontrol_new alc883_chmode_mixer[] = {
9084 {
9085 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9086 .name = "Channel Mode",
9087 .info = alc_ch_mode_info,
9088 .get = alc_ch_mode_get,
9089 .put = alc_ch_mode_put,
9090 },
9091 { } /* end */
9092};
9093
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009094/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009095static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009096{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009097 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009098
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009099 spec->autocfg.hp_pins[0] = 0x15;
9100 spec->autocfg.speaker_pins[0] = 0x14;
9101 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009102}
9103
9104/* auto-toggle front mic */
9105/*
9106static void alc883_mitac_mic_automute(struct hda_codec *codec)
9107{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009108 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009109
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009110 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
9111}
9112*/
9113
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009114static struct hda_verb alc883_mitac_verbs[] = {
9115 /* HP */
9116 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9117 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9118 /* Subwoofer */
9119 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9120 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9121
9122 /* enable unsolicited event */
9123 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9124 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
9125
9126 { } /* end */
9127};
9128
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309129static struct hda_verb alc883_clevo_m540r_verbs[] = {
9130 /* HP */
9131 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9132 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9133 /* Int speaker */
9134 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9135
9136 /* enable unsolicited event */
9137 /*
9138 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9139 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9140 */
9141
9142 { } /* end */
9143};
9144
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009145static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009146 /* HP */
9147 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9148 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9149 /* Int speaker */
9150 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9151 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9152
9153 /* enable unsolicited event */
9154 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009155 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009156
9157 { } /* end */
9158};
9159
Jiang zhefb97dc62008-03-06 11:07:11 +01009160static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9161 /* HP */
9162 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9163 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9164 /* Subwoofer */
9165 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9166 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9167
9168 /* enable unsolicited event */
9169 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9170
9171 { } /* end */
9172};
9173
Sasha Alexandrc2592492009-06-16 14:52:54 -04009174static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009175 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9176 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9177
9178 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9179 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009180
David Heidelberger64a8be72009-06-08 16:15:18 +02009181/* Connect Line-Out side jack (SPDIF) to Side */
9182 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9183 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9184 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9185/* Connect Mic jack to CLFE */
9186 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9187 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9188 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9189/* Connect Line-in jack to Surround */
9190 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9191 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9192 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9193/* Connect HP out jack to Front */
9194 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9195 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9196 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009197
9198 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009199
9200 { } /* end */
9201};
9202
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009203static struct hda_verb alc883_lenovo_101e_verbs[] = {
9204 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9205 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9206 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9207 { } /* end */
9208};
9209
Kailang Yang272a5272007-05-14 11:00:38 +02009210static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9211 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9212 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9213 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9214 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9215 { } /* end */
9216};
9217
9218static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
9219 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9220 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9221 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9222 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9223 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9224 { } /* end */
9225};
9226
Kailang Yang189609a2007-08-20 11:31:23 +02009227static struct hda_verb alc883_haier_w66_verbs[] = {
9228 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9229 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9230
9231 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9232
9233 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9234 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9235 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9236 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9237 { } /* end */
9238};
9239
Kailang Yange2757d52008-08-26 13:17:46 +02009240static struct hda_verb alc888_lenovo_sky_verbs[] = {
9241 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9242 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9243 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9244 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9245 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9246 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9247 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9248 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9249 { } /* end */
9250};
9251
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009252static struct hda_verb alc888_6st_dell_verbs[] = {
9253 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9254 { }
9255};
9256
Guido Günther3e1647c2009-06-05 00:47:26 +02009257static struct hda_verb alc883_vaiott_verbs[] = {
9258 /* HP */
9259 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9260 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9261
9262 /* enable unsolicited event */
9263 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9264
9265 { } /* end */
9266};
9267
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009268static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009269{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009270 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009271
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009272 spec->autocfg.hp_pins[0] = 0x1b;
9273 spec->autocfg.speaker_pins[0] = 0x14;
9274 spec->autocfg.speaker_pins[1] = 0x16;
9275 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009276}
9277
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009278static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009279 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009280 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9281 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009282 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009283 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009284};
9285
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009286/*
9287 * 2ch mode
9288 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009289static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009290 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9291 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9292 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9293 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009294 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009295};
9296
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009297/*
9298 * 4ch mode
9299 */
9300static struct hda_verb alc888_3st_hp_4ch_init[] = {
9301 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9302 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9303 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9304 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9305 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9306 { } /* end */
9307};
9308
9309/*
9310 * 6ch mode
9311 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009312static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009313 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9314 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009315 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009316 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9317 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009318 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9319 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009320};
9321
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009322static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009323 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009324 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009325 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009326};
9327
Kailang Yang272a5272007-05-14 11:00:38 +02009328/* toggle front-jack and RCA according to the hp-jack state */
9329static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9330{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009331 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02009332
Takashi Iwai47fd8302007-08-10 17:11:07 +02009333 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9334 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9335 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9336 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009337}
9338
9339/* toggle RCA according to the front-jack state */
9340static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9341{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009342 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009343
Takashi Iwai47fd8302007-08-10 17:11:07 +02009344 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9345 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009346}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009347
Kailang Yang272a5272007-05-14 11:00:38 +02009348static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9349 unsigned int res)
9350{
9351 if ((res >> 26) == ALC880_HP_EVENT)
9352 alc888_lenovo_ms7195_front_automute(codec);
9353 if ((res >> 26) == ALC880_FRONT_EVENT)
9354 alc888_lenovo_ms7195_rca_automute(codec);
9355}
9356
9357static struct hda_verb alc883_medion_md2_verbs[] = {
9358 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9359 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9360
9361 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9362
9363 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9364 { } /* end */
9365};
9366
9367/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009368static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009369{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009370 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009371
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009372 spec->autocfg.hp_pins[0] = 0x14;
9373 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009374}
9375
Kailang Yangccc656c2006-10-17 12:32:26 +02009376/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009377#define alc883_targa_init_hook alc882_targa_init_hook
9378#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009379
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009380static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
9381{
9382 unsigned int present;
9383
Takashi Iwaid56757a2009-11-18 08:00:14 +01009384 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009385 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
9386 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9387}
9388
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009389static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009390{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009391 struct alc_spec *spec = codec->spec;
9392
9393 spec->autocfg.hp_pins[0] = 0x15;
9394 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009395}
9396
9397static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9398{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009399 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009400 alc883_clevo_m720_mic_automute(codec);
9401}
9402
9403static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009404 unsigned int res)
9405{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009406 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009407 case ALC880_MIC_EVENT:
9408 alc883_clevo_m720_mic_automute(codec);
9409 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009410 default:
9411 alc_automute_amp_unsol_event(codec, res);
9412 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009413 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009414}
9415
Jiang zhefb97dc62008-03-06 11:07:11 +01009416/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009417static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009418{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009419 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009420
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009421 spec->autocfg.hp_pins[0] = 0x14;
9422 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009423}
9424
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009425static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009426{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009427 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009428
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009429 spec->autocfg.hp_pins[0] = 0x1b;
9430 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009431}
9432
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009433static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9434{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009435 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009436
Takashi Iwai47fd8302007-08-10 17:11:07 +02009437 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9438 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009439}
9440
9441static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9442{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009443 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009444
Takashi Iwai47fd8302007-08-10 17:11:07 +02009445 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9446 HDA_AMP_MUTE, bits);
9447 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9448 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009449}
9450
9451static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9452 unsigned int res)
9453{
9454 if ((res >> 26) == ALC880_HP_EVENT)
9455 alc883_lenovo_101e_all_automute(codec);
9456 if ((res >> 26) == ALC880_FRONT_EVENT)
9457 alc883_lenovo_101e_ispeaker_automute(codec);
9458}
9459
Takashi Iwai676a9b52007-08-16 15:23:35 +02009460/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009461static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009462{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009463 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009464
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009465 spec->autocfg.hp_pins[0] = 0x14;
9466 spec->autocfg.speaker_pins[0] = 0x15;
9467 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009468}
9469
Kailang Yangd1a991a2007-08-15 16:21:59 +02009470static struct hda_verb alc883_acer_eapd_verbs[] = {
9471 /* HP Pin: output 0 (0x0c) */
9472 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9473 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9474 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9475 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009476 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9477 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009478 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009479 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9480 /* eanable EAPD on medion laptop */
9481 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9482 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009483 /* enable unsolicited event */
9484 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009485 { }
9486};
9487
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009488static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
9489 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9490 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9491 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9492 { } /* end */
9493};
9494
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009495static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009496{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009497 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009498
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009499 spec->autocfg.hp_pins[0] = 0x1b;
9500 spec->autocfg.speaker_pins[0] = 0x14;
9501 spec->autocfg.speaker_pins[1] = 0x15;
9502 spec->autocfg.speaker_pins[2] = 0x16;
9503 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009504}
9505
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009506static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009507{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009508 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009509
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009510 spec->autocfg.hp_pins[0] = 0x1b;
9511 spec->autocfg.speaker_pins[0] = 0x14;
9512 spec->autocfg.speaker_pins[1] = 0x15;
9513 spec->autocfg.speaker_pins[2] = 0x16;
9514 spec->autocfg.speaker_pins[3] = 0x17;
9515 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009516}
9517
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009518static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009519{
9520 struct alc_spec *spec = codec->spec;
9521
9522 spec->autocfg.hp_pins[0] = 0x15;
9523 spec->autocfg.speaker_pins[0] = 0x14;
9524 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009525}
9526
Kailang Yange2757d52008-08-26 13:17:46 +02009527static struct hda_verb alc888_asus_m90v_verbs[] = {
9528 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9529 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9530 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9531 /* enable unsolicited event */
9532 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9533 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9534 { } /* end */
9535};
9536
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009537static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009538{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009539 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009540
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009541 spec->autocfg.hp_pins[0] = 0x1b;
9542 spec->autocfg.speaker_pins[0] = 0x14;
9543 spec->autocfg.speaker_pins[1] = 0x15;
9544 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009545 spec->ext_mic.pin = 0x18;
9546 spec->int_mic.pin = 0x19;
9547 spec->ext_mic.mux_idx = 0;
9548 spec->int_mic.mux_idx = 1;
9549 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009550}
9551
9552static struct hda_verb alc888_asus_eee1601_verbs[] = {
9553 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9554 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9555 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9556 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9557 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9558 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9559 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9560 /* enable unsolicited event */
9561 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9562 { } /* end */
9563};
9564
Kailang Yange2757d52008-08-26 13:17:46 +02009565static void alc883_eee1601_inithook(struct hda_codec *codec)
9566{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009567 struct alc_spec *spec = codec->spec;
9568
9569 spec->autocfg.hp_pins[0] = 0x14;
9570 spec->autocfg.speaker_pins[0] = 0x1b;
9571 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009572}
9573
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009574static struct hda_verb alc889A_mb31_verbs[] = {
9575 /* Init rear pin (used as headphone output) */
9576 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9577 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9578 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9579 /* Init line pin (used as output in 4ch and 6ch mode) */
9580 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9581 /* Init line 2 pin (used as headphone out by default) */
9582 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9583 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9584 { } /* end */
9585};
9586
9587/* Mute speakers according to the headphone jack state */
9588static void alc889A_mb31_automute(struct hda_codec *codec)
9589{
9590 unsigned int present;
9591
9592 /* Mute only in 2ch or 4ch mode */
9593 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9594 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009595 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009596 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9597 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9598 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9599 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9600 }
9601}
9602
9603static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9604{
9605 if ((res >> 26) == ALC880_HP_EVENT)
9606 alc889A_mb31_automute(codec);
9607}
9608
Takashi Iwai4953550a2009-06-30 15:28:30 +02009609
Takashi Iwaicb53c622007-08-10 17:21:45 +02009610#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009611#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009612#endif
9613
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009614/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009615#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9616#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9617#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9618#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9619
9620static hda_nid_t alc883_slave_dig_outs[] = {
9621 ALC1200_DIGOUT_NID, 0,
9622};
9623
9624static hda_nid_t alc1200_slave_dig_outs[] = {
9625 ALC883_DIGOUT_NID, 0,
9626};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009627
9628/*
9629 * configuration and preset
9630 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009631static const char *alc882_models[ALC882_MODEL_LAST] = {
9632 [ALC882_3ST_DIG] = "3stack-dig",
9633 [ALC882_6ST_DIG] = "6stack-dig",
9634 [ALC882_ARIMA] = "arima",
9635 [ALC882_W2JC] = "w2jc",
9636 [ALC882_TARGA] = "targa",
9637 [ALC882_ASUS_A7J] = "asus-a7j",
9638 [ALC882_ASUS_A7M] = "asus-a7m",
9639 [ALC885_MACPRO] = "macpro",
9640 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009641 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009642 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009643 [ALC885_MBP3] = "mbp3",
9644 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009645 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009646 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009647 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9648 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009649 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009650 [ALC883_TARGA_DIG] = "targa-dig",
9651 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009652 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009653 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009654 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009655 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009656 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009657 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009658 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009659 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009660 [ALC883_MEDION_MD2] = "medion-md2",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009661 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009662 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009663 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009664 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9665 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009666 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009667 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009668 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009669 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009670 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309671 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009672 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009673 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009674 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009675 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009676 [ALC889A_INTEL] = "intel-alc889a",
9677 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009678 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009679 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009680 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009681 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009682};
9683
Takashi Iwai4953550a2009-06-30 15:28:30 +02009684static struct snd_pci_quirk alc882_cfg_tbl[] = {
9685 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9686
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009687 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009688 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009689 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009690 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9691 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009692 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009693 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9694 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009695 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009696 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009697 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9698 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009699 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9700 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009701 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9702 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009703 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009704 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009705 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009706 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009707 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9708 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009709 /* default Acer -- disabled as it causes more problems.
9710 * model=auto should work fine now
9711 */
9712 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009713
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009714 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009715
Tobin Davisfebe3372007-06-12 11:27:46 +02009716 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009717 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9718 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009719 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009720 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009721 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009722
9723 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9724 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9725 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009726 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009727 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9728 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9729 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009730 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009731 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009732 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009733 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009734
9735 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009736 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009737 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009738 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009739 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9740 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009741 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009742 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009743 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9744
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009745 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9746 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9747 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009748 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009749 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009750 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009751 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009752 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009753 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9754 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9755 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9756 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9757 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9758 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009759 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009760 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9761 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9762 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009763 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009764 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009765 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9766 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009767 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009768 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009769 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009770 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009771 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009772 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009773 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009774 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009775 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009776
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009777 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009778 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009779 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9780 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309781 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009782 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009783 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009784 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009785 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009786 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009787 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009788 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009789 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009790 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009791 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009792 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9793 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009794 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009795 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009796 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009797 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009798 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009799
Jiang zhe17bba1b2008-06-04 12:11:07 +02009800 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9801 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009802 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009803 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9804 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9805 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009806 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009807
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009808 {}
9809};
9810
Takashi Iwai4953550a2009-06-30 15:28:30 +02009811/* codec SSID table for Intel Mac */
9812static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9813 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9814 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9815 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9816 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9817 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9818 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9819 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009820 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009821 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009822 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009823 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009824 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9825 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9826 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009827 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009828 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +10009829 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009830 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9831 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009832 */
9833 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009834 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009835 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009836 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009837};
9838
Takashi Iwai4953550a2009-06-30 15:28:30 +02009839static struct alc_config_preset alc882_presets[] = {
9840 [ALC882_3ST_DIG] = {
9841 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009842 .init_verbs = { alc882_base_init_verbs,
9843 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009844 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9845 .dac_nids = alc882_dac_nids,
9846 .dig_out_nid = ALC882_DIGOUT_NID,
9847 .dig_in_nid = ALC882_DIGIN_NID,
9848 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9849 .channel_mode = alc882_ch_modes,
9850 .need_dac_fix = 1,
9851 .input_mux = &alc882_capture_source,
9852 },
9853 [ALC882_6ST_DIG] = {
9854 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009855 .init_verbs = { alc882_base_init_verbs,
9856 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009857 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9858 .dac_nids = alc882_dac_nids,
9859 .dig_out_nid = ALC882_DIGOUT_NID,
9860 .dig_in_nid = ALC882_DIGIN_NID,
9861 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9862 .channel_mode = alc882_sixstack_modes,
9863 .input_mux = &alc882_capture_source,
9864 },
9865 [ALC882_ARIMA] = {
9866 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009867 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9868 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009869 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9870 .dac_nids = alc882_dac_nids,
9871 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9872 .channel_mode = alc882_sixstack_modes,
9873 .input_mux = &alc882_capture_source,
9874 },
9875 [ALC882_W2JC] = {
9876 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009877 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9878 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009879 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9880 .dac_nids = alc882_dac_nids,
9881 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9882 .channel_mode = alc880_threestack_modes,
9883 .need_dac_fix = 1,
9884 .input_mux = &alc882_capture_source,
9885 .dig_out_nid = ALC882_DIGOUT_NID,
9886 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009887 [ALC885_MBA21] = {
9888 .mixers = { alc885_mba21_mixer },
9889 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9890 .num_dacs = 2,
9891 .dac_nids = alc882_dac_nids,
9892 .channel_mode = alc885_mba21_ch_modes,
9893 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9894 .input_mux = &alc882_capture_source,
9895 .unsol_event = alc_automute_amp_unsol_event,
9896 .setup = alc885_mba21_setup,
9897 .init_hook = alc_automute_amp,
9898 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009899 [ALC885_MBP3] = {
9900 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9901 .init_verbs = { alc885_mbp3_init_verbs,
9902 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009903 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009904 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009905 .hp_nid = 0x04,
9906 .channel_mode = alc885_mbp_4ch_modes,
9907 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009908 .input_mux = &alc882_capture_source,
9909 .dig_out_nid = ALC882_DIGOUT_NID,
9910 .dig_in_nid = ALC882_DIGIN_NID,
9911 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009912 .setup = alc885_mbp3_setup,
9913 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009914 },
9915 [ALC885_MB5] = {
9916 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9917 .init_verbs = { alc885_mb5_init_verbs,
9918 alc880_gpio1_init_verbs },
9919 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9920 .dac_nids = alc882_dac_nids,
9921 .channel_mode = alc885_mb5_6ch_modes,
9922 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9923 .input_mux = &mb5_capture_source,
9924 .dig_out_nid = ALC882_DIGOUT_NID,
9925 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009926 .unsol_event = alc_automute_amp_unsol_event,
9927 .setup = alc885_mb5_setup,
9928 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009929 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009930 [ALC885_MACMINI3] = {
9931 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
9932 .init_verbs = { alc885_macmini3_init_verbs,
9933 alc880_gpio1_init_verbs },
9934 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9935 .dac_nids = alc882_dac_nids,
9936 .channel_mode = alc885_macmini3_6ch_modes,
9937 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
9938 .input_mux = &macmini3_capture_source,
9939 .dig_out_nid = ALC882_DIGOUT_NID,
9940 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009941 .unsol_event = alc_automute_amp_unsol_event,
9942 .setup = alc885_macmini3_setup,
9943 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009944 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009945 [ALC885_MACPRO] = {
9946 .mixers = { alc882_macpro_mixer },
9947 .init_verbs = { alc882_macpro_init_verbs },
9948 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9949 .dac_nids = alc882_dac_nids,
9950 .dig_out_nid = ALC882_DIGOUT_NID,
9951 .dig_in_nid = ALC882_DIGIN_NID,
9952 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9953 .channel_mode = alc882_ch_modes,
9954 .input_mux = &alc882_capture_source,
9955 .init_hook = alc885_macpro_init_hook,
9956 },
9957 [ALC885_IMAC24] = {
9958 .mixers = { alc885_imac24_mixer },
9959 .init_verbs = { alc885_imac24_init_verbs },
9960 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9961 .dac_nids = alc882_dac_nids,
9962 .dig_out_nid = ALC882_DIGOUT_NID,
9963 .dig_in_nid = ALC882_DIGIN_NID,
9964 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9965 .channel_mode = alc882_ch_modes,
9966 .input_mux = &alc882_capture_source,
9967 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009968 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009969 .init_hook = alc885_imac24_init_hook,
9970 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009971 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07009972 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009973 .init_verbs = { alc885_imac91_init_verbs,
9974 alc880_gpio1_init_verbs },
9975 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9976 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07009977 .channel_mode = alc885_mba21_ch_modes,
9978 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9979 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009980 .dig_out_nid = ALC882_DIGOUT_NID,
9981 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009982 .unsol_event = alc_automute_amp_unsol_event,
9983 .setup = alc885_imac91_setup,
9984 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009985 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009986 [ALC882_TARGA] = {
9987 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009988 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009989 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009990 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9991 .dac_nids = alc882_dac_nids,
9992 .dig_out_nid = ALC882_DIGOUT_NID,
9993 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9994 .adc_nids = alc882_adc_nids,
9995 .capsrc_nids = alc882_capsrc_nids,
9996 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9997 .channel_mode = alc882_3ST_6ch_modes,
9998 .need_dac_fix = 1,
9999 .input_mux = &alc882_capture_source,
10000 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010001 .setup = alc882_targa_setup,
10002 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010003 },
10004 [ALC882_ASUS_A7J] = {
10005 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010006 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10007 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010008 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10009 .dac_nids = alc882_dac_nids,
10010 .dig_out_nid = ALC882_DIGOUT_NID,
10011 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10012 .adc_nids = alc882_adc_nids,
10013 .capsrc_nids = alc882_capsrc_nids,
10014 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10015 .channel_mode = alc882_3ST_6ch_modes,
10016 .need_dac_fix = 1,
10017 .input_mux = &alc882_capture_source,
10018 },
10019 [ALC882_ASUS_A7M] = {
10020 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010021 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10022 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010023 alc882_asus_a7m_verbs },
10024 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10025 .dac_nids = alc882_dac_nids,
10026 .dig_out_nid = ALC882_DIGOUT_NID,
10027 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10028 .channel_mode = alc880_threestack_modes,
10029 .need_dac_fix = 1,
10030 .input_mux = &alc882_capture_source,
10031 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010032 [ALC883_3ST_2ch_DIG] = {
10033 .mixers = { alc883_3ST_2ch_mixer },
10034 .init_verbs = { alc883_init_verbs },
10035 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10036 .dac_nids = alc883_dac_nids,
10037 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010038 .dig_in_nid = ALC883_DIGIN_NID,
10039 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10040 .channel_mode = alc883_3ST_2ch_modes,
10041 .input_mux = &alc883_capture_source,
10042 },
10043 [ALC883_3ST_6ch_DIG] = {
10044 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10045 .init_verbs = { alc883_init_verbs },
10046 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10047 .dac_nids = alc883_dac_nids,
10048 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010049 .dig_in_nid = ALC883_DIGIN_NID,
10050 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10051 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010052 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010053 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010054 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010055 [ALC883_3ST_6ch] = {
10056 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10057 .init_verbs = { alc883_init_verbs },
10058 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10059 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010060 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10061 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010062 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010063 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010064 },
Jiang zhe17bba1b2008-06-04 12:11:07 +020010065 [ALC883_3ST_6ch_INTEL] = {
10066 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
10067 .init_verbs = { alc883_init_verbs },
10068 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10069 .dac_nids = alc883_dac_nids,
10070 .dig_out_nid = ALC883_DIGOUT_NID,
10071 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010072 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +020010073 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
10074 .channel_mode = alc883_3ST_6ch_intel_modes,
10075 .need_dac_fix = 1,
10076 .input_mux = &alc883_3stack_6ch_intel,
10077 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010078 [ALC889A_INTEL] = {
10079 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020010080 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
10081 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010082 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10083 .dac_nids = alc883_dac_nids,
10084 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10085 .adc_nids = alc889_adc_nids,
10086 .dig_out_nid = ALC883_DIGOUT_NID,
10087 .dig_in_nid = ALC883_DIGIN_NID,
10088 .slave_dig_outs = alc883_slave_dig_outs,
10089 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10090 .channel_mode = alc889_8ch_intel_modes,
10091 .capsrc_nids = alc889_capsrc_nids,
10092 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010093 .setup = alc889_automute_setup,
10094 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010095 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010096 .need_dac_fix = 1,
10097 },
10098 [ALC889_INTEL] = {
10099 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
10100 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010101 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010102 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10103 .dac_nids = alc883_dac_nids,
10104 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10105 .adc_nids = alc889_adc_nids,
10106 .dig_out_nid = ALC883_DIGOUT_NID,
10107 .dig_in_nid = ALC883_DIGIN_NID,
10108 .slave_dig_outs = alc883_slave_dig_outs,
10109 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10110 .channel_mode = alc889_8ch_intel_modes,
10111 .capsrc_nids = alc889_capsrc_nids,
10112 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010113 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010114 .init_hook = alc889_intel_init_hook,
10115 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010116 .need_dac_fix = 1,
10117 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010118 [ALC883_6ST_DIG] = {
10119 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10120 .init_verbs = { alc883_init_verbs },
10121 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10122 .dac_nids = alc883_dac_nids,
10123 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010124 .dig_in_nid = ALC883_DIGIN_NID,
10125 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10126 .channel_mode = alc883_sixstack_modes,
10127 .input_mux = &alc883_capture_source,
10128 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010129 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010130 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010131 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10132 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010133 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10134 .dac_nids = alc883_dac_nids,
10135 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010136 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10137 .channel_mode = alc883_3ST_6ch_modes,
10138 .need_dac_fix = 1,
10139 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010140 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010141 .setup = alc882_targa_setup,
10142 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010143 },
10144 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010145 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010146 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10147 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010148 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10149 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010150 .adc_nids = alc883_adc_nids_alt,
10151 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010152 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010153 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010154 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10155 .channel_mode = alc883_3ST_2ch_modes,
10156 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010157 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010158 .setup = alc882_targa_setup,
10159 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010160 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010161 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010162 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10163 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010164 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010165 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010166 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10167 .dac_nids = alc883_dac_nids,
10168 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10169 .adc_nids = alc883_adc_nids_rev,
10170 .capsrc_nids = alc883_capsrc_nids_rev,
10171 .dig_out_nid = ALC883_DIGOUT_NID,
10172 .dig_in_nid = ALC883_DIGIN_NID,
10173 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10174 .channel_mode = alc883_4ST_8ch_modes,
10175 .need_dac_fix = 1,
10176 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010177 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010178 .setup = alc882_targa_setup,
10179 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010180 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010181 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010182 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010183 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10184 * and the headphone jack. Turn this on and rely on the
10185 * standard mute methods whenever the user wants to turn
10186 * these outputs off.
10187 */
10188 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10189 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10190 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010191 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10192 .channel_mode = alc883_3ST_2ch_modes,
10193 .input_mux = &alc883_capture_source,
10194 },
Tobin Davis2880a862007-08-07 11:50:26 +020010195 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010196 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010197 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010198 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10199 .dac_nids = alc883_dac_nids,
10200 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010201 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10202 .channel_mode = alc883_3ST_2ch_modes,
10203 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010204 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010205 .setup = alc883_acer_aspire_setup,
10206 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010207 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010208 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010209 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010210 alc883_chmode_mixer },
10211 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10212 alc888_acer_aspire_4930g_verbs },
10213 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10214 .dac_nids = alc883_dac_nids,
10215 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10216 .adc_nids = alc883_adc_nids_rev,
10217 .capsrc_nids = alc883_capsrc_nids_rev,
10218 .dig_out_nid = ALC883_DIGOUT_NID,
10219 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10220 .channel_mode = alc883_3ST_6ch_modes,
10221 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010222 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010223 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010224 ARRAY_SIZE(alc888_2_capture_sources),
10225 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010226 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010227 .setup = alc888_acer_aspire_4930g_setup,
10228 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010229 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010230 [ALC888_ACER_ASPIRE_6530G] = {
10231 .mixers = { alc888_acer_aspire_6530_mixer },
10232 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10233 alc888_acer_aspire_6530g_verbs },
10234 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10235 .dac_nids = alc883_dac_nids,
10236 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10237 .adc_nids = alc883_adc_nids_rev,
10238 .capsrc_nids = alc883_capsrc_nids_rev,
10239 .dig_out_nid = ALC883_DIGOUT_NID,
10240 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10241 .channel_mode = alc883_3ST_2ch_modes,
10242 .num_mux_defs =
10243 ARRAY_SIZE(alc888_2_capture_sources),
10244 .input_mux = alc888_acer_aspire_6530_sources,
10245 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010246 .setup = alc888_acer_aspire_6530g_setup,
10247 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010248 },
Hector Martin3b315d72009-06-02 10:54:19 +020010249 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010250 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010251 alc883_chmode_mixer },
10252 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010253 alc889_acer_aspire_8930g_verbs,
10254 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010255 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10256 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010257 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10258 .adc_nids = alc889_adc_nids,
10259 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010260 .dig_out_nid = ALC883_DIGOUT_NID,
10261 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10262 .channel_mode = alc883_3ST_6ch_modes,
10263 .need_dac_fix = 1,
10264 .const_channel_count = 6,
10265 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010266 ARRAY_SIZE(alc889_capture_sources),
10267 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +020010268 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010269 .setup = alc889_acer_aspire_8930g_setup,
10270 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +010010271#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010272 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010273#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010274 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010275 [ALC888_ACER_ASPIRE_7730G] = {
10276 .mixers = { alc883_3ST_6ch_mixer,
10277 alc883_chmode_mixer },
10278 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10279 alc888_acer_aspire_7730G_verbs },
10280 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10281 .dac_nids = alc883_dac_nids,
10282 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10283 .adc_nids = alc883_adc_nids_rev,
10284 .capsrc_nids = alc883_capsrc_nids_rev,
10285 .dig_out_nid = ALC883_DIGOUT_NID,
10286 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10287 .channel_mode = alc883_3ST_6ch_modes,
10288 .need_dac_fix = 1,
10289 .const_channel_count = 6,
10290 .input_mux = &alc883_capture_source,
10291 .unsol_event = alc_automute_amp_unsol_event,
10292 .setup = alc888_acer_aspire_6530g_setup,
10293 .init_hook = alc_automute_amp,
10294 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010295 [ALC883_MEDION] = {
10296 .mixers = { alc883_fivestack_mixer,
10297 alc883_chmode_mixer },
10298 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010299 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010300 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10301 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010302 .adc_nids = alc883_adc_nids_alt,
10303 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010304 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010305 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10306 .channel_mode = alc883_sixstack_modes,
10307 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010308 },
Kailang Yang272a5272007-05-14 11:00:38 +020010309 [ALC883_MEDION_MD2] = {
10310 .mixers = { alc883_medion_md2_mixer},
10311 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
10312 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10313 .dac_nids = alc883_dac_nids,
10314 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010315 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10316 .channel_mode = alc883_3ST_2ch_modes,
10317 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010318 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010319 .setup = alc883_medion_md2_setup,
10320 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020010321 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010322 [ALC883_MEDION_WIM2160] = {
10323 .mixers = { alc883_medion_wim2160_mixer },
10324 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10325 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10326 .dac_nids = alc883_dac_nids,
10327 .dig_out_nid = ALC883_DIGOUT_NID,
10328 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10329 .adc_nids = alc883_adc_nids,
10330 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10331 .channel_mode = alc883_3ST_2ch_modes,
10332 .input_mux = &alc883_capture_source,
10333 .unsol_event = alc_automute_amp_unsol_event,
10334 .setup = alc883_medion_wim2160_setup,
10335 .init_hook = alc_automute_amp,
10336 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010337 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010338 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010339 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10340 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10341 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010342 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10343 .channel_mode = alc883_3ST_2ch_modes,
10344 .input_mux = &alc883_capture_source,
10345 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010346 [ALC883_CLEVO_M540R] = {
10347 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10348 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10349 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10350 .dac_nids = alc883_dac_nids,
10351 .dig_out_nid = ALC883_DIGOUT_NID,
10352 .dig_in_nid = ALC883_DIGIN_NID,
10353 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10354 .channel_mode = alc883_3ST_6ch_clevo_modes,
10355 .need_dac_fix = 1,
10356 .input_mux = &alc883_capture_source,
10357 /* This machine has the hardware HP auto-muting, thus
10358 * we need no software mute via unsol event
10359 */
10360 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010361 [ALC883_CLEVO_M720] = {
10362 .mixers = { alc883_clevo_m720_mixer },
10363 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010364 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10365 .dac_nids = alc883_dac_nids,
10366 .dig_out_nid = ALC883_DIGOUT_NID,
10367 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10368 .channel_mode = alc883_3ST_2ch_modes,
10369 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010370 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010371 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010372 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010373 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010374 [ALC883_LENOVO_101E_2ch] = {
10375 .mixers = { alc883_lenovo_101e_2ch_mixer},
10376 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10377 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10378 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010379 .adc_nids = alc883_adc_nids_alt,
10380 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010381 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010382 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10383 .channel_mode = alc883_3ST_2ch_modes,
10384 .input_mux = &alc883_lenovo_101e_capture_source,
10385 .unsol_event = alc883_lenovo_101e_unsol_event,
10386 .init_hook = alc883_lenovo_101e_all_automute,
10387 },
Kailang Yang272a5272007-05-14 11:00:38 +020010388 [ALC883_LENOVO_NB0763] = {
10389 .mixers = { alc883_lenovo_nb0763_mixer },
10390 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10391 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10392 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010393 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10394 .channel_mode = alc883_3ST_2ch_modes,
10395 .need_dac_fix = 1,
10396 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010397 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010398 .setup = alc883_medion_md2_setup,
10399 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010400 },
10401 [ALC888_LENOVO_MS7195_DIG] = {
10402 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10403 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10404 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10405 .dac_nids = alc883_dac_nids,
10406 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010407 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10408 .channel_mode = alc883_3ST_6ch_modes,
10409 .need_dac_fix = 1,
10410 .input_mux = &alc883_capture_source,
10411 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10412 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010413 },
10414 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010415 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010416 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10417 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10418 .dac_nids = alc883_dac_nids,
10419 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010420 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10421 .channel_mode = alc883_3ST_2ch_modes,
10422 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010423 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010424 .setup = alc883_haier_w66_setup,
10425 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010426 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010427 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010428 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010429 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010430 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10431 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010432 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10433 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010434 .need_dac_fix = 1,
10435 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010436 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010437 .setup = alc888_3st_hp_setup,
10438 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010439 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010440 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010441 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010442 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10443 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10444 .dac_nids = alc883_dac_nids,
10445 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010446 .dig_in_nid = ALC883_DIGIN_NID,
10447 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10448 .channel_mode = alc883_sixstack_modes,
10449 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010450 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010451 .setup = alc888_6st_dell_setup,
10452 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010453 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010454 [ALC883_MITAC] = {
10455 .mixers = { alc883_mitac_mixer },
10456 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10457 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10458 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010459 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10460 .channel_mode = alc883_3ST_2ch_modes,
10461 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010462 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010463 .setup = alc883_mitac_setup,
10464 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010465 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010466 [ALC883_FUJITSU_PI2515] = {
10467 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10468 .init_verbs = { alc883_init_verbs,
10469 alc883_2ch_fujitsu_pi2515_verbs},
10470 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10471 .dac_nids = alc883_dac_nids,
10472 .dig_out_nid = ALC883_DIGOUT_NID,
10473 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10474 .channel_mode = alc883_3ST_2ch_modes,
10475 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010476 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010477 .setup = alc883_2ch_fujitsu_pi2515_setup,
10478 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010479 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010480 [ALC888_FUJITSU_XA3530] = {
10481 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10482 .init_verbs = { alc883_init_verbs,
10483 alc888_fujitsu_xa3530_verbs },
10484 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10485 .dac_nids = alc883_dac_nids,
10486 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10487 .adc_nids = alc883_adc_nids_rev,
10488 .capsrc_nids = alc883_capsrc_nids_rev,
10489 .dig_out_nid = ALC883_DIGOUT_NID,
10490 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10491 .channel_mode = alc888_4ST_8ch_intel_modes,
10492 .num_mux_defs =
10493 ARRAY_SIZE(alc888_2_capture_sources),
10494 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010495 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010496 .setup = alc888_fujitsu_xa3530_setup,
10497 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010498 },
Kailang Yange2757d52008-08-26 13:17:46 +020010499 [ALC888_LENOVO_SKY] = {
10500 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10501 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10502 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10503 .dac_nids = alc883_dac_nids,
10504 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010505 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10506 .channel_mode = alc883_sixstack_modes,
10507 .need_dac_fix = 1,
10508 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010509 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010510 .setup = alc888_lenovo_sky_setup,
10511 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010512 },
10513 [ALC888_ASUS_M90V] = {
10514 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10515 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10516 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10517 .dac_nids = alc883_dac_nids,
10518 .dig_out_nid = ALC883_DIGOUT_NID,
10519 .dig_in_nid = ALC883_DIGIN_NID,
10520 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10521 .channel_mode = alc883_3ST_6ch_modes,
10522 .need_dac_fix = 1,
10523 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010524 .unsol_event = alc_sku_unsol_event,
10525 .setup = alc883_mode2_setup,
10526 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010527 },
10528 [ALC888_ASUS_EEE1601] = {
10529 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010530 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010531 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10532 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10533 .dac_nids = alc883_dac_nids,
10534 .dig_out_nid = ALC883_DIGOUT_NID,
10535 .dig_in_nid = ALC883_DIGIN_NID,
10536 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10537 .channel_mode = alc883_3ST_2ch_modes,
10538 .need_dac_fix = 1,
10539 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010540 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010541 .init_hook = alc883_eee1601_inithook,
10542 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010543 [ALC1200_ASUS_P5Q] = {
10544 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10545 .init_verbs = { alc883_init_verbs },
10546 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10547 .dac_nids = alc883_dac_nids,
10548 .dig_out_nid = ALC1200_DIGOUT_NID,
10549 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010550 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010551 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10552 .channel_mode = alc883_sixstack_modes,
10553 .input_mux = &alc883_capture_source,
10554 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010555 [ALC889A_MB31] = {
10556 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10557 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10558 alc880_gpio1_init_verbs },
10559 .adc_nids = alc883_adc_nids,
10560 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010561 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010562 .dac_nids = alc883_dac_nids,
10563 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10564 .channel_mode = alc889A_mb31_6ch_modes,
10565 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10566 .input_mux = &alc889A_mb31_capture_source,
10567 .dig_out_nid = ALC883_DIGOUT_NID,
10568 .unsol_event = alc889A_mb31_unsol_event,
10569 .init_hook = alc889A_mb31_automute,
10570 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010571 [ALC883_SONY_VAIO_TT] = {
10572 .mixers = { alc883_vaiott_mixer },
10573 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10574 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10575 .dac_nids = alc883_dac_nids,
10576 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10577 .channel_mode = alc883_3ST_2ch_modes,
10578 .input_mux = &alc883_capture_source,
10579 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010580 .setup = alc883_vaiott_setup,
10581 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010582 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010583};
10584
10585
10586/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010587 * Pin config fixes
10588 */
10589enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010590 PINFIX_ABIT_AW9D_MAX,
10591 PINFIX_PB_M5210,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010592};
10593
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010594static const struct alc_fixup alc882_fixups[] = {
10595 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010596 .pins = (const struct alc_pincfg[]) {
10597 { 0x15, 0x01080104 }, /* side */
10598 { 0x16, 0x01011012 }, /* rear */
10599 { 0x17, 0x01016011 }, /* clfe */
10600 { }
10601 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010602 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010603 [PINFIX_PB_M5210] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010604 .verbs = (const struct hda_verb[]) {
10605 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10606 {}
10607 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020010608 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010609};
10610
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010611static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010612 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010613 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
10614 {}
10615};
10616
10617/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010618 * BIOS auto configuration
10619 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010620static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10621 const struct auto_pin_cfg *cfg)
10622{
10623 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10624}
10625
Takashi Iwai4953550a2009-06-30 15:28:30 +020010626static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010627 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010628 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010629{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010630 int idx;
10631
Takashi Iwai489008c2010-04-07 09:06:00 +020010632 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010633 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010634
Takashi Iwai489008c2010-04-07 09:06:00 +020010635 if (dac == 0x25)
10636 idx = 4;
10637 else if (dac >= 0x02 && dac <= 0x05)
10638 idx = dac - 2;
10639 else
10640 return;
10641 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010642}
10643
Takashi Iwai4953550a2009-06-30 15:28:30 +020010644static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010645{
10646 struct alc_spec *spec = codec->spec;
10647 int i;
10648
10649 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010650 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010651 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010652 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010653 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010654 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010655 }
10656}
10657
Takashi Iwai4953550a2009-06-30 15:28:30 +020010658static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010659{
10660 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010661 hda_nid_t pin, dac;
Takashi Iwai5855fb82010-09-16 18:24:02 +020010662 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010663
Takashi Iwai5855fb82010-09-16 18:24:02 +020010664 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
10665 pin = spec->autocfg.hp_pins[i];
10666 if (!pin)
10667 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010668 dac = spec->multiout.hp_nid;
10669 if (!dac)
10670 dac = spec->multiout.dac_nids[0]; /* to front */
10671 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10672 }
Takashi Iwai5855fb82010-09-16 18:24:02 +020010673 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
10674 pin = spec->autocfg.speaker_pins[i];
10675 if (!pin)
10676 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010677 dac = spec->multiout.extra_out_nid[0];
10678 if (!dac)
10679 dac = spec->multiout.dac_nids[0]; /* to front */
10680 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10681 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010682}
10683
Takashi Iwai4953550a2009-06-30 15:28:30 +020010684static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010685{
10686 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010687 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010688 int i;
10689
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010690 for (i = 0; i < cfg->num_inputs; i++) {
10691 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai30ea0982010-09-16 18:47:56 +020010692 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010693 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10694 snd_hda_codec_write(codec, nid, 0,
10695 AC_VERB_SET_AMP_GAIN_MUTE,
10696 AMP_OUT_MUTE);
10697 }
10698}
10699
10700static void alc882_auto_init_input_src(struct hda_codec *codec)
10701{
10702 struct alc_spec *spec = codec->spec;
10703 int c;
10704
10705 for (c = 0; c < spec->num_adc_nids; c++) {
10706 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10707 hda_nid_t nid = spec->capsrc_nids[c];
10708 unsigned int mux_idx;
10709 const struct hda_input_mux *imux;
10710 int conns, mute, idx, item;
10711
10712 conns = snd_hda_get_connections(codec, nid, conn_list,
10713 ARRAY_SIZE(conn_list));
10714 if (conns < 0)
10715 continue;
10716 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10717 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010718 if (!imux->num_items && mux_idx > 0)
10719 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010720 for (idx = 0; idx < conns; idx++) {
10721 /* if the current connection is the selected one,
10722 * unmute it as default - otherwise mute it
10723 */
10724 mute = AMP_IN_MUTE(idx);
10725 for (item = 0; item < imux->num_items; item++) {
10726 if (imux->items[item].index == idx) {
10727 if (spec->cur_mux[c] == item)
10728 mute = AMP_IN_UNMUTE(idx);
10729 break;
10730 }
10731 }
10732 /* check if we have a selector or mixer
10733 * we could check for the widget type instead, but
10734 * just check for Amp-In presence (in case of mixer
10735 * without amp-in there is something wrong, this
10736 * function shouldn't be used or capsrc nid is wrong)
10737 */
10738 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010739 snd_hda_codec_write(codec, nid, 0,
10740 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010741 mute);
10742 else if (mute != AMP_IN_MUTE(idx))
10743 snd_hda_codec_write(codec, nid, 0,
10744 AC_VERB_SET_CONNECT_SEL,
10745 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010746 }
10747 }
10748}
10749
Takashi Iwai4953550a2009-06-30 15:28:30 +020010750/* add mic boosts if needed */
10751static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010752{
10753 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010754 struct auto_pin_cfg *cfg = &spec->autocfg;
10755 int i, err;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010756 hda_nid_t nid;
10757
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010758 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020010759 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010760 break;
10761 nid = cfg->inputs[i].pin;
10762 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
Takashi Iwai10a20af2010-09-09 16:28:02 +020010763 char label[32];
10764 snprintf(label, sizeof(label), "%s Boost",
10765 hda_get_autocfg_input_label(codec, cfg, i));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010766 err = add_control(spec, ALC_CTL_WIDGET_VOL, label, 0,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010767 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010768 if (err < 0)
10769 return err;
10770 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010771 }
10772 return 0;
10773}
10774
10775/* almost identical with ALC880 parser... */
10776static int alc882_parse_auto_config(struct hda_codec *codec)
10777{
10778 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010779 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020010780 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010781
Takashi Iwai05f5f472009-08-25 13:10:18 +020010782 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10783 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010784 if (err < 0)
10785 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010786 if (!spec->autocfg.line_outs)
10787 return 0; /* can't find valid BIOS pin config */
10788
10789 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10790 if (err < 0)
10791 return err;
10792 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10793 if (err < 0)
10794 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010795 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10796 "Headphone");
10797 if (err < 0)
10798 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010799 err = alc880_auto_create_extra_out(spec,
10800 spec->autocfg.speaker_pins[0],
10801 "Speaker");
10802 if (err < 0)
10803 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010804 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10805 if (err < 0)
10806 return err;
10807
10808 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10809
Takashi Iwai757899a2010-07-30 10:48:14 +020010810 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010811
10812 if (spec->kctls.list)
10813 add_mixer(spec, spec->kctls.list);
10814
10815 add_verb(spec, alc883_auto_init_verbs);
10816 /* if ADC 0x07 is available, initialize it, too */
10817 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10818 add_verb(spec, alc882_adc1_init_verbs);
10819
10820 spec->num_mux_defs = 1;
10821 spec->input_mux = &spec->private_imux[0];
10822
Kailang Yang6227cdc2010-02-25 08:36:52 +010010823 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010824
10825 err = alc_auto_add_mic_boost(codec);
10826 if (err < 0)
10827 return err;
10828
Takashi Iwai776e1842007-08-29 15:07:11 +020010829 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010830}
10831
10832/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010833static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010834{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010835 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010836 alc882_auto_init_multi_out(codec);
10837 alc882_auto_init_hp_out(codec);
10838 alc882_auto_init_analog_input(codec);
10839 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020010840 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010841 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010842 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010843}
10844
Takashi Iwai4953550a2009-06-30 15:28:30 +020010845static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010846{
10847 struct alc_spec *spec;
10848 int err, board_config;
10849
10850 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10851 if (spec == NULL)
10852 return -ENOMEM;
10853
10854 codec->spec = spec;
10855
Kailang Yangda00c242010-03-19 11:23:45 +010010856 alc_auto_parse_customize_define(codec);
10857
Takashi Iwai4953550a2009-06-30 15:28:30 +020010858 switch (codec->vendor_id) {
10859 case 0x10ec0882:
10860 case 0x10ec0885:
10861 break;
10862 default:
10863 /* ALC883 and variants */
10864 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10865 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010866 }
10867
Takashi Iwai4953550a2009-06-30 15:28:30 +020010868 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10869 alc882_models,
10870 alc882_cfg_tbl);
10871
10872 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10873 board_config = snd_hda_check_board_codec_sid_config(codec,
10874 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10875
10876 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010877 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010878 codec->chip_name);
10879 board_config = ALC882_AUTO;
10880 }
10881
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010882 if (board_config == ALC882_AUTO)
10883 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 1);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010884
10885 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010886 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010887 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010888 if (err < 0) {
10889 alc_free(codec);
10890 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010891 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010892 printk(KERN_INFO
10893 "hda_codec: Cannot set up configuration "
10894 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010895 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010896 }
10897 }
10898
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010899 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020010900 err = snd_hda_attach_beep_device(codec, 0x1);
10901 if (err < 0) {
10902 alc_free(codec);
10903 return err;
10904 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010905 }
10906
Takashi Iwai4953550a2009-06-30 15:28:30 +020010907 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010908 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010909
Takashi Iwai4953550a2009-06-30 15:28:30 +020010910 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10911 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10912 /* FIXME: setup DAC5 */
10913 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10914 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10915
10916 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10917 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10918
Takashi Iwai4953550a2009-06-30 15:28:30 +020010919 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010920 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010921 spec->num_adc_nids = 0;
10922 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010923 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010924 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010925 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010926 hda_nid_t nid = alc882_adc_nids[i];
10927 unsigned int wcap = get_wcaps(codec, nid);
10928 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010929 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010930 if (wcap != AC_WID_AUD_IN)
10931 continue;
10932 spec->private_adc_nids[spec->num_adc_nids] = nid;
10933 err = snd_hda_get_connections(codec, nid, &cap, 1);
10934 if (err < 0)
10935 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010936 err = snd_hda_get_connections(codec, cap, items,
10937 ARRAY_SIZE(items));
10938 if (err < 0)
10939 continue;
10940 for (j = 0; j < imux->num_items; j++)
10941 if (imux->items[j].index >= err)
10942 break;
10943 if (j < imux->num_items)
10944 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010945 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10946 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010947 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010948 spec->adc_nids = spec->private_adc_nids;
10949 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010950 }
10951
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010952 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010010953
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010954 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010010955 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010956
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010957 if (board_config == ALC882_AUTO)
10958 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 0);
10959
Takashi Iwai2134ea42008-01-10 16:53:55 +010010960 spec->vmaster_nid = 0x0c;
10961
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010962 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010963 if (board_config == ALC882_AUTO)
10964 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010965#ifdef CONFIG_SND_HDA_POWER_SAVE
10966 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010967 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010968#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010969
10970 return 0;
10971}
10972
Takashi Iwai4953550a2009-06-30 15:28:30 +020010973
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010974/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010975 * ALC262 support
10976 */
10977
10978#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10979#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10980
10981#define alc262_dac_nids alc260_dac_nids
10982#define alc262_adc_nids alc882_adc_nids
10983#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010984#define alc262_capsrc_nids alc882_capsrc_nids
10985#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010986
10987#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010988#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010989
Kailang Yang4e555fe2008-08-26 13:05:55 +020010990static hda_nid_t alc262_dmic_adc_nids[1] = {
10991 /* ADC0 */
10992 0x09
10993};
10994
10995static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10996
Kailang Yangdf694da2005-12-05 19:42:22 +010010997static struct snd_kcontrol_new alc262_base_mixer[] = {
10998 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10999 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11000 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11001 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11002 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11003 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11004 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11005 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011006 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011007 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11008 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011009 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011010 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
11011 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11012 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
11013 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011014 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010011015};
11016
Takashi Iwaice875f02008-01-28 18:17:43 +010011017/* update HP, line and mono-out pins according to the master switch */
11018static void alc262_hp_master_update(struct hda_codec *codec)
11019{
11020 struct alc_spec *spec = codec->spec;
11021 int val = spec->master_sw;
11022
11023 /* HP & line-out */
11024 snd_hda_codec_write_cache(codec, 0x1b, 0,
11025 AC_VERB_SET_PIN_WIDGET_CONTROL,
11026 val ? PIN_HP : 0);
11027 snd_hda_codec_write_cache(codec, 0x15, 0,
11028 AC_VERB_SET_PIN_WIDGET_CONTROL,
11029 val ? PIN_HP : 0);
11030 /* mono (speaker) depending on the HP jack sense */
11031 val = val && !spec->jack_present;
11032 snd_hda_codec_write_cache(codec, 0x16, 0,
11033 AC_VERB_SET_PIN_WIDGET_CONTROL,
11034 val ? PIN_OUT : 0);
11035}
11036
11037static void alc262_hp_bpc_automute(struct hda_codec *codec)
11038{
11039 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011040
11041 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010011042 alc262_hp_master_update(codec);
11043}
11044
11045static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
11046{
11047 if ((res >> 26) != ALC880_HP_EVENT)
11048 return;
11049 alc262_hp_bpc_automute(codec);
11050}
11051
11052static void alc262_hp_wildwest_automute(struct hda_codec *codec)
11053{
11054 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011055
11056 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010011057 alc262_hp_master_update(codec);
11058}
11059
11060static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
11061 unsigned int res)
11062{
11063 if ((res >> 26) != ALC880_HP_EVENT)
11064 return;
11065 alc262_hp_wildwest_automute(codec);
11066}
11067
Takashi Iwaib72519b2009-05-08 14:31:55 +020011068#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010011069
11070static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
11071 struct snd_ctl_elem_value *ucontrol)
11072{
11073 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11074 struct alc_spec *spec = codec->spec;
11075 int val = !!*ucontrol->value.integer.value;
11076
11077 if (val == spec->master_sw)
11078 return 0;
11079 spec->master_sw = val;
11080 alc262_hp_master_update(codec);
11081 return 1;
11082}
11083
Takashi Iwaib72519b2009-05-08 14:31:55 +020011084#define ALC262_HP_MASTER_SWITCH \
11085 { \
11086 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11087 .name = "Master Playback Switch", \
11088 .info = snd_ctl_boolean_mono_info, \
11089 .get = alc262_hp_master_sw_get, \
11090 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011091 }, \
11092 { \
11093 .iface = NID_MAPPING, \
11094 .name = "Master Playback Switch", \
11095 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020011096 }
11097
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011098
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011099static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011100 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011101 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11102 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11103 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011104 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11105 HDA_OUTPUT),
11106 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11107 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011108 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11109 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011110 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011111 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11112 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011113 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011114 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11115 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11116 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11117 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011118 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
11119 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
11120 { } /* end */
11121};
11122
Kailang Yangcd7509a2007-01-26 18:33:17 +010011123static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011124 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010011125 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11126 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11127 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11128 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011129 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11130 HDA_OUTPUT),
11131 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11132 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011133 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11134 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011135 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011136 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11137 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11138 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11139 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011140 { } /* end */
11141};
11142
11143static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11144 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11145 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011146 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011147 { } /* end */
11148};
11149
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011150/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011151static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011152{
11153 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011154
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011155 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011156 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011157}
11158
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011159static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011160 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11161 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011162 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11163 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11164 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11165 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11166 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11167 { } /* end */
11168};
11169
11170static struct hda_verb alc262_hp_t5735_verbs[] = {
11171 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11172 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11173
11174 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11175 { }
11176};
11177
Kailang Yang8c427222008-01-10 13:03:59 +010011178static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011179 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11180 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011181 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11182 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011183 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11184 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11185 { } /* end */
11186};
11187
11188static struct hda_verb alc262_hp_rp5700_verbs[] = {
11189 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11190 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11191 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11192 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11193 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11194 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11195 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11196 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11197 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11198 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11199 {}
11200};
11201
11202static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11203 .num_items = 1,
11204 .items = {
11205 { "Line", 0x1 },
11206 },
11207};
11208
Takashi Iwai42171c12009-05-08 14:11:43 +020011209/* bind hp and internal speaker mute (with plug check) as master switch */
11210static void alc262_hippo_master_update(struct hda_codec *codec)
11211{
11212 struct alc_spec *spec = codec->spec;
11213 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11214 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11215 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11216 unsigned int mute;
11217
11218 /* HP */
11219 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11220 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11221 HDA_AMP_MUTE, mute);
11222 /* mute internal speaker per jack sense */
11223 if (spec->jack_present)
11224 mute = HDA_AMP_MUTE;
11225 if (line_nid)
11226 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11227 HDA_AMP_MUTE, mute);
11228 if (speaker_nid && speaker_nid != line_nid)
11229 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11230 HDA_AMP_MUTE, mute);
11231}
11232
11233#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
11234
11235static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11236 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020011237{
11238 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020011239 struct alc_spec *spec = codec->spec;
11240 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011241
Takashi Iwai42171c12009-05-08 14:11:43 +020011242 if (val == spec->master_sw)
11243 return 0;
11244 spec->master_sw = val;
11245 alc262_hippo_master_update(codec);
11246 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011247}
Takashi Iwai5b319542007-07-26 11:49:22 +020011248
Takashi Iwai42171c12009-05-08 14:11:43 +020011249#define ALC262_HIPPO_MASTER_SWITCH \
11250 { \
11251 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11252 .name = "Master Playback Switch", \
11253 .info = snd_ctl_boolean_mono_info, \
11254 .get = alc262_hippo_master_sw_get, \
11255 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011256 }, \
11257 { \
11258 .iface = NID_MAPPING, \
11259 .name = "Master Playback Switch", \
11260 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11261 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011262 }
11263
11264static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11265 ALC262_HIPPO_MASTER_SWITCH,
11266 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11267 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11268 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11269 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11270 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11271 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11272 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11273 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11274 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11275 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11276 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11277 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11278 { } /* end */
11279};
11280
11281static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11282 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11283 ALC262_HIPPO_MASTER_SWITCH,
11284 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11285 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11286 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11287 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11288 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11289 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11290 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11291 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11292 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11293 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11294 { } /* end */
11295};
11296
11297/* mute/unmute internal speaker according to the hp jack and mute state */
11298static void alc262_hippo_automute(struct hda_codec *codec)
11299{
11300 struct alc_spec *spec = codec->spec;
11301 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020011302
Wu Fengguang864f92b2009-11-18 12:38:02 +080011303 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020011304 alc262_hippo_master_update(codec);
11305}
11306
11307static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11308{
11309 if ((res >> 26) != ALC880_HP_EVENT)
11310 return;
11311 alc262_hippo_automute(codec);
11312}
11313
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011314static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011315{
11316 struct alc_spec *spec = codec->spec;
11317
11318 spec->autocfg.hp_pins[0] = 0x15;
11319 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011320}
11321
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011322static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011323{
11324 struct alc_spec *spec = codec->spec;
11325
11326 spec->autocfg.hp_pins[0] = 0x1b;
11327 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011328}
11329
11330
Kailang Yang272a5272007-05-14 11:00:38 +020011331static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011332 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011333 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011334 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11335 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11336 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11337 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11338 { } /* end */
11339};
11340
Kailang Yang83c34212007-07-05 11:43:05 +020011341static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011342 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11343 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011344 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11345 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11346 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11347 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11348 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11349 { } /* end */
11350};
Kailang Yang272a5272007-05-14 11:00:38 +020011351
Tony Vroonba340e82009-02-02 19:01:30 +000011352static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11353 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11354 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11355 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11356 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11357 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11358 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11359 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11360 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11361 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11362 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11363 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11364 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11365 { } /* end */
11366};
11367
11368static struct hda_verb alc262_tyan_verbs[] = {
11369 /* Headphone automute */
11370 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11371 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11372 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11373
11374 /* P11 AUX_IN, white 4-pin connector */
11375 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11376 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11377 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11378 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11379
11380 {}
11381};
11382
11383/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011384static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011385{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011386 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011387
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011388 spec->autocfg.hp_pins[0] = 0x1b;
11389 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011390}
11391
Tony Vroonba340e82009-02-02 19:01:30 +000011392
Kailang Yangdf694da2005-12-05 19:42:22 +010011393#define alc262_capture_mixer alc882_capture_mixer
11394#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11395
11396/*
11397 * generic initialization of ADC, input mixers and output mixers
11398 */
11399static struct hda_verb alc262_init_verbs[] = {
11400 /*
11401 * Unmute ADC0-2 and set the default input to mic-in
11402 */
11403 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11404 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11405 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11406 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11407 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11408 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11409
Takashi Iwaicb53c622007-08-10 17:21:45 +020011410 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011411 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011412 * Note: PASD motherboards uses the Line In 2 as the input for
11413 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011414 */
11415 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011416 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11417 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11418 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11419 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11420 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011421
11422 /*
11423 * Set up output mixers (0x0c - 0x0e)
11424 */
11425 /* set vol=0 to output mixers */
11426 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11427 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11428 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11429 /* set up input amps for analog loopback */
11430 /* Amp Indices: DAC = 0, mixer = 1 */
11431 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11432 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11433 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11434 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11435 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11436 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11437
11438 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11439 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11440 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11441 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11442 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11443 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11444
11445 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11446 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11447 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11448 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11449 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011450
Kailang Yangdf694da2005-12-05 19:42:22 +010011451 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11452 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011453
Kailang Yangdf694da2005-12-05 19:42:22 +010011454 /* FIXME: use matrix-type input source selection */
11455 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11456 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11457 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11458 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11459 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11460 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11461 /* Input mixer2 */
11462 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11463 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11464 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11465 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11466 /* Input mixer3 */
11467 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11468 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11469 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011470 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011471
11472 { }
11473};
11474
Kailang Yang4e555fe2008-08-26 13:05:55 +020011475static struct hda_verb alc262_eapd_verbs[] = {
11476 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11477 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11478 { }
11479};
11480
Kailang Yangccc656c2006-10-17 12:32:26 +020011481static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11482 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11483 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11484 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11485
11486 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11487 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11488 {}
11489};
11490
Kailang Yang272a5272007-05-14 11:00:38 +020011491static struct hda_verb alc262_sony_unsol_verbs[] = {
11492 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11493 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11494 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11495
11496 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11497 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011498 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011499};
11500
Kailang Yang4e555fe2008-08-26 13:05:55 +020011501static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11502 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11503 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11504 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11505 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11506 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011507 { } /* end */
11508};
11509
11510static struct hda_verb alc262_toshiba_s06_verbs[] = {
11511 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11512 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11513 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11514 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11515 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11516 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11517 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11518 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11519 {}
11520};
11521
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011522static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011523{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011524 struct alc_spec *spec = codec->spec;
11525
11526 spec->autocfg.hp_pins[0] = 0x15;
11527 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011528 spec->ext_mic.pin = 0x18;
11529 spec->ext_mic.mux_idx = 0;
11530 spec->int_mic.pin = 0x12;
11531 spec->int_mic.mux_idx = 9;
11532 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011533}
11534
Takashi Iwai834be882006-03-01 14:16:17 +010011535/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011536 * nec model
11537 * 0x15 = headphone
11538 * 0x16 = internal speaker
11539 * 0x18 = external mic
11540 */
11541
11542static struct snd_kcontrol_new alc262_nec_mixer[] = {
11543 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11544 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11545
11546 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11547 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11548 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11549
11550 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11551 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11552 { } /* end */
11553};
11554
11555static struct hda_verb alc262_nec_verbs[] = {
11556 /* Unmute Speaker */
11557 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11558
11559 /* Headphone */
11560 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11561 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11562
11563 /* External mic to headphone */
11564 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11565 /* External mic to speaker */
11566 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11567 {}
11568};
11569
11570/*
Takashi Iwai834be882006-03-01 14:16:17 +010011571 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011572 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11573 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011574 */
11575
11576#define ALC_HP_EVENT 0x37
11577
11578static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11579 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11580 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011581 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11582 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011583 {}
11584};
11585
Jiang zhe0e31daf2008-03-20 12:12:39 +010011586static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11587 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11588 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11589 {}
11590};
11591
Daniel T Chene2595322009-12-19 18:19:02 -050011592static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11593 /* Front Mic pin: input vref at 50% */
11594 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11595 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11596 {}
11597};
11598
Takashi Iwai834be882006-03-01 14:16:17 +010011599static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011600 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011601 .items = {
11602 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011603 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011604 { "CD", 0x4 },
11605 },
11606};
11607
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011608static struct hda_input_mux alc262_HP_capture_source = {
11609 .num_items = 5,
11610 .items = {
11611 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011612 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011613 { "Line", 0x2 },
11614 { "CD", 0x4 },
11615 { "AUX IN", 0x6 },
11616 },
11617};
11618
zhejiangaccbe492007-08-31 12:36:05 +020011619static struct hda_input_mux alc262_HP_D7000_capture_source = {
11620 .num_items = 4,
11621 .items = {
11622 { "Mic", 0x0 },
11623 { "Front Mic", 0x2 },
11624 { "Line", 0x1 },
11625 { "CD", 0x4 },
11626 },
11627};
11628
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011629/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011630static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11631{
11632 struct alc_spec *spec = codec->spec;
11633 unsigned int mute;
11634
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011635 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011636 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11637 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011638 spec->sense_updated = 1;
11639 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011640 /* unmute internal speaker only if both HPs are unplugged and
11641 * master switch is on
11642 */
11643 if (spec->jack_present)
11644 mute = HDA_AMP_MUTE;
11645 else
Takashi Iwai834be882006-03-01 14:16:17 +010011646 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011647 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11648 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011649}
11650
11651/* unsolicited event for HP jack sensing */
11652static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11653 unsigned int res)
11654{
11655 if ((res >> 26) != ALC_HP_EVENT)
11656 return;
11657 alc262_fujitsu_automute(codec, 1);
11658}
11659
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011660static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11661{
11662 alc262_fujitsu_automute(codec, 1);
11663}
11664
Takashi Iwai834be882006-03-01 14:16:17 +010011665/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011666static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11667 .ops = &snd_hda_bind_vol,
11668 .values = {
11669 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11670 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11671 0
11672 },
11673};
Takashi Iwai834be882006-03-01 14:16:17 +010011674
Jiang zhe0e31daf2008-03-20 12:12:39 +010011675/* mute/unmute internal speaker according to the hp jack and mute state */
11676static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11677{
11678 struct alc_spec *spec = codec->spec;
11679 unsigned int mute;
11680
11681 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011682 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011683 spec->sense_updated = 1;
11684 }
11685 if (spec->jack_present) {
11686 /* mute internal speaker */
11687 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11688 HDA_AMP_MUTE, HDA_AMP_MUTE);
11689 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11690 HDA_AMP_MUTE, HDA_AMP_MUTE);
11691 } else {
11692 /* unmute internal speaker if necessary */
11693 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11694 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11695 HDA_AMP_MUTE, mute);
11696 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11697 HDA_AMP_MUTE, mute);
11698 }
11699}
11700
11701/* unsolicited event for HP jack sensing */
11702static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11703 unsigned int res)
11704{
11705 if ((res >> 26) != ALC_HP_EVENT)
11706 return;
11707 alc262_lenovo_3000_automute(codec, 1);
11708}
11709
Takashi Iwai8de56b72009-07-24 16:51:47 +020011710static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11711 int dir, int idx, long *valp)
11712{
11713 int i, change = 0;
11714
11715 for (i = 0; i < 2; i++, valp++)
11716 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11717 HDA_AMP_MUTE,
11718 *valp ? 0 : HDA_AMP_MUTE);
11719 return change;
11720}
11721
Takashi Iwai834be882006-03-01 14:16:17 +010011722/* bind hp and internal speaker mute (with plug check) */
11723static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11724 struct snd_ctl_elem_value *ucontrol)
11725{
11726 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11727 long *valp = ucontrol->value.integer.value;
11728 int change;
11729
Takashi Iwai8de56b72009-07-24 16:51:47 +020011730 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11731 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011732 if (change)
11733 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011734 return change;
11735}
11736
11737static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011738 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011739 {
11740 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11741 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011742 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011743 .info = snd_hda_mixer_amp_switch_info,
11744 .get = snd_hda_mixer_amp_switch_get,
11745 .put = alc262_fujitsu_master_sw_put,
11746 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11747 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011748 {
11749 .iface = NID_MAPPING,
11750 .name = "Master Playback Switch",
11751 .private_value = 0x1b,
11752 },
Takashi Iwai834be882006-03-01 14:16:17 +010011753 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11754 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11755 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11756 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11757 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011758 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11759 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11760 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011761 { } /* end */
11762};
11763
Jiang zhe0e31daf2008-03-20 12:12:39 +010011764/* bind hp and internal speaker mute (with plug check) */
11765static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11766 struct snd_ctl_elem_value *ucontrol)
11767{
11768 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11769 long *valp = ucontrol->value.integer.value;
11770 int change;
11771
Takashi Iwai8de56b72009-07-24 16:51:47 +020011772 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011773 if (change)
11774 alc262_lenovo_3000_automute(codec, 0);
11775 return change;
11776}
11777
11778static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11779 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11780 {
11781 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11782 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011783 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011784 .info = snd_hda_mixer_amp_switch_info,
11785 .get = snd_hda_mixer_amp_switch_get,
11786 .put = alc262_lenovo_3000_master_sw_put,
11787 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11788 },
11789 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11790 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11791 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11792 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11793 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11794 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11795 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11796 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11797 { } /* end */
11798};
11799
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011800static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11801 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011802 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011803 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11804 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11805 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11806 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11807 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11808 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11809 { } /* end */
11810};
11811
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011812/* additional init verbs for Benq laptops */
11813static struct hda_verb alc262_EAPD_verbs[] = {
11814 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11815 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11816 {}
11817};
11818
Kailang Yang83c34212007-07-05 11:43:05 +020011819static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11820 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11821 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11822
11823 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11824 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11825 {}
11826};
11827
Tobin Davisf651b502007-10-26 12:40:47 +020011828/* Samsung Q1 Ultra Vista model setup */
11829static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011830 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11831 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011832 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11833 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11834 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011835 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011836 { } /* end */
11837};
11838
11839static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011840 /* output mixer */
11841 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11842 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11843 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11844 /* speaker */
11845 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11846 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11847 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11848 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11849 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011850 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011851 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11852 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11853 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11854 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11855 /* internal mic */
11856 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11857 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11858 /* ADC, choose mic */
11859 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11860 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11861 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11862 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11863 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11864 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11865 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11866 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11867 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11868 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011869 {}
11870};
11871
Tobin Davisf651b502007-10-26 12:40:47 +020011872/* mute/unmute internal speaker according to the hp jack and mute state */
11873static void alc262_ultra_automute(struct hda_codec *codec)
11874{
11875 struct alc_spec *spec = codec->spec;
11876 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011877
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011878 mute = 0;
11879 /* auto-mute only when HP is used as HP */
11880 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011881 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011882 if (spec->jack_present)
11883 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011884 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011885 /* mute/unmute internal speaker */
11886 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11887 HDA_AMP_MUTE, mute);
11888 /* mute/unmute HP */
11889 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11890 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011891}
11892
11893/* unsolicited event for HP jack sensing */
11894static void alc262_ultra_unsol_event(struct hda_codec *codec,
11895 unsigned int res)
11896{
11897 if ((res >> 26) != ALC880_HP_EVENT)
11898 return;
11899 alc262_ultra_automute(codec);
11900}
11901
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011902static struct hda_input_mux alc262_ultra_capture_source = {
11903 .num_items = 2,
11904 .items = {
11905 { "Mic", 0x1 },
11906 { "Headphone", 0x7 },
11907 },
11908};
11909
11910static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11911 struct snd_ctl_elem_value *ucontrol)
11912{
11913 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11914 struct alc_spec *spec = codec->spec;
11915 int ret;
11916
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011917 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011918 if (!ret)
11919 return 0;
11920 /* reprogram the HP pin as mic or HP according to the input source */
11921 snd_hda_codec_write_cache(codec, 0x15, 0,
11922 AC_VERB_SET_PIN_WIDGET_CONTROL,
11923 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11924 alc262_ultra_automute(codec); /* mute/unmute HP */
11925 return ret;
11926}
11927
11928static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11929 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11930 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11931 {
11932 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11933 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011934 .info = alc_mux_enum_info,
11935 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011936 .put = alc262_ultra_mux_enum_put,
11937 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011938 {
11939 .iface = NID_MAPPING,
11940 .name = "Capture Source",
11941 .private_value = 0x15,
11942 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011943 { } /* end */
11944};
11945
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011946/* We use two mixers depending on the output pin; 0x16 is a mono output
11947 * and thus it's bound with a different mixer.
11948 * This function returns which mixer amp should be used.
11949 */
11950static int alc262_check_volbit(hda_nid_t nid)
11951{
11952 if (!nid)
11953 return 0;
11954 else if (nid == 0x16)
11955 return 2;
11956 else
11957 return 1;
11958}
11959
11960static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020011961 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011962{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011963 unsigned long val;
11964 int vbit;
11965
11966 vbit = alc262_check_volbit(nid);
11967 if (!vbit)
11968 return 0;
11969 if (*vbits & vbit) /* a volume control for this mixer already there */
11970 return 0;
11971 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011972 if (vbit == 2)
11973 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11974 else
11975 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020011976 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011977}
11978
11979static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020011980 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011981{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011982 unsigned long val;
11983
11984 if (!nid)
11985 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011986 if (nid == 0x16)
11987 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11988 else
11989 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020011990 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011991}
11992
Kailang Yangdf694da2005-12-05 19:42:22 +010011993/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011994static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11995 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011996{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011997 const char *pfx;
11998 int vbits;
Takashi Iwai033688a2010-09-08 15:47:09 +020011999 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010012000
12001 spec->multiout.num_dacs = 1; /* only use one dac */
12002 spec->multiout.dac_nids = spec->private_dac_nids;
12003 spec->multiout.dac_nids[0] = 2;
12004
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012005 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
12006 pfx = "Master";
12007 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12008 pfx = "Speaker";
Takashi Iwai033688a2010-09-08 15:47:09 +020012009 else if (cfg->line_out_type == AUTO_PIN_HP_OUT)
12010 pfx = "Headphone";
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012011 else
12012 pfx = "Front";
Takashi Iwai033688a2010-09-08 15:47:09 +020012013 for (i = 0; i < 2; i++) {
12014 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
12015 if (err < 0)
12016 return err;
12017 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12018 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
12019 "Speaker", i);
12020 if (err < 0)
12021 return err;
12022 }
12023 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12024 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
12025 "Headphone", i);
12026 if (err < 0)
12027 return err;
12028 }
12029 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012030
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012031 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
12032 alc262_check_volbit(cfg->speaker_pins[0]) |
12033 alc262_check_volbit(cfg->hp_pins[0]);
12034 if (vbits == 1 || vbits == 2)
12035 pfx = "Master"; /* only one mixer is used */
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012036 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020012037 for (i = 0; i < 2; i++) {
12038 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
12039 &vbits, i);
12040 if (err < 0)
12041 return err;
12042 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12043 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
12044 "Speaker", &vbits, i);
12045 if (err < 0)
12046 return err;
12047 }
12048 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12049 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
12050 "Headphone", &vbits, i);
12051 if (err < 0)
12052 return err;
12053 }
12054 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012055 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010012056}
12057
Takashi Iwai05f5f472009-08-25 13:10:18 +020012058#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010012059 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010012060
12061/*
12062 * generic initialization of ADC, input mixers and output mixers
12063 */
12064static struct hda_verb alc262_volume_init_verbs[] = {
12065 /*
12066 * Unmute ADC0-2 and set the default input to mic-in
12067 */
12068 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12069 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12070 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12071 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12072 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12073 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12074
Takashi Iwaicb53c622007-08-10 17:21:45 +020012075 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010012076 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012077 * Note: PASD motherboards uses the Line In 2 as the input for
12078 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010012079 */
12080 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012081 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12082 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12083 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12084 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12085 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012086
12087 /*
12088 * Set up output mixers (0x0c - 0x0f)
12089 */
12090 /* set vol=0 to output mixers */
12091 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12092 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12093 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020012094
Kailang Yangdf694da2005-12-05 19:42:22 +010012095 /* set up input amps for analog loopback */
12096 /* Amp Indices: DAC = 0, mixer = 1 */
12097 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12098 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12099 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12100 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12101 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12102 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12103
12104 /* FIXME: use matrix-type input source selection */
12105 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12106 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12107 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12108 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12109 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12110 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12111 /* Input mixer2 */
12112 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12113 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12114 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12115 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12116 /* Input mixer3 */
12117 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12118 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12119 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12120 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12121
12122 { }
12123};
12124
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012125static struct hda_verb alc262_HP_BPC_init_verbs[] = {
12126 /*
12127 * Unmute ADC0-2 and set the default input to mic-in
12128 */
12129 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12130 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12131 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12132 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12133 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12134 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12135
Takashi Iwaicb53c622007-08-10 17:21:45 +020012136 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012137 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012138 * Note: PASD motherboards uses the Line In 2 as the input for
12139 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012140 */
12141 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012142 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12143 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12144 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12145 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12146 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12147 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12148 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012149
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012150 /*
12151 * Set up output mixers (0x0c - 0x0e)
12152 */
12153 /* set vol=0 to output mixers */
12154 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12155 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12156 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12157
12158 /* set up input amps for analog loopback */
12159 /* Amp Indices: DAC = 0, mixer = 1 */
12160 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12161 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12162 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12163 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12164 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12165 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12166
Takashi Iwaice875f02008-01-28 18:17:43 +010012167 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012168 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12169 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12170
12171 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12172 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12173
12174 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12175 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12176
12177 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12178 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12179 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12180 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12181 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12182
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012183 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012184 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12185 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012186 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012187 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12188 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12189
12190
12191 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012192 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12193 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012194 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012195 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12196 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12197 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12198 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12199 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12200 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12201 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12202 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012203 /* Input mixer2 */
12204 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012205 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12206 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12207 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12208 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12209 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12210 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12211 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12212 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012213 /* Input mixer3 */
12214 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012215 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12216 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12217 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12218 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12219 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12220 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12221 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12222 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012223
Takashi Iwaice875f02008-01-28 18:17:43 +010012224 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12225
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012226 { }
12227};
12228
Kailang Yangcd7509a2007-01-26 18:33:17 +010012229static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12230 /*
12231 * Unmute ADC0-2 and set the default input to mic-in
12232 */
12233 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12234 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12235 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12236 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12237 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12238 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12239
Takashi Iwaicb53c622007-08-10 17:21:45 +020012240 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012241 * mixer widget
12242 * Note: PASD motherboards uses the Line In 2 as the input for front
12243 * panel mic (mic 2)
12244 */
12245 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012246 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12247 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12248 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12249 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12250 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12251 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12252 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12253 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012254 /*
12255 * Set up output mixers (0x0c - 0x0e)
12256 */
12257 /* set vol=0 to output mixers */
12258 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12259 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12260 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12261
12262 /* set up input amps for analog loopback */
12263 /* Amp Indices: DAC = 0, mixer = 1 */
12264 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12265 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12266 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12267 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12268 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12269 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12270
12271
12272 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12273 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12274 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12275 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12276 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12277 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12278 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12279
12280 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12281 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12282
12283 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12284 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12285
12286 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12287 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12288 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12289 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12290 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12291 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12292
12293 /* FIXME: use matrix-type input source selection */
12294 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12295 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12296 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12297 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12298 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12299 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12300 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12301 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12302 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12303 /* Input mixer2 */
12304 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12305 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12306 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12307 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12308 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12309 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12310 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12311 /* Input mixer3 */
12312 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12313 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12315 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12316 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12317 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12318 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12319
Takashi Iwaice875f02008-01-28 18:17:43 +010012320 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12321
Kailang Yangcd7509a2007-01-26 18:33:17 +010012322 { }
12323};
12324
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012325static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12326
12327 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12328 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12329 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12330
12331 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12332 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12333 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12334 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12335
12336 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12337 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12338 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12339 {}
12340};
12341
Takashi Iwai18675e42010-09-08 15:55:44 +020012342/*
12343 * Pin config fixes
12344 */
12345enum {
12346 PINFIX_FSC_H270,
12347};
12348
12349static const struct alc_fixup alc262_fixups[] = {
12350 [PINFIX_FSC_H270] = {
12351 .pins = (const struct alc_pincfg[]) {
12352 { 0x14, 0x99130110 }, /* speaker */
12353 { 0x15, 0x0221142f }, /* front HP */
12354 { 0x1b, 0x0121141f }, /* rear HP */
12355 { }
12356 }
12357 },
12358 [PINFIX_PB_M5210] = {
12359 .verbs = (const struct hda_verb[]) {
12360 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
12361 {}
12362 }
12363 },
12364};
12365
12366static struct snd_pci_quirk alc262_fixup_tbl[] = {
12367 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12368 {}
12369};
12370
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012371
Takashi Iwaicb53c622007-08-10 17:21:45 +020012372#ifdef CONFIG_SND_HDA_POWER_SAVE
12373#define alc262_loopbacks alc880_loopbacks
12374#endif
12375
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012376/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012377#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12378#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12379#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12380#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12381
12382/*
12383 * BIOS auto configuration
12384 */
12385static int alc262_parse_auto_config(struct hda_codec *codec)
12386{
12387 struct alc_spec *spec = codec->spec;
12388 int err;
12389 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12390
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012391 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12392 alc262_ignore);
12393 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012394 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012395 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012396 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012397 spec->multiout.max_channels = 2;
12398 spec->no_analog = 1;
12399 goto dig_only;
12400 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012401 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012402 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012403 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12404 if (err < 0)
12405 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012406 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012407 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012408 return err;
12409
12410 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12411
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012412 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012413 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012414
Takashi Iwai603c4012008-07-30 15:01:44 +020012415 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012416 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012417
Takashi Iwaid88897e2008-10-31 15:01:37 +010012418 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012419 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012420 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012421
Takashi Iwai776e1842007-08-29 15:07:11 +020012422 err = alc_auto_add_mic_boost(codec);
12423 if (err < 0)
12424 return err;
12425
Kailang Yang6227cdc2010-02-25 08:36:52 +010012426 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012427
Kailang Yangdf694da2005-12-05 19:42:22 +010012428 return 1;
12429}
12430
12431#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12432#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12433#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012434#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012435
12436
12437/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012438static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012439{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012440 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012441 alc262_auto_init_multi_out(codec);
12442 alc262_auto_init_hp_out(codec);
12443 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012444 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012445 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012446 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012447 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012448}
12449
12450/*
12451 * configuration and preset
12452 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012453static const char *alc262_models[ALC262_MODEL_LAST] = {
12454 [ALC262_BASIC] = "basic",
12455 [ALC262_HIPPO] = "hippo",
12456 [ALC262_HIPPO_1] = "hippo_1",
12457 [ALC262_FUJITSU] = "fujitsu",
12458 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012459 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012460 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012461 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012462 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012463 [ALC262_BENQ_T31] = "benq-t31",
12464 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012465 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012466 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012467 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012468 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012469 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012470 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012471 [ALC262_AUTO] = "auto",
12472};
12473
12474static struct snd_pci_quirk alc262_cfg_tbl[] = {
12475 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012476 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012477 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12478 ALC262_HP_BPC),
12479 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12480 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012481 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12482 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012483 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012484 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012485 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012486 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012487 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012488 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012489 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012490 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012491 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12492 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12493 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012494 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12495 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012496 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012497 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012498 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012499 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012500 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012501 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012502 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012503 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012504#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012505 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12506 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012507#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012508 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012509 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012510 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012511 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012512 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012513 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012514 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12515 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012516 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012517 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012518 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012519 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012520 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012521 {}
12522};
12523
12524static struct alc_config_preset alc262_presets[] = {
12525 [ALC262_BASIC] = {
12526 .mixers = { alc262_base_mixer },
12527 .init_verbs = { alc262_init_verbs },
12528 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12529 .dac_nids = alc262_dac_nids,
12530 .hp_nid = 0x03,
12531 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12532 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012533 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012534 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012535 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012536 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012537 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012538 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12539 .dac_nids = alc262_dac_nids,
12540 .hp_nid = 0x03,
12541 .dig_out_nid = ALC262_DIGOUT_NID,
12542 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12543 .channel_mode = alc262_modes,
12544 .input_mux = &alc262_capture_source,
12545 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012546 .setup = alc262_hippo_setup,
12547 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012548 },
12549 [ALC262_HIPPO_1] = {
12550 .mixers = { alc262_hippo1_mixer },
12551 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12552 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12553 .dac_nids = alc262_dac_nids,
12554 .hp_nid = 0x02,
12555 .dig_out_nid = ALC262_DIGOUT_NID,
12556 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12557 .channel_mode = alc262_modes,
12558 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012559 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012560 .setup = alc262_hippo1_setup,
12561 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012562 },
Takashi Iwai834be882006-03-01 14:16:17 +010012563 [ALC262_FUJITSU] = {
12564 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012565 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12566 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012567 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12568 .dac_nids = alc262_dac_nids,
12569 .hp_nid = 0x03,
12570 .dig_out_nid = ALC262_DIGOUT_NID,
12571 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12572 .channel_mode = alc262_modes,
12573 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012574 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012575 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012576 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012577 [ALC262_HP_BPC] = {
12578 .mixers = { alc262_HP_BPC_mixer },
12579 .init_verbs = { alc262_HP_BPC_init_verbs },
12580 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12581 .dac_nids = alc262_dac_nids,
12582 .hp_nid = 0x03,
12583 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12584 .channel_mode = alc262_modes,
12585 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012586 .unsol_event = alc262_hp_bpc_unsol_event,
12587 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012588 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012589 [ALC262_HP_BPC_D7000_WF] = {
12590 .mixers = { alc262_HP_BPC_WildWest_mixer },
12591 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12592 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12593 .dac_nids = alc262_dac_nids,
12594 .hp_nid = 0x03,
12595 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12596 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012597 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012598 .unsol_event = alc262_hp_wildwest_unsol_event,
12599 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012600 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012601 [ALC262_HP_BPC_D7000_WL] = {
12602 .mixers = { alc262_HP_BPC_WildWest_mixer,
12603 alc262_HP_BPC_WildWest_option_mixer },
12604 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12605 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12606 .dac_nids = alc262_dac_nids,
12607 .hp_nid = 0x03,
12608 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12609 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012610 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012611 .unsol_event = alc262_hp_wildwest_unsol_event,
12612 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012613 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012614 [ALC262_HP_TC_T5735] = {
12615 .mixers = { alc262_hp_t5735_mixer },
12616 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12617 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12618 .dac_nids = alc262_dac_nids,
12619 .hp_nid = 0x03,
12620 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12621 .channel_mode = alc262_modes,
12622 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012623 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012624 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012625 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012626 },
12627 [ALC262_HP_RP5700] = {
12628 .mixers = { alc262_hp_rp5700_mixer },
12629 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12630 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12631 .dac_nids = alc262_dac_nids,
12632 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12633 .channel_mode = alc262_modes,
12634 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012635 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012636 [ALC262_BENQ_ED8] = {
12637 .mixers = { alc262_base_mixer },
12638 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12639 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12640 .dac_nids = alc262_dac_nids,
12641 .hp_nid = 0x03,
12642 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12643 .channel_mode = alc262_modes,
12644 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012645 },
Kailang Yang272a5272007-05-14 11:00:38 +020012646 [ALC262_SONY_ASSAMD] = {
12647 .mixers = { alc262_sony_mixer },
12648 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12649 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12650 .dac_nids = alc262_dac_nids,
12651 .hp_nid = 0x02,
12652 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12653 .channel_mode = alc262_modes,
12654 .input_mux = &alc262_capture_source,
12655 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012656 .setup = alc262_hippo_setup,
12657 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012658 },
12659 [ALC262_BENQ_T31] = {
12660 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012661 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12662 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012663 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12664 .dac_nids = alc262_dac_nids,
12665 .hp_nid = 0x03,
12666 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12667 .channel_mode = alc262_modes,
12668 .input_mux = &alc262_capture_source,
12669 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012670 .setup = alc262_hippo_setup,
12671 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012672 },
Tobin Davisf651b502007-10-26 12:40:47 +020012673 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012674 .mixers = { alc262_ultra_mixer },
12675 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012676 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012677 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12678 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012679 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12680 .channel_mode = alc262_modes,
12681 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012682 .adc_nids = alc262_adc_nids, /* ADC0 */
12683 .capsrc_nids = alc262_capsrc_nids,
12684 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012685 .unsol_event = alc262_ultra_unsol_event,
12686 .init_hook = alc262_ultra_automute,
12687 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012688 [ALC262_LENOVO_3000] = {
12689 .mixers = { alc262_lenovo_3000_mixer },
12690 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012691 alc262_lenovo_3000_unsol_verbs,
12692 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012693 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12694 .dac_nids = alc262_dac_nids,
12695 .hp_nid = 0x03,
12696 .dig_out_nid = ALC262_DIGOUT_NID,
12697 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12698 .channel_mode = alc262_modes,
12699 .input_mux = &alc262_fujitsu_capture_source,
12700 .unsol_event = alc262_lenovo_3000_unsol_event,
12701 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012702 [ALC262_NEC] = {
12703 .mixers = { alc262_nec_mixer },
12704 .init_verbs = { alc262_nec_verbs },
12705 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12706 .dac_nids = alc262_dac_nids,
12707 .hp_nid = 0x03,
12708 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12709 .channel_mode = alc262_modes,
12710 .input_mux = &alc262_capture_source,
12711 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012712 [ALC262_TOSHIBA_S06] = {
12713 .mixers = { alc262_toshiba_s06_mixer },
12714 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12715 alc262_eapd_verbs },
12716 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12717 .capsrc_nids = alc262_dmic_capsrc_nids,
12718 .dac_nids = alc262_dac_nids,
12719 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012720 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012721 .dig_out_nid = ALC262_DIGOUT_NID,
12722 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12723 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012724 .unsol_event = alc_sku_unsol_event,
12725 .setup = alc262_toshiba_s06_setup,
12726 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012727 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012728 [ALC262_TOSHIBA_RX1] = {
12729 .mixers = { alc262_toshiba_rx1_mixer },
12730 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12731 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12732 .dac_nids = alc262_dac_nids,
12733 .hp_nid = 0x03,
12734 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12735 .channel_mode = alc262_modes,
12736 .input_mux = &alc262_capture_source,
12737 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012738 .setup = alc262_hippo_setup,
12739 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012740 },
Tony Vroonba340e82009-02-02 19:01:30 +000012741 [ALC262_TYAN] = {
12742 .mixers = { alc262_tyan_mixer },
12743 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12744 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12745 .dac_nids = alc262_dac_nids,
12746 .hp_nid = 0x02,
12747 .dig_out_nid = ALC262_DIGOUT_NID,
12748 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12749 .channel_mode = alc262_modes,
12750 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012751 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012752 .setup = alc262_tyan_setup,
12753 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012754 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012755};
12756
12757static int patch_alc262(struct hda_codec *codec)
12758{
12759 struct alc_spec *spec;
12760 int board_config;
12761 int err;
12762
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012763 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012764 if (spec == NULL)
12765 return -ENOMEM;
12766
12767 codec->spec = spec;
12768#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012769 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12770 * under-run
12771 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012772 {
12773 int tmp;
12774 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12775 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12776 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12777 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12778 }
12779#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012780 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012781
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012782 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12783
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012784 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12785 alc262_models,
12786 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012787
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012788 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012789 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12790 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012791 board_config = ALC262_AUTO;
12792 }
12793
Takashi Iwai18675e42010-09-08 15:55:44 +020012794 if (board_config == ALC262_AUTO)
12795 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 1);
12796
Kailang Yangdf694da2005-12-05 19:42:22 +010012797 if (board_config == ALC262_AUTO) {
12798 /* automatic parse from the BIOS config */
12799 err = alc262_parse_auto_config(codec);
12800 if (err < 0) {
12801 alc_free(codec);
12802 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012803 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012804 printk(KERN_INFO
12805 "hda_codec: Cannot set up configuration "
12806 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012807 board_config = ALC262_BASIC;
12808 }
12809 }
12810
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012811 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012812 err = snd_hda_attach_beep_device(codec, 0x1);
12813 if (err < 0) {
12814 alc_free(codec);
12815 return err;
12816 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012817 }
12818
Kailang Yangdf694da2005-12-05 19:42:22 +010012819 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012820 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012821
Kailang Yangdf694da2005-12-05 19:42:22 +010012822 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12823 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012824
Kailang Yangdf694da2005-12-05 19:42:22 +010012825 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12826 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12827
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012828 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012829 int i;
12830 /* check whether the digital-mic has to be supported */
12831 for (i = 0; i < spec->input_mux->num_items; i++) {
12832 if (spec->input_mux->items[i].index >= 9)
12833 break;
12834 }
12835 if (i < spec->input_mux->num_items) {
12836 /* use only ADC0 */
12837 spec->adc_nids = alc262_dmic_adc_nids;
12838 spec->num_adc_nids = 1;
12839 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012840 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012841 /* all analog inputs */
12842 /* check whether NID 0x07 is valid */
12843 unsigned int wcap = get_wcaps(codec, 0x07);
12844
12845 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012846 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012847 if (wcap != AC_WID_AUD_IN) {
12848 spec->adc_nids = alc262_adc_nids_alt;
12849 spec->num_adc_nids =
12850 ARRAY_SIZE(alc262_adc_nids_alt);
12851 spec->capsrc_nids = alc262_capsrc_nids_alt;
12852 } else {
12853 spec->adc_nids = alc262_adc_nids;
12854 spec->num_adc_nids =
12855 ARRAY_SIZE(alc262_adc_nids);
12856 spec->capsrc_nids = alc262_capsrc_nids;
12857 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012858 }
12859 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012860 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012861 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012862 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010012863 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012864
Takashi Iwai18675e42010-09-08 15:55:44 +020012865 if (board_config == ALC262_AUTO)
12866 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 0);
12867
Takashi Iwai2134ea42008-01-10 16:53:55 +010012868 spec->vmaster_nid = 0x0c;
12869
Kailang Yangdf694da2005-12-05 19:42:22 +010012870 codec->patch_ops = alc_patch_ops;
12871 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012872 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012873#ifdef CONFIG_SND_HDA_POWER_SAVE
12874 if (!spec->loopback.amplist)
12875 spec->loopback.amplist = alc262_loopbacks;
12876#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012877
Kailang Yangdf694da2005-12-05 19:42:22 +010012878 return 0;
12879}
12880
Kailang Yangdf694da2005-12-05 19:42:22 +010012881/*
Kailang Yanga361d842007-06-05 12:30:55 +020012882 * ALC268 channel source setting (2 channel)
12883 */
12884#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12885#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012886
Kailang Yanga361d842007-06-05 12:30:55 +020012887static hda_nid_t alc268_dac_nids[2] = {
12888 /* front, hp */
12889 0x02, 0x03
12890};
12891
12892static hda_nid_t alc268_adc_nids[2] = {
12893 /* ADC0-1 */
12894 0x08, 0x07
12895};
12896
12897static hda_nid_t alc268_adc_nids_alt[1] = {
12898 /* ADC0 */
12899 0x08
12900};
12901
Takashi Iwaie1406342008-02-11 18:32:32 +010012902static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12903
Kailang Yanga361d842007-06-05 12:30:55 +020012904static struct snd_kcontrol_new alc268_base_mixer[] = {
12905 /* output mixer control */
12906 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12907 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12908 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12909 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012910 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12911 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12912 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012913 { }
12914};
12915
Takashi Iwai42171c12009-05-08 14:11:43 +020012916static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12917 /* output mixer control */
12918 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12919 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12920 ALC262_HIPPO_MASTER_SWITCH,
12921 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12922 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12923 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12924 { }
12925};
12926
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012927/* bind Beep switches of both NID 0x0f and 0x10 */
12928static struct hda_bind_ctls alc268_bind_beep_sw = {
12929 .ops = &snd_hda_bind_sw,
12930 .values = {
12931 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12932 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12933 0
12934 },
12935};
12936
12937static struct snd_kcontrol_new alc268_beep_mixer[] = {
12938 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12939 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12940 { }
12941};
12942
Kailang Yangd1a991a2007-08-15 16:21:59 +020012943static struct hda_verb alc268_eapd_verbs[] = {
12944 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12945 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12946 { }
12947};
12948
Takashi Iwaid2738092007-08-16 14:59:45 +020012949/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012950static struct hda_verb alc268_toshiba_verbs[] = {
12951 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12952 { } /* end */
12953};
12954
12955/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012956/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012957static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12958 .ops = &snd_hda_bind_vol,
12959 .values = {
12960 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12961 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12962 0
12963 },
12964};
12965
Takashi Iwai889c4392007-08-23 18:56:52 +020012966/* mute/unmute internal speaker according to the hp jack and mute state */
12967static void alc268_acer_automute(struct hda_codec *codec, int force)
12968{
12969 struct alc_spec *spec = codec->spec;
12970 unsigned int mute;
12971
12972 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012973 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012974 spec->sense_updated = 1;
12975 }
12976 if (spec->jack_present)
12977 mute = HDA_AMP_MUTE; /* mute internal speaker */
12978 else /* unmute internal speaker if necessary */
12979 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12980 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12981 HDA_AMP_MUTE, mute);
12982}
12983
12984
12985/* bind hp and internal speaker mute (with plug check) */
12986static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12987 struct snd_ctl_elem_value *ucontrol)
12988{
12989 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12990 long *valp = ucontrol->value.integer.value;
12991 int change;
12992
Takashi Iwai8de56b72009-07-24 16:51:47 +020012993 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012994 if (change)
12995 alc268_acer_automute(codec, 0);
12996 return change;
12997}
Takashi Iwaid2738092007-08-16 14:59:45 +020012998
Kailang Yang8ef355d2008-08-26 13:10:22 +020012999static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
13000 /* output mixer control */
13001 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13002 {
13003 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13004 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013005 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013006 .info = snd_hda_mixer_amp_switch_info,
13007 .get = snd_hda_mixer_amp_switch_get,
13008 .put = alc268_acer_master_sw_put,
13009 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13010 },
13011 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
13012 { }
13013};
13014
Takashi Iwaid2738092007-08-16 14:59:45 +020013015static struct snd_kcontrol_new alc268_acer_mixer[] = {
13016 /* output mixer control */
13017 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13018 {
13019 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13020 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013021 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020013022 .info = snd_hda_mixer_amp_switch_info,
13023 .get = snd_hda_mixer_amp_switch_get,
13024 .put = alc268_acer_master_sw_put,
13025 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13026 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020013027 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13028 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13029 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020013030 { }
13031};
13032
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013033static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
13034 /* output mixer control */
13035 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13036 {
13037 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13038 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013039 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013040 .info = snd_hda_mixer_amp_switch_info,
13041 .get = snd_hda_mixer_amp_switch_get,
13042 .put = alc268_acer_master_sw_put,
13043 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13044 },
13045 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13046 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
13047 { }
13048};
13049
Kailang Yang8ef355d2008-08-26 13:10:22 +020013050static struct hda_verb alc268_acer_aspire_one_verbs[] = {
13051 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13052 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13053 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13054 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13055 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
13056 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
13057 { }
13058};
13059
Takashi Iwaid2738092007-08-16 14:59:45 +020013060static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013061 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
13062 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020013063 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13064 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013065 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13066 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020013067 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13068 { }
13069};
13070
13071/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020013072#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013073#define alc268_toshiba_setup alc262_hippo_setup
13074#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020013075
13076static void alc268_acer_unsol_event(struct hda_codec *codec,
13077 unsigned int res)
13078{
Takashi Iwai889c4392007-08-23 18:56:52 +020013079 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020013080 return;
13081 alc268_acer_automute(codec, 1);
13082}
13083
Takashi Iwai889c4392007-08-23 18:56:52 +020013084static void alc268_acer_init_hook(struct hda_codec *codec)
13085{
13086 alc268_acer_automute(codec, 1);
13087}
13088
Kailang Yang8ef355d2008-08-26 13:10:22 +020013089/* toggle speaker-output according to the hp-jack state */
13090static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
13091{
13092 unsigned int present;
13093 unsigned char bits;
13094
Wu Fengguang864f92b2009-11-18 12:38:02 +080013095 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013096 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013097 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013098 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013099 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013100 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013101}
13102
Kailang Yang8ef355d2008-08-26 13:10:22 +020013103static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
13104 unsigned int res)
13105{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013106 switch (res >> 26) {
13107 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020013108 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013109 break;
13110 case ALC880_MIC_EVENT:
13111 alc_mic_automute(codec);
13112 break;
13113 }
13114}
13115
13116static void alc268_acer_lc_setup(struct hda_codec *codec)
13117{
13118 struct alc_spec *spec = codec->spec;
13119 spec->ext_mic.pin = 0x18;
13120 spec->ext_mic.mux_idx = 0;
13121 spec->int_mic.pin = 0x12;
13122 spec->int_mic.mux_idx = 6;
13123 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013124}
13125
13126static void alc268_acer_lc_init_hook(struct hda_codec *codec)
13127{
13128 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013129 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013130}
13131
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013132static struct snd_kcontrol_new alc268_dell_mixer[] = {
13133 /* output mixer control */
13134 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13135 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13136 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13137 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13138 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13139 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13140 { }
13141};
13142
13143static struct hda_verb alc268_dell_verbs[] = {
13144 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13145 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13146 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013147 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013148 { }
13149};
13150
13151/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013152static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013153{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013154 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013155
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013156 spec->autocfg.hp_pins[0] = 0x15;
13157 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013158 spec->ext_mic.pin = 0x18;
13159 spec->ext_mic.mux_idx = 0;
13160 spec->int_mic.pin = 0x19;
13161 spec->int_mic.mux_idx = 1;
13162 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013163}
13164
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013165static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
13166 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13167 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13168 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13169 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13170 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13171 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
13172 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
13173 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
13174 { }
13175};
13176
13177static struct hda_verb alc267_quanta_il1_verbs[] = {
13178 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13179 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13180 { }
13181};
13182
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013183static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013184{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013185 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013186 spec->autocfg.hp_pins[0] = 0x15;
13187 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013188 spec->ext_mic.pin = 0x18;
13189 spec->ext_mic.mux_idx = 0;
13190 spec->int_mic.pin = 0x19;
13191 spec->int_mic.mux_idx = 1;
13192 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013193}
13194
Kailang Yanga361d842007-06-05 12:30:55 +020013195/*
13196 * generic initialization of ADC, input mixers and output mixers
13197 */
13198static struct hda_verb alc268_base_init_verbs[] = {
13199 /* Unmute DAC0-1 and set vol = 0 */
13200 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013201 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013202
13203 /*
13204 * Set up output mixers (0x0c - 0x0e)
13205 */
13206 /* set vol=0 to output mixers */
13207 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013208 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13209
13210 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13211 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13212
13213 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13214 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13215 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13216 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13217 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13218 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13219 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13220 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13221
13222 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13223 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13224 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13225 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013226 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013227
13228 /* set PCBEEP vol = 0, mute connections */
13229 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13230 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13231 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013232
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013233 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013234
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013235 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13236 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13237 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13238 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013239
Kailang Yanga361d842007-06-05 12:30:55 +020013240 { }
13241};
13242
13243/*
13244 * generic initialization of ADC, input mixers and output mixers
13245 */
13246static struct hda_verb alc268_volume_init_verbs[] = {
13247 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013248 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13249 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013250
13251 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13252 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13253 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13254 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13255 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13256
Kailang Yanga361d842007-06-05 12:30:55 +020013257 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013258 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13259 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13260
13261 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013262 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013263
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013264 /* set PCBEEP vol = 0, mute connections */
13265 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13266 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13267 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013268
13269 { }
13270};
13271
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013272static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13273 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13274 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13275 { } /* end */
13276};
13277
Kailang Yanga361d842007-06-05 12:30:55 +020013278static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13279 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13280 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013281 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013282 { } /* end */
13283};
13284
13285static struct snd_kcontrol_new alc268_capture_mixer[] = {
13286 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13287 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13288 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13289 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013290 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013291 { } /* end */
13292};
13293
13294static struct hda_input_mux alc268_capture_source = {
13295 .num_items = 4,
13296 .items = {
13297 { "Mic", 0x0 },
13298 { "Front Mic", 0x1 },
13299 { "Line", 0x2 },
13300 { "CD", 0x3 },
13301 },
13302};
13303
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013304static struct hda_input_mux alc268_acer_capture_source = {
13305 .num_items = 3,
13306 .items = {
13307 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013308 { "Internal Mic", 0x1 },
13309 { "Line", 0x2 },
13310 },
13311};
13312
13313static struct hda_input_mux alc268_acer_dmic_capture_source = {
13314 .num_items = 3,
13315 .items = {
13316 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013317 { "Internal Mic", 0x6 },
13318 { "Line", 0x2 },
13319 },
13320};
13321
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013322#ifdef CONFIG_SND_DEBUG
13323static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013324 /* Volume widgets */
13325 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13326 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13327 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13328 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13329 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13330 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13331 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13332 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13333 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13334 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13335 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13336 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13337 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013338 /* The below appears problematic on some hardwares */
13339 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013340 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13341 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13342 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13343 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13344
13345 /* Modes for retasking pin widgets */
13346 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13347 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13348 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13349 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13350
13351 /* Controls for GPIO pins, assuming they are configured as outputs */
13352 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13353 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13354 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13355 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13356
13357 /* Switches to allow the digital SPDIF output pin to be enabled.
13358 * The ALC268 does not have an SPDIF input.
13359 */
13360 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13361
13362 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13363 * this output to turn on an external amplifier.
13364 */
13365 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13366 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13367
13368 { } /* end */
13369};
13370#endif
13371
Kailang Yanga361d842007-06-05 12:30:55 +020013372/* create input playback/capture controls for the given pin */
13373static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13374 const char *ctlname, int idx)
13375{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013376 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013377 int err;
13378
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013379 switch (nid) {
13380 case 0x14:
13381 case 0x16:
13382 dac = 0x02;
13383 break;
13384 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013385 case 0x1a: /* ALC259/269 only */
13386 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013387 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013388 dac = 0x03;
13389 break;
13390 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013391 snd_printd(KERN_WARNING "hda_codec: "
13392 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013393 return 0;
13394 }
13395 if (spec->multiout.dac_nids[0] != dac &&
13396 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013397 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013398 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013399 HDA_OUTPUT));
13400 if (err < 0)
13401 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013402 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13403 }
13404
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013405 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013406 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013407 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013408 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013409 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013410 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013411 if (err < 0)
13412 return err;
13413 return 0;
13414}
13415
13416/* add playback controls from the parsed DAC table */
13417static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13418 const struct auto_pin_cfg *cfg)
13419{
13420 hda_nid_t nid;
13421 int err;
13422
Kailang Yanga361d842007-06-05 12:30:55 +020013423 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013424
13425 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013426 if (nid) {
13427 const char *name;
13428 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13429 name = "Speaker";
13430 else
13431 name = "Front";
13432 err = alc268_new_analog_output(spec, nid, name, 0);
13433 if (err < 0)
13434 return err;
13435 }
Kailang Yanga361d842007-06-05 12:30:55 +020013436
13437 nid = cfg->speaker_pins[0];
13438 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013439 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013440 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13441 if (err < 0)
13442 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013443 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013444 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13445 if (err < 0)
13446 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013447 }
13448 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013449 if (nid) {
13450 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13451 if (err < 0)
13452 return err;
13453 }
Kailang Yanga361d842007-06-05 12:30:55 +020013454
13455 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13456 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013457 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013458 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013459 if (err < 0)
13460 return err;
13461 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013462 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013463}
13464
13465/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013466static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013467 const struct auto_pin_cfg *cfg)
13468{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013469 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013470}
13471
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013472static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13473 hda_nid_t nid, int pin_type)
13474{
13475 int idx;
13476
13477 alc_set_pin_output(codec, nid, pin_type);
13478 if (nid == 0x14 || nid == 0x16)
13479 idx = 0;
13480 else
13481 idx = 1;
13482 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13483}
13484
13485static void alc268_auto_init_multi_out(struct hda_codec *codec)
13486{
13487 struct alc_spec *spec = codec->spec;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013488 int i;
13489
13490 for (i = 0; i < spec->autocfg.line_outs; i++) {
13491 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013492 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13493 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13494 }
13495}
13496
13497static void alc268_auto_init_hp_out(struct hda_codec *codec)
13498{
13499 struct alc_spec *spec = codec->spec;
13500 hda_nid_t pin;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013501 int i;
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013502
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013503 for (i = 0; i < spec->autocfg.hp_outs; i++) {
13504 pin = spec->autocfg.hp_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013505 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013506 }
13507 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
13508 pin = spec->autocfg.speaker_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013509 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013510 }
13511 if (spec->autocfg.mono_out_pin)
13512 snd_hda_codec_write(codec, spec->autocfg.mono_out_pin, 0,
13513 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013514}
13515
Kailang Yanga361d842007-06-05 12:30:55 +020013516static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13517{
13518 struct alc_spec *spec = codec->spec;
13519 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13520 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13521 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13522 unsigned int dac_vol1, dac_vol2;
13523
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013524 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013525 snd_hda_codec_write(codec, speaker_nid, 0,
13526 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013527 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013528 snd_hda_codec_write(codec, 0x0f, 0,
13529 AC_VERB_SET_AMP_GAIN_MUTE,
13530 AMP_IN_UNMUTE(1));
13531 snd_hda_codec_write(codec, 0x10, 0,
13532 AC_VERB_SET_AMP_GAIN_MUTE,
13533 AMP_IN_UNMUTE(1));
13534 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013535 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013536 snd_hda_codec_write(codec, 0x0f, 0,
13537 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13538 snd_hda_codec_write(codec, 0x10, 0,
13539 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13540 }
13541
13542 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013543 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013544 dac_vol2 = AMP_OUT_ZERO;
13545 else if (line_nid == 0x15)
13546 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013547 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013548 dac_vol2 = AMP_OUT_ZERO;
13549 else if (hp_nid == 0x15)
13550 dac_vol1 = AMP_OUT_ZERO;
13551 if (line_nid != 0x16 || hp_nid != 0x16 ||
13552 spec->autocfg.line_out_pins[1] != 0x16 ||
13553 spec->autocfg.line_out_pins[2] != 0x16)
13554 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13555
13556 snd_hda_codec_write(codec, 0x02, 0,
13557 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13558 snd_hda_codec_write(codec, 0x03, 0,
13559 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13560}
13561
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013562/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013563#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13564#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013565#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013566#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13567
13568/*
13569 * BIOS auto configuration
13570 */
13571static int alc268_parse_auto_config(struct hda_codec *codec)
13572{
13573 struct alc_spec *spec = codec->spec;
13574 int err;
13575 static hda_nid_t alc268_ignore[] = { 0 };
13576
13577 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13578 alc268_ignore);
13579 if (err < 0)
13580 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013581 if (!spec->autocfg.line_outs) {
13582 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13583 spec->multiout.max_channels = 2;
13584 spec->no_analog = 1;
13585 goto dig_only;
13586 }
Kailang Yanga361d842007-06-05 12:30:55 +020013587 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013588 }
Kailang Yanga361d842007-06-05 12:30:55 +020013589 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13590 if (err < 0)
13591 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013592 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013593 if (err < 0)
13594 return err;
13595
13596 spec->multiout.max_channels = 2;
13597
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013598 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013599 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013600 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013601 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013602 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013603
Takashi Iwai892981f2009-03-02 08:04:35 +010013604 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013605 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013606
Takashi Iwaid88897e2008-10-31 15:01:37 +010013607 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013608 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013609 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013610
Takashi Iwai776e1842007-08-29 15:07:11 +020013611 err = alc_auto_add_mic_boost(codec);
13612 if (err < 0)
13613 return err;
13614
Kailang Yang6227cdc2010-02-25 08:36:52 +010013615 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013616
Kailang Yanga361d842007-06-05 12:30:55 +020013617 return 1;
13618}
13619
Kailang Yanga361d842007-06-05 12:30:55 +020013620#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13621
13622/* init callback for auto-configuration model -- overriding the default init */
13623static void alc268_auto_init(struct hda_codec *codec)
13624{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013625 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013626 alc268_auto_init_multi_out(codec);
13627 alc268_auto_init_hp_out(codec);
13628 alc268_auto_init_mono_speaker_out(codec);
13629 alc268_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013630 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013631 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013632 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013633}
13634
13635/*
13636 * configuration and preset
13637 */
13638static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013639 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013640 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013641 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013642 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013643 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013644 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013645 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013646 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013647#ifdef CONFIG_SND_DEBUG
13648 [ALC268_TEST] = "test",
13649#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013650 [ALC268_AUTO] = "auto",
13651};
13652
13653static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013654 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013655 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013656 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013657 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013658 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013659 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13660 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013661 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013662 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13663 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013664 /* almost compatible with toshiba but with optional digital outs;
13665 * auto-probing seems working fine
13666 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013667 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013668 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013669 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013670 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013671 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013672 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013673 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013674 {}
13675};
13676
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013677/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13678static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13679 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13680 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13681 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13682 ALC268_TOSHIBA),
13683 {}
13684};
13685
Kailang Yanga361d842007-06-05 12:30:55 +020013686static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013687 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013688 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13689 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013690 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13691 alc267_quanta_il1_verbs },
13692 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13693 .dac_nids = alc268_dac_nids,
13694 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13695 .adc_nids = alc268_adc_nids_alt,
13696 .hp_nid = 0x03,
13697 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13698 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013699 .unsol_event = alc_sku_unsol_event,
13700 .setup = alc267_quanta_il1_setup,
13701 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013702 },
Kailang Yanga361d842007-06-05 12:30:55 +020013703 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013704 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13705 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013706 .init_verbs = { alc268_base_init_verbs },
13707 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13708 .dac_nids = alc268_dac_nids,
13709 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13710 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013711 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013712 .hp_nid = 0x03,
13713 .dig_out_nid = ALC268_DIGOUT_NID,
13714 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13715 .channel_mode = alc268_modes,
13716 .input_mux = &alc268_capture_source,
13717 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013718 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013719 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013720 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013721 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13722 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013723 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13724 .dac_nids = alc268_dac_nids,
13725 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13726 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013727 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013728 .hp_nid = 0x03,
13729 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13730 .channel_mode = alc268_modes,
13731 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013732 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013733 .setup = alc268_toshiba_setup,
13734 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013735 },
13736 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013737 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013738 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013739 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13740 alc268_acer_verbs },
13741 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13742 .dac_nids = alc268_dac_nids,
13743 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13744 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013745 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013746 .hp_nid = 0x02,
13747 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13748 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013749 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013750 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013751 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013752 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013753 [ALC268_ACER_DMIC] = {
13754 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13755 alc268_beep_mixer },
13756 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13757 alc268_acer_verbs },
13758 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13759 .dac_nids = alc268_dac_nids,
13760 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13761 .adc_nids = alc268_adc_nids_alt,
13762 .capsrc_nids = alc268_capsrc_nids,
13763 .hp_nid = 0x02,
13764 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13765 .channel_mode = alc268_modes,
13766 .input_mux = &alc268_acer_dmic_capture_source,
13767 .unsol_event = alc268_acer_unsol_event,
13768 .init_hook = alc268_acer_init_hook,
13769 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013770 [ALC268_ACER_ASPIRE_ONE] = {
13771 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013772 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013773 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013774 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13775 alc268_acer_aspire_one_verbs },
13776 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13777 .dac_nids = alc268_dac_nids,
13778 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13779 .adc_nids = alc268_adc_nids_alt,
13780 .capsrc_nids = alc268_capsrc_nids,
13781 .hp_nid = 0x03,
13782 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13783 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013784 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013785 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013786 .init_hook = alc268_acer_lc_init_hook,
13787 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013788 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013789 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13790 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013791 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13792 alc268_dell_verbs },
13793 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13794 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013795 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13796 .adc_nids = alc268_adc_nids_alt,
13797 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013798 .hp_nid = 0x02,
13799 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13800 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013801 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013802 .setup = alc268_dell_setup,
13803 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013804 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013805 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013806 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13807 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013808 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13809 alc268_toshiba_verbs },
13810 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13811 .dac_nids = alc268_dac_nids,
13812 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13813 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013814 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013815 .hp_nid = 0x03,
13816 .dig_out_nid = ALC268_DIGOUT_NID,
13817 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13818 .channel_mode = alc268_modes,
13819 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013820 .setup = alc268_toshiba_setup,
13821 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013822 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013823#ifdef CONFIG_SND_DEBUG
13824 [ALC268_TEST] = {
13825 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13826 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13827 alc268_volume_init_verbs },
13828 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13829 .dac_nids = alc268_dac_nids,
13830 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13831 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013832 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013833 .hp_nid = 0x03,
13834 .dig_out_nid = ALC268_DIGOUT_NID,
13835 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13836 .channel_mode = alc268_modes,
13837 .input_mux = &alc268_capture_source,
13838 },
13839#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013840};
13841
13842static int patch_alc268(struct hda_codec *codec)
13843{
13844 struct alc_spec *spec;
13845 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013846 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013847
Julia Lawallef86f582009-12-19 08:18:03 +010013848 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013849 if (spec == NULL)
13850 return -ENOMEM;
13851
13852 codec->spec = spec;
13853
13854 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13855 alc268_models,
13856 alc268_cfg_tbl);
13857
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013858 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13859 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013860 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013861
Kailang Yanga361d842007-06-05 12:30:55 +020013862 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013863 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13864 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013865 board_config = ALC268_AUTO;
13866 }
13867
13868 if (board_config == ALC268_AUTO) {
13869 /* automatic parse from the BIOS config */
13870 err = alc268_parse_auto_config(codec);
13871 if (err < 0) {
13872 alc_free(codec);
13873 return err;
13874 } else if (!err) {
13875 printk(KERN_INFO
13876 "hda_codec: Cannot set up configuration "
13877 "from BIOS. Using base mode...\n");
13878 board_config = ALC268_3ST;
13879 }
13880 }
13881
13882 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013883 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013884
Kailang Yanga361d842007-06-05 12:30:55 +020013885 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13886 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013887 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013888
Kailang Yanga361d842007-06-05 12:30:55 +020013889 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13890
Takashi Iwai22971e32009-02-10 11:56:44 +010013891 has_beep = 0;
13892 for (i = 0; i < spec->num_mixers; i++) {
13893 if (spec->mixers[i] == alc268_beep_mixer) {
13894 has_beep = 1;
13895 break;
13896 }
13897 }
13898
13899 if (has_beep) {
13900 err = snd_hda_attach_beep_device(codec, 0x1);
13901 if (err < 0) {
13902 alc_free(codec);
13903 return err;
13904 }
13905 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13906 /* override the amp caps for beep generator */
13907 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013908 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13909 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13910 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13911 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013912 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013913
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013914 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013915 /* check whether NID 0x07 is valid */
13916 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013917 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013918
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013919 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013920 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013921 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013922 if (spec->auto_mic ||
13923 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013924 spec->adc_nids = alc268_adc_nids_alt;
13925 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013926 if (spec->auto_mic)
13927 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013928 if (spec->auto_mic || spec->input_mux->num_items == 1)
13929 add_mixer(spec, alc268_capture_nosrc_mixer);
13930 else
13931 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013932 } else {
13933 spec->adc_nids = alc268_adc_nids;
13934 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013935 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013936 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013937 /* set default input source */
13938 for (i = 0; i < spec->num_adc_nids; i++)
13939 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13940 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013941 i < spec->num_mux_defs ?
13942 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013943 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013944 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013945
13946 spec->vmaster_nid = 0x02;
13947
Kailang Yanga361d842007-06-05 12:30:55 +020013948 codec->patch_ops = alc_patch_ops;
13949 if (board_config == ALC268_AUTO)
13950 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013951
Kailang Yanga361d842007-06-05 12:30:55 +020013952 return 0;
13953}
13954
13955/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013956 * ALC269 channel source setting (2 channel)
13957 */
13958#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13959
13960#define alc269_dac_nids alc260_dac_nids
13961
13962static hda_nid_t alc269_adc_nids[1] = {
13963 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013964 0x08,
13965};
13966
Takashi Iwaie01bf502008-08-21 16:25:07 +020013967static hda_nid_t alc269_capsrc_nids[1] = {
13968 0x23,
13969};
13970
Kailang Yang84898e82010-02-04 14:16:14 +010013971static hda_nid_t alc269vb_adc_nids[1] = {
13972 /* ADC1 */
13973 0x09,
13974};
13975
13976static hda_nid_t alc269vb_capsrc_nids[1] = {
13977 0x22,
13978};
13979
Takashi Iwai66946352010-03-29 17:21:45 +020013980static hda_nid_t alc269_adc_candidates[] = {
13981 0x08, 0x09, 0x07,
13982};
Takashi Iwaie01bf502008-08-21 16:25:07 +020013983
Kailang Yangf6a92242007-12-13 16:52:54 +010013984#define alc269_modes alc260_modes
13985#define alc269_capture_source alc880_lg_lw_capture_source
13986
13987static struct snd_kcontrol_new alc269_base_mixer[] = {
13988 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13989 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13990 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13991 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13992 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13993 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13994 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13995 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13996 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13997 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13998 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13999 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
14000 { } /* end */
14001};
14002
Kailang Yang60db6b52008-08-26 13:13:00 +020014003static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
14004 /* output mixer control */
14005 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14006 {
14007 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14008 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014009 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020014010 .info = snd_hda_mixer_amp_switch_info,
14011 .get = snd_hda_mixer_amp_switch_get,
14012 .put = alc268_acer_master_sw_put,
14013 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14014 },
14015 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14016 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14017 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14018 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14019 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14020 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014021 { }
14022};
14023
Tony Vroon64154832008-11-06 15:08:49 +000014024static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
14025 /* output mixer control */
14026 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14027 {
14028 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14029 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014030 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000014031 .info = snd_hda_mixer_amp_switch_info,
14032 .get = snd_hda_mixer_amp_switch_get,
14033 .put = alc268_acer_master_sw_put,
14034 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14035 },
14036 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14037 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14038 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14039 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14040 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14041 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
14042 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
14043 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
14044 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014045 { }
14046};
14047
Kailang Yang84898e82010-02-04 14:16:14 +010014048static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020014049 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014050 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020014051 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014052 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020014053 { } /* end */
14054};
14055
Kailang Yang84898e82010-02-04 14:16:14 +010014056static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
14057 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14058 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14059 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14060 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14061 { } /* end */
14062};
14063
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014064static struct snd_kcontrol_new alc269_asus_mixer[] = {
14065 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14066 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
14067 { } /* end */
14068};
14069
Kailang Yangf6a92242007-12-13 16:52:54 +010014070/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010014071static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
14072 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14073 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
14074 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14075 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
14076 { } /* end */
14077};
14078
14079static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020014080 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14081 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010014082 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14083 { } /* end */
14084};
14085
Kailang Yang84898e82010-02-04 14:16:14 +010014086static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
14087 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14088 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14089 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14090 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
14091 { } /* end */
14092};
14093
14094static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
14095 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14096 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14097 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14098 { } /* end */
14099};
14100
Takashi Iwai26f5df22008-11-03 17:39:46 +010014101/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010014102#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020014103
Kailang Yang60db6b52008-08-26 13:13:00 +020014104static struct hda_verb alc269_quanta_fl1_verbs[] = {
14105 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14106 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14107 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14108 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14109 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14110 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14111 { }
14112};
14113
Tony Vroon64154832008-11-06 15:08:49 +000014114static struct hda_verb alc269_lifebook_verbs[] = {
14115 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14116 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
14117 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14118 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14119 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14120 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14121 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14122 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14123 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14124 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14125 { }
14126};
14127
Kailang Yang60db6b52008-08-26 13:13:00 +020014128/* toggle speaker-output according to the hp-jack state */
14129static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
14130{
14131 unsigned int present;
14132 unsigned char bits;
14133
Wu Fengguang864f92b2009-11-18 12:38:02 +080014134 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014135 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014136 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014137 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014138 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014139 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014140
14141 snd_hda_codec_write(codec, 0x20, 0,
14142 AC_VERB_SET_COEF_INDEX, 0x0c);
14143 snd_hda_codec_write(codec, 0x20, 0,
14144 AC_VERB_SET_PROC_COEF, 0x680);
14145
14146 snd_hda_codec_write(codec, 0x20, 0,
14147 AC_VERB_SET_COEF_INDEX, 0x0c);
14148 snd_hda_codec_write(codec, 0x20, 0,
14149 AC_VERB_SET_PROC_COEF, 0x480);
14150}
14151
Tony Vroon64154832008-11-06 15:08:49 +000014152/* toggle speaker-output according to the hp-jacks state */
14153static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
14154{
14155 unsigned int present;
14156 unsigned char bits;
14157
14158 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014159 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000014160
14161 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014162 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000014163
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014164 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000014165 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014166 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014167 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014168 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014169
14170 snd_hda_codec_write(codec, 0x20, 0,
14171 AC_VERB_SET_COEF_INDEX, 0x0c);
14172 snd_hda_codec_write(codec, 0x20, 0,
14173 AC_VERB_SET_PROC_COEF, 0x680);
14174
14175 snd_hda_codec_write(codec, 0x20, 0,
14176 AC_VERB_SET_COEF_INDEX, 0x0c);
14177 snd_hda_codec_write(codec, 0x20, 0,
14178 AC_VERB_SET_PROC_COEF, 0x480);
14179}
14180
Tony Vroon64154832008-11-06 15:08:49 +000014181static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14182{
14183 unsigned int present_laptop;
14184 unsigned int present_dock;
14185
Wu Fengguang864f92b2009-11-18 12:38:02 +080014186 present_laptop = snd_hda_jack_detect(codec, 0x18);
14187 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014188
14189 /* Laptop mic port overrides dock mic port, design decision */
14190 if (present_dock)
14191 snd_hda_codec_write(codec, 0x23, 0,
14192 AC_VERB_SET_CONNECT_SEL, 0x3);
14193 if (present_laptop)
14194 snd_hda_codec_write(codec, 0x23, 0,
14195 AC_VERB_SET_CONNECT_SEL, 0x0);
14196 if (!present_dock && !present_laptop)
14197 snd_hda_codec_write(codec, 0x23, 0,
14198 AC_VERB_SET_CONNECT_SEL, 0x1);
14199}
14200
Kailang Yang60db6b52008-08-26 13:13:00 +020014201static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14202 unsigned int res)
14203{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014204 switch (res >> 26) {
14205 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014206 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014207 break;
14208 case ALC880_MIC_EVENT:
14209 alc_mic_automute(codec);
14210 break;
14211 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014212}
14213
Tony Vroon64154832008-11-06 15:08:49 +000014214static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14215 unsigned int res)
14216{
14217 if ((res >> 26) == ALC880_HP_EVENT)
14218 alc269_lifebook_speaker_automute(codec);
14219 if ((res >> 26) == ALC880_MIC_EVENT)
14220 alc269_lifebook_mic_autoswitch(codec);
14221}
14222
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014223static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14224{
14225 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014226 spec->autocfg.hp_pins[0] = 0x15;
14227 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014228 spec->ext_mic.pin = 0x18;
14229 spec->ext_mic.mux_idx = 0;
14230 spec->int_mic.pin = 0x19;
14231 spec->int_mic.mux_idx = 1;
14232 spec->auto_mic = 1;
14233}
14234
Kailang Yang60db6b52008-08-26 13:13:00 +020014235static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14236{
14237 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014238 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014239}
14240
Tony Vroon64154832008-11-06 15:08:49 +000014241static void alc269_lifebook_init_hook(struct hda_codec *codec)
14242{
14243 alc269_lifebook_speaker_automute(codec);
14244 alc269_lifebook_mic_autoswitch(codec);
14245}
14246
Kailang Yang84898e82010-02-04 14:16:14 +010014247static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014248 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14249 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14250 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14251 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14252 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14253 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14254 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14255 {}
14256};
14257
Kailang Yang84898e82010-02-04 14:16:14 +010014258static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014259 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14260 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14261 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14262 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14263 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14264 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14265 {}
14266};
14267
Kailang Yang84898e82010-02-04 14:16:14 +010014268static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14269 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14270 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14271 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14272 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14273 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14274 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14275 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14276 {}
14277};
14278
14279static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14280 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14281 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14282 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14283 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14284 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14285 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14286 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14287 {}
14288};
14289
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014290static struct hda_verb alc271_acer_dmic_verbs[] = {
14291 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14292 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14293 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14294 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14295 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14296 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14297 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14298 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14299 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14300 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14301 { }
14302};
14303
Kailang Yang60db6b52008-08-26 13:13:00 +020014304/* toggle speaker-output according to the hp-jack state */
14305static void alc269_speaker_automute(struct hda_codec *codec)
14306{
Kailang Yangebb83ee2009-12-17 12:23:00 +010014307 struct alc_spec *spec = codec->spec;
14308 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020014309 unsigned int present;
14310 unsigned char bits;
14311
Kailang Yangebb83ee2009-12-17 12:23:00 +010014312 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014313 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014314 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014315 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014316 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014317 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014318}
14319
Kailang Yang60db6b52008-08-26 13:13:00 +020014320/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010014321static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020014322 unsigned int res)
14323{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014324 switch (res >> 26) {
14325 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014326 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014327 break;
14328 case ALC880_MIC_EVENT:
14329 alc_mic_automute(codec);
14330 break;
14331 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014332}
14333
Kailang Yang226b1ec2010-04-09 11:01:20 +020014334static void alc269_laptop_amic_setup(struct hda_codec *codec)
14335{
14336 struct alc_spec *spec = codec->spec;
14337 spec->autocfg.hp_pins[0] = 0x15;
14338 spec->autocfg.speaker_pins[0] = 0x14;
14339 spec->ext_mic.pin = 0x18;
14340 spec->ext_mic.mux_idx = 0;
14341 spec->int_mic.pin = 0x19;
14342 spec->int_mic.mux_idx = 1;
14343 spec->auto_mic = 1;
14344}
14345
Kailang Yang84898e82010-02-04 14:16:14 +010014346static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014347{
14348 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014349 spec->autocfg.hp_pins[0] = 0x15;
14350 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014351 spec->ext_mic.pin = 0x18;
14352 spec->ext_mic.mux_idx = 0;
14353 spec->int_mic.pin = 0x12;
14354 spec->int_mic.mux_idx = 5;
14355 spec->auto_mic = 1;
14356}
14357
Kailang Yang226b1ec2010-04-09 11:01:20 +020014358static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014359{
14360 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014361 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014362 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014363 spec->ext_mic.pin = 0x18;
14364 spec->ext_mic.mux_idx = 0;
14365 spec->int_mic.pin = 0x19;
14366 spec->int_mic.mux_idx = 1;
14367 spec->auto_mic = 1;
14368}
14369
Kailang Yang226b1ec2010-04-09 11:01:20 +020014370static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14371{
14372 struct alc_spec *spec = codec->spec;
14373 spec->autocfg.hp_pins[0] = 0x21;
14374 spec->autocfg.speaker_pins[0] = 0x14;
14375 spec->ext_mic.pin = 0x18;
14376 spec->ext_mic.mux_idx = 0;
14377 spec->int_mic.pin = 0x12;
14378 spec->int_mic.mux_idx = 6;
14379 spec->auto_mic = 1;
14380}
14381
Kailang Yang84898e82010-02-04 14:16:14 +010014382static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020014383{
14384 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014385 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014386}
14387
Kailang Yangf6a92242007-12-13 16:52:54 +010014388/*
14389 * generic initialization of ADC, input mixers and output mixers
14390 */
14391static struct hda_verb alc269_init_verbs[] = {
14392 /*
14393 * Unmute ADC0 and set the default input to mic-in
14394 */
Kailang Yang84898e82010-02-04 14:16:14 +010014395 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014396
14397 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014398 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014399 */
14400 /* set vol=0 to output mixers */
14401 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14402 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14403
14404 /* set up input amps for analog loopback */
14405 /* Amp Indices: DAC = 0, mixer = 1 */
14406 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14407 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14408 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14409 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14410 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14411 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14412
14413 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14414 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14415 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14416 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14417 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14418 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14419 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14420
14421 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14422 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014423
Kailang Yang84898e82010-02-04 14:16:14 +010014424 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014425 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14426 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014427 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014428
14429 /* set EAPD */
14430 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014431 { }
14432};
14433
14434static struct hda_verb alc269vb_init_verbs[] = {
14435 /*
14436 * Unmute ADC0 and set the default input to mic-in
14437 */
14438 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14439
14440 /*
14441 * Set up output mixers (0x02 - 0x03)
14442 */
14443 /* set vol=0 to output mixers */
14444 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14445 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14446
14447 /* set up input amps for analog loopback */
14448 /* Amp Indices: DAC = 0, mixer = 1 */
14449 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14450 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14451 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14452 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14453 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14454 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14455
14456 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14457 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14458 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14459 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14460 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14461 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14462 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14463
14464 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14465 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14466
14467 /* FIXME: use Mux-type input source selection */
14468 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14469 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14470 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14471
14472 /* set EAPD */
14473 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014474 { }
14475};
14476
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014477#define alc269_auto_create_multi_out_ctls \
14478 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014479#define alc269_auto_create_input_ctls \
14480 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014481
14482#ifdef CONFIG_SND_HDA_POWER_SAVE
14483#define alc269_loopbacks alc880_loopbacks
14484#endif
14485
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014486/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014487#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14488#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14489#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14490#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14491
Takashi Iwaif03d3112009-03-05 14:18:16 +010014492static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14493 .substreams = 1,
14494 .channels_min = 2,
14495 .channels_max = 8,
14496 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14497 /* NID is set in alc_build_pcms */
14498 .ops = {
14499 .open = alc880_playback_pcm_open,
14500 .prepare = alc880_playback_pcm_prepare,
14501 .cleanup = alc880_playback_pcm_cleanup
14502 },
14503};
14504
14505static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14506 .substreams = 1,
14507 .channels_min = 2,
14508 .channels_max = 2,
14509 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14510 /* NID is set in alc_build_pcms */
14511};
14512
Takashi Iwaiad358792010-03-30 18:00:59 +020014513#ifdef CONFIG_SND_HDA_POWER_SAVE
14514static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14515{
14516 switch (codec->subsystem_id) {
14517 case 0x103c1586:
14518 return 1;
14519 }
14520 return 0;
14521}
14522
14523static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14524{
14525 /* update mute-LED according to the speaker mute state */
14526 if (nid == 0x01 || nid == 0x14) {
14527 int pinval;
14528 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14529 HDA_AMP_MUTE)
14530 pinval = 0x24;
14531 else
14532 pinval = 0x20;
14533 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a542010-03-30 18:03:44 +020014534 snd_hda_codec_update_cache(codec, 0x19, 0,
14535 AC_VERB_SET_PIN_WIDGET_CONTROL,
14536 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014537 }
14538 return alc_check_power_status(codec, nid);
14539}
14540#endif /* CONFIG_SND_HDA_POWER_SAVE */
14541
Takashi Iwai840b64c2010-07-13 22:49:01 +020014542static int alc275_setup_dual_adc(struct hda_codec *codec)
14543{
14544 struct alc_spec *spec = codec->spec;
14545
14546 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14547 return 0;
14548 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14549 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14550 if (spec->ext_mic.pin <= 0x12) {
14551 spec->private_adc_nids[0] = 0x08;
14552 spec->private_adc_nids[1] = 0x11;
14553 spec->private_capsrc_nids[0] = 0x23;
14554 spec->private_capsrc_nids[1] = 0x22;
14555 } else {
14556 spec->private_adc_nids[0] = 0x11;
14557 spec->private_adc_nids[1] = 0x08;
14558 spec->private_capsrc_nids[0] = 0x22;
14559 spec->private_capsrc_nids[1] = 0x23;
14560 }
14561 spec->adc_nids = spec->private_adc_nids;
14562 spec->capsrc_nids = spec->private_capsrc_nids;
14563 spec->num_adc_nids = 2;
14564 spec->dual_adc_switch = 1;
14565 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14566 spec->adc_nids[0], spec->adc_nids[1]);
14567 return 1;
14568 }
14569 return 0;
14570}
14571
Takashi Iwaid433a672010-09-20 15:11:54 +020014572/* different alc269-variants */
14573enum {
14574 ALC269_TYPE_NORMAL,
14575 ALC269_TYPE_ALC259,
14576 ALC269_TYPE_ALC271X,
14577};
14578
Kailang Yangf6a92242007-12-13 16:52:54 +010014579/*
14580 * BIOS auto configuration
14581 */
14582static int alc269_parse_auto_config(struct hda_codec *codec)
14583{
14584 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014585 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014586 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14587
14588 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14589 alc269_ignore);
14590 if (err < 0)
14591 return err;
14592
14593 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14594 if (err < 0)
14595 return err;
Takashi Iwaif3550d12010-09-20 15:09:03 +020014596 if (spec->codec_variant == ALC269_TYPE_NORMAL)
14597 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
14598 else
14599 err = alc_auto_create_input_ctls(codec, &spec->autocfg, 0,
14600 0x22, 0);
Kailang Yangf6a92242007-12-13 16:52:54 +010014601 if (err < 0)
14602 return err;
14603
14604 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14605
Takashi Iwai757899a2010-07-30 10:48:14 +020014606 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014607
Takashi Iwai603c4012008-07-30 15:01:44 +020014608 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014609 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014610
Takashi Iwaid433a672010-09-20 15:11:54 +020014611 if (spec->codec_variant != ALC269_TYPE_NORMAL) {
Kailang Yang84898e82010-02-04 14:16:14 +010014612 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014613 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014614 } else {
14615 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014616 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014617 }
14618
Kailang Yangf6a92242007-12-13 16:52:54 +010014619 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014620 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014621
14622 if (!alc275_setup_dual_adc(codec))
14623 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14624 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014625
Takashi Iwaie01bf502008-08-21 16:25:07 +020014626 /* set default input source */
Takashi Iwai840b64c2010-07-13 22:49:01 +020014627 if (!spec->dual_adc_switch)
Takashi Iwai748cce42010-08-04 07:37:39 +020014628 select_or_unmute_capsrc(codec, spec->capsrc_nids[0],
14629 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014630
14631 err = alc_auto_add_mic_boost(codec);
14632 if (err < 0)
14633 return err;
14634
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014635 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014636 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014637
Kailang Yangf6a92242007-12-13 16:52:54 +010014638 return 1;
14639}
14640
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014641#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14642#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014643#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14644
14645
14646/* init callback for auto-configuration model -- overriding the default init */
14647static void alc269_auto_init(struct hda_codec *codec)
14648{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014649 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014650 alc269_auto_init_multi_out(codec);
14651 alc269_auto_init_hp_out(codec);
14652 alc269_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014653 alc_auto_init_digital(codec);
Kailang Yang9ad0e492010-09-14 23:22:00 +020014654 alc_init_jacks(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014655 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014656 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014657}
14658
Kailang Yang977ddd62010-09-15 10:02:29 +020014659#ifdef CONFIG_SND_HDA_POWER_SAVE
14660static int alc269_suspend(struct hda_codec *codec, pm_message_t state)
14661{
14662 struct alc_spec *spec = codec->spec;
14663 int val;
14664
14665 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
14666 val = alc_read_coef_idx(codec, 0x04);
14667 /* Power down output pin */
14668 alc_write_coef_idx(codec, 0x04, val & ~(1<<11));
14669 }
14670
14671 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
14672 val = alc_read_coef_idx(codec, 0x04);
14673 /* Power down output pin */
14674 alc_write_coef_idx(codec, 0x04, val & ~(1<<11));
14675 msleep(150);
14676 }
14677
14678 alc_shutup(codec);
14679 if (spec && spec->power_hook)
14680 spec->power_hook(codec);
14681 return 0;
14682}
14683#endif
14684#ifdef SND_HDA_NEEDS_RESUME
14685static int alc269_resume(struct hda_codec *codec)
14686{
14687 int val;
14688
14689 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
14690 val = alc_read_coef_idx(codec, 0x04);
14691 /* Power down output pin */
14692 alc_write_coef_idx(codec, 0x04, val & ~(1<<11));
14693 msleep(150);
14694 }
14695
14696 codec->patch_ops.init(codec);
14697
14698 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
14699 val = alc_read_coef_idx(codec, 0x04);
14700 /* Power up output pin */
14701 alc_write_coef_idx(codec, 0x04, val | (1<<11));
14702 msleep(200);
14703 }
14704
14705 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
14706 val = alc_read_coef_idx(codec, 0x04);
14707 /* Power up output pin */
14708 alc_write_coef_idx(codec, 0x04, val | (1<<11));
14709 }
14710
14711 snd_hda_codec_resume_amp(codec);
14712 snd_hda_codec_resume_cache(codec);
14713#ifdef CONFIG_SND_HDA_POWER_SAVE
14714 if (codec->patch_ops.check_power_status)
14715 codec->patch_ops.check_power_status(codec, 0x01);
14716#endif
14717 return 0;
14718}
14719#endif
14720
Takashi Iwaiff818c22010-04-12 08:59:25 +020014721enum {
14722 ALC269_FIXUP_SONY_VAIO,
14723};
14724
Takashi Iwaiff818c22010-04-12 08:59:25 +020014725static const struct alc_fixup alc269_fixups[] = {
14726 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020014727 .verbs = (const struct hda_verb[]) {
14728 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14729 {}
14730 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014731 },
14732};
14733
14734static struct snd_pci_quirk alc269_fixup_tbl[] = {
14735 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningssondbbcbc02010-08-23 08:14:35 +020014736 SND_PCI_QUIRK(0x104d, 0x9077, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014737 {}
14738};
14739
14740
Kailang Yangf6a92242007-12-13 16:52:54 +010014741/*
14742 * configuration and preset
14743 */
14744static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014745 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014746 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014747 [ALC269_AMIC] = "laptop-amic",
14748 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014749 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014750 [ALC269_LIFEBOOK] = "lifebook",
14751 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014752};
14753
14754static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014755 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014756 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014757 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014758 ALC269_AMIC),
14759 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14760 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14761 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14762 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14763 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14764 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14765 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14766 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14767 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
14768 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14769 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14770 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14771 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14772 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14773 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14774 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14775 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14776 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14777 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14778 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14779 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14780 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14781 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14782 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14783 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14784 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14785 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14786 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14787 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14788 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14789 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14790 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14791 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14792 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14793 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14794 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014795 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014796 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014797 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014798 ALC269_DMIC),
14799 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14800 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014801 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014802 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014803 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14804 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14805 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14806 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14807 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14808 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014809 {}
14810};
14811
14812static struct alc_config_preset alc269_presets[] = {
14813 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014814 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014815 .init_verbs = { alc269_init_verbs },
14816 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14817 .dac_nids = alc269_dac_nids,
14818 .hp_nid = 0x03,
14819 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14820 .channel_mode = alc269_modes,
14821 .input_mux = &alc269_capture_source,
14822 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014823 [ALC269_QUANTA_FL1] = {
14824 .mixers = { alc269_quanta_fl1_mixer },
14825 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14826 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14827 .dac_nids = alc269_dac_nids,
14828 .hp_nid = 0x03,
14829 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14830 .channel_mode = alc269_modes,
14831 .input_mux = &alc269_capture_source,
14832 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014833 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014834 .init_hook = alc269_quanta_fl1_init_hook,
14835 },
Kailang Yang84898e82010-02-04 14:16:14 +010014836 [ALC269_AMIC] = {
14837 .mixers = { alc269_laptop_mixer },
14838 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014839 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014840 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014841 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14842 .dac_nids = alc269_dac_nids,
14843 .hp_nid = 0x03,
14844 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14845 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014846 .unsol_event = alc269_laptop_unsol_event,
14847 .setup = alc269_laptop_amic_setup,
14848 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014849 },
Kailang Yang84898e82010-02-04 14:16:14 +010014850 [ALC269_DMIC] = {
14851 .mixers = { alc269_laptop_mixer },
14852 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014853 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014854 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014855 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14856 .dac_nids = alc269_dac_nids,
14857 .hp_nid = 0x03,
14858 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14859 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014860 .unsol_event = alc269_laptop_unsol_event,
14861 .setup = alc269_laptop_dmic_setup,
14862 .init_hook = alc269_laptop_inithook,
14863 },
14864 [ALC269VB_AMIC] = {
14865 .mixers = { alc269vb_laptop_mixer },
14866 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14867 .init_verbs = { alc269vb_init_verbs,
14868 alc269vb_laptop_amic_init_verbs },
14869 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14870 .dac_nids = alc269_dac_nids,
14871 .hp_nid = 0x03,
14872 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14873 .channel_mode = alc269_modes,
14874 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020014875 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010014876 .init_hook = alc269_laptop_inithook,
14877 },
14878 [ALC269VB_DMIC] = {
14879 .mixers = { alc269vb_laptop_mixer },
14880 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14881 .init_verbs = { alc269vb_init_verbs,
14882 alc269vb_laptop_dmic_init_verbs },
14883 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14884 .dac_nids = alc269_dac_nids,
14885 .hp_nid = 0x03,
14886 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14887 .channel_mode = alc269_modes,
14888 .unsol_event = alc269_laptop_unsol_event,
14889 .setup = alc269vb_laptop_dmic_setup,
14890 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014891 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014892 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014893 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014894 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014895 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014896 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014897 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14898 .dac_nids = alc269_dac_nids,
14899 .hp_nid = 0x03,
14900 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14901 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014902 .unsol_event = alc269_laptop_unsol_event,
14903 .setup = alc269_laptop_dmic_setup,
14904 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014905 },
Tony Vroon64154832008-11-06 15:08:49 +000014906 [ALC269_LIFEBOOK] = {
14907 .mixers = { alc269_lifebook_mixer },
14908 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14909 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14910 .dac_nids = alc269_dac_nids,
14911 .hp_nid = 0x03,
14912 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14913 .channel_mode = alc269_modes,
14914 .input_mux = &alc269_capture_source,
14915 .unsol_event = alc269_lifebook_unsol_event,
14916 .init_hook = alc269_lifebook_init_hook,
14917 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014918 [ALC271_ACER] = {
14919 .mixers = { alc269_asus_mixer },
14920 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14921 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
14922 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14923 .dac_nids = alc269_dac_nids,
14924 .adc_nids = alc262_dmic_adc_nids,
14925 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
14926 .capsrc_nids = alc262_dmic_capsrc_nids,
14927 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14928 .channel_mode = alc269_modes,
14929 .input_mux = &alc269_capture_source,
14930 .dig_out_nid = ALC880_DIGOUT_NID,
14931 .unsol_event = alc_sku_unsol_event,
14932 .setup = alc269vb_laptop_dmic_setup,
14933 .init_hook = alc_inithook,
14934 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014935};
14936
Kailang Yang977ddd62010-09-15 10:02:29 +020014937static int alc269_fill_coef(struct hda_codec *codec)
14938{
14939 int val;
14940
14941 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
14942 alc_write_coef_idx(codec, 0xf, 0x960b);
14943 alc_write_coef_idx(codec, 0xe, 0x8817);
14944 }
14945
14946 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
14947 alc_write_coef_idx(codec, 0xf, 0x960b);
14948 alc_write_coef_idx(codec, 0xe, 0x8814);
14949 }
14950
14951 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
14952 val = alc_read_coef_idx(codec, 0x04);
14953 /* Power up output pin */
14954 alc_write_coef_idx(codec, 0x04, val | (1<<11));
14955 }
14956
14957 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
14958 val = alc_read_coef_idx(codec, 0xd);
14959 if ((val & 0x0c00) >> 10 != 0x1) {
14960 /* Capless ramp up clock control */
14961 alc_write_coef_idx(codec, 0xd, val | 1<<10);
14962 }
14963 val = alc_read_coef_idx(codec, 0x17);
14964 if ((val & 0x01c0) >> 6 != 0x4) {
14965 /* Class D power on reset */
14966 alc_write_coef_idx(codec, 0x17, val | 1<<7);
14967 }
14968 }
14969 return 0;
14970}
14971
Kailang Yangf6a92242007-12-13 16:52:54 +010014972static int patch_alc269(struct hda_codec *codec)
14973{
14974 struct alc_spec *spec;
14975 int board_config;
14976 int err;
14977
14978 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14979 if (spec == NULL)
14980 return -ENOMEM;
14981
14982 codec->spec = spec;
14983
Kailang Yangda00c242010-03-19 11:23:45 +010014984 alc_auto_parse_customize_define(codec);
14985
Kailang Yang274693f2009-12-03 10:07:50 +010014986 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
Kailang Yangc027ddc2010-03-19 11:33:06 +010014987 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
Takashi Iwaid433a672010-09-20 15:11:54 +020014988 spec->cdefine.platform_type == 1) {
Kailang Yangc027ddc2010-03-19 11:33:06 +010014989 alc_codec_rename(codec, "ALC271X");
Takashi Iwaid433a672010-09-20 15:11:54 +020014990 spec->codec_variant = ALC269_TYPE_ALC271X;
14991 } else {
Kailang Yangc027ddc2010-03-19 11:33:06 +010014992 alc_codec_rename(codec, "ALC259");
Takashi Iwaid433a672010-09-20 15:11:54 +020014993 spec->codec_variant = ALC269_TYPE_ALC259;
14994 }
Kailang Yangc027ddc2010-03-19 11:33:06 +010014995 } else
14996 alc_fix_pll_init(codec, 0x20, 0x04, 15);
Kailang Yang274693f2009-12-03 10:07:50 +010014997
Kailang Yang977ddd62010-09-15 10:02:29 +020014998 alc269_fill_coef(codec);
14999
Kailang Yangf6a92242007-12-13 16:52:54 +010015000 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
15001 alc269_models,
15002 alc269_cfg_tbl);
15003
15004 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015005 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15006 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010015007 board_config = ALC269_AUTO;
15008 }
15009
Takashi Iwaiff818c22010-04-12 08:59:25 +020015010 if (board_config == ALC269_AUTO)
15011 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 1);
15012
Kailang Yangf6a92242007-12-13 16:52:54 +010015013 if (board_config == ALC269_AUTO) {
15014 /* automatic parse from the BIOS config */
15015 err = alc269_parse_auto_config(codec);
15016 if (err < 0) {
15017 alc_free(codec);
15018 return err;
15019 } else if (!err) {
15020 printk(KERN_INFO
15021 "hda_codec: Cannot set up configuration "
15022 "from BIOS. Using base mode...\n");
15023 board_config = ALC269_BASIC;
15024 }
15025 }
15026
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015027 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020015028 err = snd_hda_attach_beep_device(codec, 0x1);
15029 if (err < 0) {
15030 alc_free(codec);
15031 return err;
15032 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015033 }
15034
Kailang Yangf6a92242007-12-13 16:52:54 +010015035 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015036 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010015037
Kailang Yang84898e82010-02-04 14:16:14 +010015038 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010015039 /* Due to a hardware problem on Lenovo Ideadpad, we need to
15040 * fix the sample rate of analog I/O to 44.1kHz
15041 */
15042 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
15043 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020015044 } else if (spec->dual_adc_switch) {
15045 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15046 /* switch ADC dynamically */
15047 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010015048 } else {
15049 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15050 spec->stream_analog_capture = &alc269_pcm_analog_capture;
15051 }
Kailang Yangf6a92242007-12-13 16:52:54 +010015052 spec->stream_digital_playback = &alc269_pcm_digital_playback;
15053 spec->stream_digital_capture = &alc269_pcm_digital_capture;
15054
Takashi Iwai66946352010-03-29 17:21:45 +020015055 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
Takashi Iwaid433a672010-09-20 15:11:54 +020015056 if (spec->codec_variant != ALC269_TYPE_NORMAL) {
Takashi Iwai66946352010-03-29 17:21:45 +020015057 spec->adc_nids = alc269_adc_nids;
15058 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
15059 spec->capsrc_nids = alc269_capsrc_nids;
15060 } else {
15061 spec->adc_nids = alc269vb_adc_nids;
15062 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
15063 spec->capsrc_nids = alc269vb_capsrc_nids;
15064 }
Kailang Yang84898e82010-02-04 14:16:14 +010015065 }
15066
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015067 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015068 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015069 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010015070 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010015071
Takashi Iwaiff818c22010-04-12 08:59:25 +020015072 if (board_config == ALC269_AUTO)
15073 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 0);
15074
Takashi Iwai100d5eb2009-08-10 11:55:51 +020015075 spec->vmaster_nid = 0x02;
15076
Kailang Yangf6a92242007-12-13 16:52:54 +010015077 codec->patch_ops = alc_patch_ops;
Kailang Yang977ddd62010-09-15 10:02:29 +020015078#ifdef CONFIG_SND_HDA_POWER_SAVE
15079 codec->patch_ops.suspend = alc269_suspend;
15080#endif
15081#ifdef SND_HDA_NEEDS_RESUME
15082 codec->patch_ops.resume = alc269_resume;
15083#endif
Kailang Yangf6a92242007-12-13 16:52:54 +010015084 if (board_config == ALC269_AUTO)
15085 spec->init_hook = alc269_auto_init;
15086#ifdef CONFIG_SND_HDA_POWER_SAVE
15087 if (!spec->loopback.amplist)
15088 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020015089 if (alc269_mic2_for_mute_led(codec))
15090 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010015091#endif
15092
15093 return 0;
15094}
15095
15096/*
Kailang Yangdf694da2005-12-05 19:42:22 +010015097 * ALC861 channel source setting (2/6 channel selection for 3-stack)
15098 */
15099
15100/*
15101 * set the path ways for 2 channel output
15102 * need to set the codec line out and mic 1 pin widgets to inputs
15103 */
15104static struct hda_verb alc861_threestack_ch2_init[] = {
15105 /* set pin widget 1Ah (line in) for input */
15106 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015107 /* set pin widget 18h (mic1/2) for input, for mic also enable
15108 * the vref
15109 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015110 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15111
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015112 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15113#if 0
15114 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15115 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15116#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015117 { } /* end */
15118};
15119/*
15120 * 6ch mode
15121 * need to set the codec line out and mic 1 pin widgets to outputs
15122 */
15123static struct hda_verb alc861_threestack_ch6_init[] = {
15124 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15125 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15126 /* set pin widget 18h (mic1) for output (CLFE)*/
15127 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15128
15129 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015130 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015131
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015132 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15133#if 0
15134 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15135 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15136#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015137 { } /* end */
15138};
15139
15140static struct hda_channel_mode alc861_threestack_modes[2] = {
15141 { 2, alc861_threestack_ch2_init },
15142 { 6, alc861_threestack_ch6_init },
15143};
Takashi Iwai22309c32006-08-09 16:57:28 +020015144/* Set mic1 as input and unmute the mixer */
15145static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
15146 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15147 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15148 { } /* end */
15149};
15150/* Set mic1 as output and mute mixer */
15151static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
15152 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15153 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15154 { } /* end */
15155};
15156
15157static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
15158 { 2, alc861_uniwill_m31_ch2_init },
15159 { 4, alc861_uniwill_m31_ch4_init },
15160};
Kailang Yangdf694da2005-12-05 19:42:22 +010015161
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015162/* Set mic1 and line-in as input and unmute the mixer */
15163static struct hda_verb alc861_asus_ch2_init[] = {
15164 /* set pin widget 1Ah (line in) for input */
15165 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015166 /* set pin widget 18h (mic1/2) for input, for mic also enable
15167 * the vref
15168 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015169 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15170
15171 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15172#if 0
15173 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15174 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15175#endif
15176 { } /* end */
15177};
15178/* Set mic1 nad line-in as output and mute mixer */
15179static struct hda_verb alc861_asus_ch6_init[] = {
15180 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15181 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15182 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15183 /* set pin widget 18h (mic1) for output (CLFE)*/
15184 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15185 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15186 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
15187 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
15188
15189 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15190#if 0
15191 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15192 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15193#endif
15194 { } /* end */
15195};
15196
15197static struct hda_channel_mode alc861_asus_modes[2] = {
15198 { 2, alc861_asus_ch2_init },
15199 { 6, alc861_asus_ch6_init },
15200};
15201
Kailang Yangdf694da2005-12-05 19:42:22 +010015202/* patch-ALC861 */
15203
15204static struct snd_kcontrol_new alc861_base_mixer[] = {
15205 /* output mixer control */
15206 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15207 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15208 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15209 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15210 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15211
15212 /*Input mixer control */
15213 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15214 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15215 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15216 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15217 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15218 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15219 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15220 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15221 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15222 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015223
Kailang Yangdf694da2005-12-05 19:42:22 +010015224 { } /* end */
15225};
15226
15227static struct snd_kcontrol_new alc861_3ST_mixer[] = {
15228 /* output mixer control */
15229 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15230 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15231 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15232 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15233 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15234
15235 /* Input mixer control */
15236 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15237 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15238 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15239 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15240 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15241 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15242 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15243 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15244 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15245 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015246
Kailang Yangdf694da2005-12-05 19:42:22 +010015247 {
15248 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15249 .name = "Channel Mode",
15250 .info = alc_ch_mode_info,
15251 .get = alc_ch_mode_get,
15252 .put = alc_ch_mode_put,
15253 .private_value = ARRAY_SIZE(alc861_threestack_modes),
15254 },
15255 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015256};
15257
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015258static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015259 /* output mixer control */
15260 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15261 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15262 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015263
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015264 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015265};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015266
Takashi Iwai22309c32006-08-09 16:57:28 +020015267static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
15268 /* output mixer control */
15269 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15270 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15271 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15272 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15273 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15274
15275 /* Input mixer control */
15276 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15277 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15278 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15279 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15280 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15281 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15282 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15283 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15284 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15285 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015286
Takashi Iwai22309c32006-08-09 16:57:28 +020015287 {
15288 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15289 .name = "Channel Mode",
15290 .info = alc_ch_mode_info,
15291 .get = alc_ch_mode_get,
15292 .put = alc_ch_mode_put,
15293 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15294 },
15295 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015296};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015297
15298static struct snd_kcontrol_new alc861_asus_mixer[] = {
15299 /* output mixer control */
15300 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15301 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15302 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15303 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15304 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15305
15306 /* Input mixer control */
15307 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15308 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15309 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15310 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15311 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15312 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15313 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15314 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15315 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015316 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15317
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015318 {
15319 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15320 .name = "Channel Mode",
15321 .info = alc_ch_mode_info,
15322 .get = alc_ch_mode_get,
15323 .put = alc_ch_mode_put,
15324 .private_value = ARRAY_SIZE(alc861_asus_modes),
15325 },
15326 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015327};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015328
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015329/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015330static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015331 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15332 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015333 { }
15334};
15335
Kailang Yangdf694da2005-12-05 19:42:22 +010015336/*
15337 * generic initialization of ADC, input mixers and output mixers
15338 */
15339static struct hda_verb alc861_base_init_verbs[] = {
15340 /*
15341 * Unmute ADC0 and set the default input to mic-in
15342 */
15343 /* port-A for surround (rear panel) */
15344 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15345 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15346 /* port-B for mic-in (rear panel) with vref */
15347 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15348 /* port-C for line-in (rear panel) */
15349 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15350 /* port-D for Front */
15351 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15352 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15353 /* port-E for HP out (front panel) */
15354 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15355 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015356 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015357 /* port-F for mic-in (front panel) with vref */
15358 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15359 /* port-G for CLFE (rear panel) */
15360 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15361 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15362 /* port-H for side (rear panel) */
15363 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15364 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15365 /* CD-in */
15366 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15367 /* route front mic to ADC1*/
15368 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15369 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015370
Kailang Yangdf694da2005-12-05 19:42:22 +010015371 /* Unmute DAC0~3 & spdif out*/
15372 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15373 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15374 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15375 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15376 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015377
Kailang Yangdf694da2005-12-05 19:42:22 +010015378 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15379 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15380 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15381 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15382 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015383
Kailang Yangdf694da2005-12-05 19:42:22 +010015384 /* Unmute Stereo Mixer 15 */
15385 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15386 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15387 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015388 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015389
15390 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15391 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15392 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15393 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15394 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15395 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15396 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15397 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015398 /* hp used DAC 3 (Front) */
15399 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015400 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15401
15402 { }
15403};
15404
15405static struct hda_verb alc861_threestack_init_verbs[] = {
15406 /*
15407 * Unmute ADC0 and set the default input to mic-in
15408 */
15409 /* port-A for surround (rear panel) */
15410 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15411 /* port-B for mic-in (rear panel) with vref */
15412 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15413 /* port-C for line-in (rear panel) */
15414 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15415 /* port-D for Front */
15416 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15417 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15418 /* port-E for HP out (front panel) */
15419 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15420 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015421 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015422 /* port-F for mic-in (front panel) with vref */
15423 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15424 /* port-G for CLFE (rear panel) */
15425 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15426 /* port-H for side (rear panel) */
15427 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15428 /* CD-in */
15429 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15430 /* route front mic to ADC1*/
15431 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15432 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15433 /* Unmute DAC0~3 & spdif out*/
15434 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15435 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15436 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15437 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15438 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015439
Kailang Yangdf694da2005-12-05 19:42:22 +010015440 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15441 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15442 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15443 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15444 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015445
Kailang Yangdf694da2005-12-05 19:42:22 +010015446 /* Unmute Stereo Mixer 15 */
15447 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15448 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15449 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015450 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015451
15452 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15453 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15454 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15455 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15456 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15457 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15458 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15459 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015460 /* hp used DAC 3 (Front) */
15461 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015462 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15463 { }
15464};
Takashi Iwai22309c32006-08-09 16:57:28 +020015465
15466static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15467 /*
15468 * Unmute ADC0 and set the default input to mic-in
15469 */
15470 /* port-A for surround (rear panel) */
15471 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15472 /* port-B for mic-in (rear panel) with vref */
15473 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15474 /* port-C for line-in (rear panel) */
15475 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15476 /* port-D for Front */
15477 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15478 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15479 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015480 /* this has to be set to VREF80 */
15481 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015482 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015483 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015484 /* port-F for mic-in (front panel) with vref */
15485 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15486 /* port-G for CLFE (rear panel) */
15487 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15488 /* port-H for side (rear panel) */
15489 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15490 /* CD-in */
15491 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15492 /* route front mic to ADC1*/
15493 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15494 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15495 /* Unmute DAC0~3 & spdif out*/
15496 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15497 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15498 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15499 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15500 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015501
Takashi Iwai22309c32006-08-09 16:57:28 +020015502 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15503 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15504 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15505 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15506 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015507
Takashi Iwai22309c32006-08-09 16:57:28 +020015508 /* Unmute Stereo Mixer 15 */
15509 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15510 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15511 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015512 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015513
15514 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15515 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15516 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15517 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15518 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15519 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15520 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15521 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015522 /* hp used DAC 3 (Front) */
15523 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015524 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15525 { }
15526};
15527
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015528static struct hda_verb alc861_asus_init_verbs[] = {
15529 /*
15530 * Unmute ADC0 and set the default input to mic-in
15531 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015532 /* port-A for surround (rear panel)
15533 * according to codec#0 this is the HP jack
15534 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015535 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15536 /* route front PCM to HP */
15537 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15538 /* port-B for mic-in (rear panel) with vref */
15539 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15540 /* port-C for line-in (rear panel) */
15541 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15542 /* port-D for Front */
15543 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15544 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15545 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015546 /* this has to be set to VREF80 */
15547 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015548 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015549 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015550 /* port-F for mic-in (front panel) with vref */
15551 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15552 /* port-G for CLFE (rear panel) */
15553 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15554 /* port-H for side (rear panel) */
15555 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15556 /* CD-in */
15557 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15558 /* route front mic to ADC1*/
15559 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15560 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15561 /* Unmute DAC0~3 & spdif out*/
15562 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15563 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15564 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15565 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15566 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15567 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15568 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15569 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15570 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15571 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015572
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015573 /* Unmute Stereo Mixer 15 */
15574 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15575 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15576 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015577 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015578
15579 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15580 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15581 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15582 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15583 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15584 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15585 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15586 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015587 /* hp used DAC 3 (Front) */
15588 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015589 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15590 { }
15591};
15592
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015593/* additional init verbs for ASUS laptops */
15594static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15595 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15596 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15597 { }
15598};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015599
Kailang Yangdf694da2005-12-05 19:42:22 +010015600/*
15601 * generic initialization of ADC, input mixers and output mixers
15602 */
15603static struct hda_verb alc861_auto_init_verbs[] = {
15604 /*
15605 * Unmute ADC0 and set the default input to mic-in
15606 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015607 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015608 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015609
Kailang Yangdf694da2005-12-05 19:42:22 +010015610 /* Unmute DAC0~3 & spdif out*/
15611 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15612 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15613 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15614 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15615 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015616
Kailang Yangdf694da2005-12-05 19:42:22 +010015617 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15618 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15619 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15620 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15621 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015622
Kailang Yangdf694da2005-12-05 19:42:22 +010015623 /* Unmute Stereo Mixer 15 */
15624 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15625 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15626 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15627 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15628
Takashi Iwai1c209302009-07-22 15:17:45 +020015629 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15630 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15631 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15632 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15633 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15634 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15635 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15636 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015637
15638 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15639 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015640 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15641 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015642 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15643 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015644 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15645 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015646
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015647 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015648
15649 { }
15650};
15651
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015652static struct hda_verb alc861_toshiba_init_verbs[] = {
15653 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015654
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015655 { }
15656};
15657
15658/* toggle speaker-output according to the hp-jack state */
15659static void alc861_toshiba_automute(struct hda_codec *codec)
15660{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015661 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015662
Takashi Iwai47fd8302007-08-10 17:11:07 +020015663 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15664 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15665 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15666 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015667}
15668
15669static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15670 unsigned int res)
15671{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015672 if ((res >> 26) == ALC880_HP_EVENT)
15673 alc861_toshiba_automute(codec);
15674}
15675
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015676/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015677#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15678#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15679#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15680#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15681
15682
15683#define ALC861_DIGOUT_NID 0x07
15684
15685static struct hda_channel_mode alc861_8ch_modes[1] = {
15686 { 8, NULL }
15687};
15688
15689static hda_nid_t alc861_dac_nids[4] = {
15690 /* front, surround, clfe, side */
15691 0x03, 0x06, 0x05, 0x04
15692};
15693
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015694static hda_nid_t alc660_dac_nids[3] = {
15695 /* front, clfe, surround */
15696 0x03, 0x05, 0x06
15697};
15698
Kailang Yangdf694da2005-12-05 19:42:22 +010015699static hda_nid_t alc861_adc_nids[1] = {
15700 /* ADC0-2 */
15701 0x08,
15702};
15703
15704static struct hda_input_mux alc861_capture_source = {
15705 .num_items = 5,
15706 .items = {
15707 { "Mic", 0x0 },
15708 { "Front Mic", 0x3 },
15709 { "Line", 0x1 },
15710 { "CD", 0x4 },
15711 { "Mixer", 0x5 },
15712 },
15713};
15714
Takashi Iwai1c209302009-07-22 15:17:45 +020015715static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15716{
15717 struct alc_spec *spec = codec->spec;
15718 hda_nid_t mix, srcs[5];
15719 int i, j, num;
15720
15721 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15722 return 0;
15723 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15724 if (num < 0)
15725 return 0;
15726 for (i = 0; i < num; i++) {
15727 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015728 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015729 if (type != AC_WID_AUD_OUT)
15730 continue;
15731 for (j = 0; j < spec->multiout.num_dacs; j++)
15732 if (spec->multiout.dac_nids[j] == srcs[i])
15733 break;
15734 if (j >= spec->multiout.num_dacs)
15735 return srcs[i];
15736 }
15737 return 0;
15738}
15739
Kailang Yangdf694da2005-12-05 19:42:22 +010015740/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015741static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015742 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015743{
Takashi Iwai1c209302009-07-22 15:17:45 +020015744 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015745 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015746 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015747
15748 spec->multiout.dac_nids = spec->private_dac_nids;
15749 for (i = 0; i < cfg->line_outs; i++) {
15750 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015751 dac = alc861_look_for_dac(codec, nid);
15752 if (!dac)
15753 continue;
15754 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015755 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015756 return 0;
15757}
15758
Takashi Iwai1c209302009-07-22 15:17:45 +020015759static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15760 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015761{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015762 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015763 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15764}
15765
15766/* add playback controls from the parsed DAC table */
15767static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15768 const struct auto_pin_cfg *cfg)
15769{
15770 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015771 static const char *chname[4] = {
15772 "Front", "Surround", NULL /*CLFE*/, "Side"
15773 };
Kailang Yangdf694da2005-12-05 19:42:22 +010015774 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015775 int i, err;
15776
15777 if (cfg->line_outs == 1) {
15778 const char *pfx = NULL;
15779 if (!cfg->hp_outs)
15780 pfx = "Master";
15781 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15782 pfx = "Speaker";
15783 if (pfx) {
15784 nid = spec->multiout.dac_nids[0];
15785 return alc861_create_out_sw(codec, pfx, nid, 3);
15786 }
15787 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015788
15789 for (i = 0; i < cfg->line_outs; i++) {
15790 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015791 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015792 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020015793 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015794 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015795 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015796 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015797 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015798 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015799 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015800 return err;
15801 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020015802 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015803 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015804 return err;
15805 }
15806 }
15807 return 0;
15808}
15809
Takashi Iwai1c209302009-07-22 15:17:45 +020015810static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015811{
Takashi Iwai1c209302009-07-22 15:17:45 +020015812 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015813 int err;
15814 hda_nid_t nid;
15815
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015816 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015817 return 0;
15818
15819 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020015820 nid = alc861_look_for_dac(codec, pin);
15821 if (nid) {
15822 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
15823 if (err < 0)
15824 return err;
15825 spec->multiout.hp_nid = nid;
15826 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015827 }
15828 return 0;
15829}
15830
15831/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015832static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015833 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015834{
Takashi Iwai05f5f472009-08-25 13:10:18 +020015835 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010015836}
15837
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015838static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
15839 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020015840 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010015841{
Takashi Iwai1c209302009-07-22 15:17:45 +020015842 hda_nid_t mix, srcs[5];
15843 int i, num;
15844
Jacek Luczak564c5be2008-05-03 18:41:23 +020015845 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
15846 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020015847 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020015848 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020015849 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
15850 return;
15851 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15852 if (num < 0)
15853 return;
15854 for (i = 0; i < num; i++) {
15855 unsigned int mute;
15856 if (srcs[i] == dac || srcs[i] == 0x15)
15857 mute = AMP_IN_UNMUTE(i);
15858 else
15859 mute = AMP_IN_MUTE(i);
15860 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15861 mute);
15862 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015863}
15864
15865static void alc861_auto_init_multi_out(struct hda_codec *codec)
15866{
15867 struct alc_spec *spec = codec->spec;
15868 int i;
15869
15870 for (i = 0; i < spec->autocfg.line_outs; i++) {
15871 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015872 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015873 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015874 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015875 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015876 }
15877}
15878
15879static void alc861_auto_init_hp_out(struct hda_codec *codec)
15880{
15881 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015882
Takashi Iwai15870f02009-10-05 08:25:13 +020015883 if (spec->autocfg.hp_outs)
15884 alc861_auto_set_output_and_unmute(codec,
15885 spec->autocfg.hp_pins[0],
15886 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020015887 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020015888 if (spec->autocfg.speaker_outs)
15889 alc861_auto_set_output_and_unmute(codec,
15890 spec->autocfg.speaker_pins[0],
15891 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020015892 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015893}
15894
15895static void alc861_auto_init_analog_input(struct hda_codec *codec)
15896{
15897 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020015898 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010015899 int i;
15900
Takashi Iwai66ceeb62010-08-30 13:05:52 +020015901 for (i = 0; i < cfg->num_inputs; i++) {
15902 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010015903 if (nid >= 0x0c && nid <= 0x11)
Takashi Iwai30ea0982010-09-16 18:47:56 +020015904 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015905 }
15906}
15907
15908/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015909/* return 1 if successful, 0 if the proper config is not found,
15910 * or a negative error code
15911 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015912static int alc861_parse_auto_config(struct hda_codec *codec)
15913{
15914 struct alc_spec *spec = codec->spec;
15915 int err;
15916 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
15917
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015918 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15919 alc861_ignore);
15920 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015921 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015922 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015923 return 0; /* can't find valid BIOS pin config */
15924
Takashi Iwai1c209302009-07-22 15:17:45 +020015925 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015926 if (err < 0)
15927 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015928 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015929 if (err < 0)
15930 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015931 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015932 if (err < 0)
15933 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015934 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015935 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015936 return err;
15937
15938 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15939
Takashi Iwai757899a2010-07-30 10:48:14 +020015940 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015941
Takashi Iwai603c4012008-07-30 15:01:44 +020015942 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015943 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010015944
Takashi Iwaid88897e2008-10-31 15:01:37 +010015945 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010015946
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020015947 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015948 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010015949
15950 spec->adc_nids = alc861_adc_nids;
15951 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015952 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015953
Kailang Yang6227cdc2010-02-25 08:36:52 +010015954 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015955
Kailang Yangdf694da2005-12-05 19:42:22 +010015956 return 1;
15957}
15958
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015959/* additional initialization for auto-configuration model */
15960static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010015961{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015962 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015963 alc861_auto_init_multi_out(codec);
15964 alc861_auto_init_hp_out(codec);
15965 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020015966 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015967 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015968 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015969}
15970
Takashi Iwaicb53c622007-08-10 17:21:45 +020015971#ifdef CONFIG_SND_HDA_POWER_SAVE
15972static struct hda_amp_list alc861_loopbacks[] = {
15973 { 0x15, HDA_INPUT, 0 },
15974 { 0x15, HDA_INPUT, 1 },
15975 { 0x15, HDA_INPUT, 2 },
15976 { 0x15, HDA_INPUT, 3 },
15977 { } /* end */
15978};
15979#endif
15980
Kailang Yangdf694da2005-12-05 19:42:22 +010015981
15982/*
15983 * configuration and preset
15984 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015985static const char *alc861_models[ALC861_MODEL_LAST] = {
15986 [ALC861_3ST] = "3stack",
15987 [ALC660_3ST] = "3stack-660",
15988 [ALC861_3ST_DIG] = "3stack-dig",
15989 [ALC861_6ST_DIG] = "6stack-dig",
15990 [ALC861_UNIWILL_M31] = "uniwill-m31",
15991 [ALC861_TOSHIBA] = "toshiba",
15992 [ALC861_ASUS] = "asus",
15993 [ALC861_ASUS_LAPTOP] = "asus-laptop",
15994 [ALC861_AUTO] = "auto",
15995};
15996
15997static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010015998 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015999 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16000 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16001 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016002 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020016003 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010016004 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020016005 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
16006 * Any other models that need this preset?
16007 */
16008 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020016009 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
16010 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016011 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
16012 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
16013 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
16014 /* FIXME: the below seems conflict */
16015 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
16016 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
16017 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010016018 {}
16019};
16020
16021static struct alc_config_preset alc861_presets[] = {
16022 [ALC861_3ST] = {
16023 .mixers = { alc861_3ST_mixer },
16024 .init_verbs = { alc861_threestack_init_verbs },
16025 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16026 .dac_nids = alc861_dac_nids,
16027 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16028 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016029 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016030 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16031 .adc_nids = alc861_adc_nids,
16032 .input_mux = &alc861_capture_source,
16033 },
16034 [ALC861_3ST_DIG] = {
16035 .mixers = { alc861_base_mixer },
16036 .init_verbs = { alc861_threestack_init_verbs },
16037 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16038 .dac_nids = alc861_dac_nids,
16039 .dig_out_nid = ALC861_DIGOUT_NID,
16040 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16041 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016042 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016043 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16044 .adc_nids = alc861_adc_nids,
16045 .input_mux = &alc861_capture_source,
16046 },
16047 [ALC861_6ST_DIG] = {
16048 .mixers = { alc861_base_mixer },
16049 .init_verbs = { alc861_base_init_verbs },
16050 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16051 .dac_nids = alc861_dac_nids,
16052 .dig_out_nid = ALC861_DIGOUT_NID,
16053 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
16054 .channel_mode = alc861_8ch_modes,
16055 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16056 .adc_nids = alc861_adc_nids,
16057 .input_mux = &alc861_capture_source,
16058 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016059 [ALC660_3ST] = {
16060 .mixers = { alc861_3ST_mixer },
16061 .init_verbs = { alc861_threestack_init_verbs },
16062 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
16063 .dac_nids = alc660_dac_nids,
16064 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16065 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016066 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016067 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16068 .adc_nids = alc861_adc_nids,
16069 .input_mux = &alc861_capture_source,
16070 },
Takashi Iwai22309c32006-08-09 16:57:28 +020016071 [ALC861_UNIWILL_M31] = {
16072 .mixers = { alc861_uniwill_m31_mixer },
16073 .init_verbs = { alc861_uniwill_m31_init_verbs },
16074 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16075 .dac_nids = alc861_dac_nids,
16076 .dig_out_nid = ALC861_DIGOUT_NID,
16077 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
16078 .channel_mode = alc861_uniwill_m31_modes,
16079 .need_dac_fix = 1,
16080 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16081 .adc_nids = alc861_adc_nids,
16082 .input_mux = &alc861_capture_source,
16083 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016084 [ALC861_TOSHIBA] = {
16085 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016086 .init_verbs = { alc861_base_init_verbs,
16087 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016088 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16089 .dac_nids = alc861_dac_nids,
16090 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16091 .channel_mode = alc883_3ST_2ch_modes,
16092 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16093 .adc_nids = alc861_adc_nids,
16094 .input_mux = &alc861_capture_source,
16095 .unsol_event = alc861_toshiba_unsol_event,
16096 .init_hook = alc861_toshiba_automute,
16097 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020016098 [ALC861_ASUS] = {
16099 .mixers = { alc861_asus_mixer },
16100 .init_verbs = { alc861_asus_init_verbs },
16101 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16102 .dac_nids = alc861_dac_nids,
16103 .dig_out_nid = ALC861_DIGOUT_NID,
16104 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
16105 .channel_mode = alc861_asus_modes,
16106 .need_dac_fix = 1,
16107 .hp_nid = 0x06,
16108 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16109 .adc_nids = alc861_adc_nids,
16110 .input_mux = &alc861_capture_source,
16111 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010016112 [ALC861_ASUS_LAPTOP] = {
16113 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
16114 .init_verbs = { alc861_asus_init_verbs,
16115 alc861_asus_laptop_init_verbs },
16116 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16117 .dac_nids = alc861_dac_nids,
16118 .dig_out_nid = ALC861_DIGOUT_NID,
16119 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16120 .channel_mode = alc883_3ST_2ch_modes,
16121 .need_dac_fix = 1,
16122 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16123 .adc_nids = alc861_adc_nids,
16124 .input_mux = &alc861_capture_source,
16125 },
16126};
Kailang Yangdf694da2005-12-05 19:42:22 +010016127
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016128/* Pin config fixes */
16129enum {
16130 PINFIX_FSC_AMILO_PI1505,
16131};
16132
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016133static const struct alc_fixup alc861_fixups[] = {
16134 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020016135 .pins = (const struct alc_pincfg[]) {
16136 { 0x0b, 0x0221101f }, /* HP */
16137 { 0x0f, 0x90170310 }, /* speaker */
16138 { }
16139 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016140 },
16141};
16142
16143static struct snd_pci_quirk alc861_fixup_tbl[] = {
16144 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
16145 {}
16146};
Kailang Yangdf694da2005-12-05 19:42:22 +010016147
16148static int patch_alc861(struct hda_codec *codec)
16149{
16150 struct alc_spec *spec;
16151 int board_config;
16152 int err;
16153
Robert P. J. Daydc041e02006-12-19 14:44:15 +010016154 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010016155 if (spec == NULL)
16156 return -ENOMEM;
16157
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016158 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016159
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016160 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
16161 alc861_models,
16162 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016163
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016164 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016165 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16166 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010016167 board_config = ALC861_AUTO;
16168 }
16169
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016170 if (board_config == ALC861_AUTO)
16171 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 1);
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016172
Kailang Yangdf694da2005-12-05 19:42:22 +010016173 if (board_config == ALC861_AUTO) {
16174 /* automatic parse from the BIOS config */
16175 err = alc861_parse_auto_config(codec);
16176 if (err < 0) {
16177 alc_free(codec);
16178 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016179 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016180 printk(KERN_INFO
16181 "hda_codec: Cannot set up configuration "
16182 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010016183 board_config = ALC861_3ST_DIG;
16184 }
16185 }
16186
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016187 err = snd_hda_attach_beep_device(codec, 0x23);
16188 if (err < 0) {
16189 alc_free(codec);
16190 return err;
16191 }
16192
Kailang Yangdf694da2005-12-05 19:42:22 +010016193 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016194 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016195
Kailang Yangdf694da2005-12-05 19:42:22 +010016196 spec->stream_analog_playback = &alc861_pcm_analog_playback;
16197 spec->stream_analog_capture = &alc861_pcm_analog_capture;
16198
Kailang Yangdf694da2005-12-05 19:42:22 +010016199 spec->stream_digital_playback = &alc861_pcm_digital_playback;
16200 spec->stream_digital_capture = &alc861_pcm_digital_capture;
16201
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010016202 if (!spec->cap_mixer)
16203 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016204 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
16205
Takashi Iwai2134ea42008-01-10 16:53:55 +010016206 spec->vmaster_nid = 0x03;
16207
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016208 if (board_config == ALC861_AUTO)
16209 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 0);
16210
Kailang Yangdf694da2005-12-05 19:42:22 +010016211 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050016212 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016213 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016214#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050016215 spec->power_hook = alc_power_eapd;
16216#endif
16217 }
16218#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020016219 if (!spec->loopback.amplist)
16220 spec->loopback.amplist = alc861_loopbacks;
16221#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020016222
Kailang Yangdf694da2005-12-05 19:42:22 +010016223 return 0;
16224}
16225
16226/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016227 * ALC861-VD support
16228 *
16229 * Based on ALC882
16230 *
16231 * In addition, an independent DAC
16232 */
16233#define ALC861VD_DIGOUT_NID 0x06
16234
16235static hda_nid_t alc861vd_dac_nids[4] = {
16236 /* front, surr, clfe, side surr */
16237 0x02, 0x03, 0x04, 0x05
16238};
16239
16240/* dac_nids for ALC660vd are in a different order - according to
16241 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016242 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016243 * of ALC660vd codecs, but for now there is only 3stack mixer
16244 * - and it is the same as in 861vd.
16245 * adc_nids in ALC660vd are (is) the same as in 861vd
16246 */
16247static hda_nid_t alc660vd_dac_nids[3] = {
16248 /* front, rear, clfe, rear_surr */
16249 0x02, 0x04, 0x03
16250};
16251
16252static hda_nid_t alc861vd_adc_nids[1] = {
16253 /* ADC0 */
16254 0x09,
16255};
16256
Takashi Iwaie1406342008-02-11 18:32:32 +010016257static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
16258
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016259/* input MUX */
16260/* FIXME: should be a matrix-type input source selection */
16261static struct hda_input_mux alc861vd_capture_source = {
16262 .num_items = 4,
16263 .items = {
16264 { "Mic", 0x0 },
16265 { "Front Mic", 0x1 },
16266 { "Line", 0x2 },
16267 { "CD", 0x4 },
16268 },
16269};
16270
Kailang Yang272a5272007-05-14 11:00:38 +020016271static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016272 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016273 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010016274 { "Ext Mic", 0x0 },
16275 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016276 },
16277};
16278
Kailang Yangd1a991a2007-08-15 16:21:59 +020016279static struct hda_input_mux alc861vd_hp_capture_source = {
16280 .num_items = 2,
16281 .items = {
16282 { "Front Mic", 0x0 },
16283 { "ATAPI Mic", 0x1 },
16284 },
16285};
16286
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016287/*
16288 * 2ch mode
16289 */
16290static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16291 { 2, NULL }
16292};
16293
16294/*
16295 * 6ch mode
16296 */
16297static struct hda_verb alc861vd_6stack_ch6_init[] = {
16298 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16299 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16300 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16301 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16302 { } /* end */
16303};
16304
16305/*
16306 * 8ch mode
16307 */
16308static struct hda_verb alc861vd_6stack_ch8_init[] = {
16309 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16310 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16311 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16312 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16313 { } /* end */
16314};
16315
16316static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16317 { 6, alc861vd_6stack_ch6_init },
16318 { 8, alc861vd_6stack_ch8_init },
16319};
16320
16321static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16322 {
16323 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16324 .name = "Channel Mode",
16325 .info = alc_ch_mode_info,
16326 .get = alc_ch_mode_get,
16327 .put = alc_ch_mode_put,
16328 },
16329 { } /* end */
16330};
16331
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016332/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16333 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16334 */
16335static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16336 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16337 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16338
16339 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16340 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16341
16342 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16343 HDA_OUTPUT),
16344 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16345 HDA_OUTPUT),
16346 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16347 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16348
16349 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16350 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16351
16352 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16353
16354 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16355 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16356 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16357
16358 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16359 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16360 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16361
16362 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16363 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16364
16365 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16366 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16367
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016368 { } /* end */
16369};
16370
16371static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16372 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16373 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16374
16375 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16376
16377 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16378 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16379 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16380
16381 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16382 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16383 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16384
16385 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16386 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16387
16388 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16389 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16390
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016391 { } /* end */
16392};
16393
Kailang Yangbdd148a2007-05-08 15:19:08 +020016394static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16395 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16396 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16397 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16398
16399 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16400
16401 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16402 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16403 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16404
16405 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16406 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16407 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16408
16409 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16410 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16411
16412 { } /* end */
16413};
16414
Tobin Davisb419f342008-03-07 11:57:51 +010016415/* Pin assignment: Speaker=0x14, HP = 0x15,
16416 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016417 */
16418static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016419 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16420 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016421 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16422 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010016423 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16424 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16425 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16426 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16427 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16428 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016429 { } /* end */
16430};
16431
Kailang Yangd1a991a2007-08-15 16:21:59 +020016432/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16433 * Front Mic=0x18, ATAPI Mic = 0x19,
16434 */
16435static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16436 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16437 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16438 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16439 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16440 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16441 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16442 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16443 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016444
Kailang Yangd1a991a2007-08-15 16:21:59 +020016445 { } /* end */
16446};
16447
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016448/*
16449 * generic initialization of ADC, input mixers and output mixers
16450 */
16451static struct hda_verb alc861vd_volume_init_verbs[] = {
16452 /*
16453 * Unmute ADC0 and set the default input to mic-in
16454 */
16455 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16456 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16457
16458 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16459 * the analog-loopback mixer widget
16460 */
16461 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016462 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16463 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16464 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16465 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16466 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016467
16468 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016469 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16470 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16471 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016472 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016473
16474 /*
16475 * Set up output mixers (0x02 - 0x05)
16476 */
16477 /* set vol=0 to output mixers */
16478 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16479 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16480 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16481 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16482
16483 /* set up input amps for analog loopback */
16484 /* Amp Indices: DAC = 0, mixer = 1 */
16485 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16486 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16487 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16488 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16489 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16490 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16491 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16492 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16493
16494 { }
16495};
16496
16497/*
16498 * 3-stack pin configuration:
16499 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16500 */
16501static struct hda_verb alc861vd_3stack_init_verbs[] = {
16502 /*
16503 * Set pin mode and muting
16504 */
16505 /* set front pin widgets 0x14 for output */
16506 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16507 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16508 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16509
16510 /* Mic (rear) pin: input vref at 80% */
16511 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16512 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16513 /* Front Mic pin: input vref at 80% */
16514 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16515 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16516 /* Line In pin: input */
16517 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16518 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16519 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16520 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16521 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16522 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16523 /* CD pin widget for input */
16524 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16525
16526 { }
16527};
16528
16529/*
16530 * 6-stack pin configuration:
16531 */
16532static struct hda_verb alc861vd_6stack_init_verbs[] = {
16533 /*
16534 * Set pin mode and muting
16535 */
16536 /* set front pin widgets 0x14 for output */
16537 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16538 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16539 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16540
16541 /* Rear Pin: output 1 (0x0d) */
16542 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16543 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16544 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16545 /* CLFE Pin: output 2 (0x0e) */
16546 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16547 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16548 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16549 /* Side Pin: output 3 (0x0f) */
16550 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16551 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16552 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16553
16554 /* Mic (rear) pin: input vref at 80% */
16555 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16556 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16557 /* Front Mic pin: input vref at 80% */
16558 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16559 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16560 /* Line In pin: input */
16561 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16562 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16563 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16564 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16565 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16566 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16567 /* CD pin widget for input */
16568 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16569
16570 { }
16571};
16572
Kailang Yangbdd148a2007-05-08 15:19:08 +020016573static struct hda_verb alc861vd_eapd_verbs[] = {
16574 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16575 { }
16576};
16577
Kailang Yangf9423e72008-05-27 12:32:25 +020016578static struct hda_verb alc660vd_eapd_verbs[] = {
16579 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16580 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16581 { }
16582};
16583
Kailang Yangbdd148a2007-05-08 15:19:08 +020016584static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16585 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16586 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16587 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16588 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016589 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016590 {}
16591};
16592
Kailang Yangbdd148a2007-05-08 15:19:08 +020016593static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
16594{
16595 unsigned int present;
16596 unsigned char bits;
16597
Wu Fengguang864f92b2009-11-18 12:38:02 +080016598 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016599 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016600
Takashi Iwai47fd8302007-08-10 17:11:07 +020016601 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
16602 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016603}
16604
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016605static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016606{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016607 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016608 spec->autocfg.hp_pins[0] = 0x1b;
16609 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016610}
16611
16612static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16613{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016614 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016615 alc861vd_lenovo_mic_automute(codec);
16616}
16617
16618static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16619 unsigned int res)
16620{
16621 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016622 case ALC880_MIC_EVENT:
16623 alc861vd_lenovo_mic_automute(codec);
16624 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016625 default:
16626 alc_automute_amp_unsol_event(codec, res);
16627 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016628 }
16629}
16630
Kailang Yang272a5272007-05-14 11:00:38 +020016631static struct hda_verb alc861vd_dallas_verbs[] = {
16632 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16633 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16634 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16635 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16636
16637 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16638 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16639 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16640 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16641 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16642 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16643 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16644 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016645
Kailang Yang272a5272007-05-14 11:00:38 +020016646 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16647 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16648 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16649 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16650 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16651 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16652 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16653 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16654
16655 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16656 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16657 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16658 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16659 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16660 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16661 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16662 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16663
16664 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16665 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16666 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16667 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16668
16669 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016670 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016671 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16672
16673 { } /* end */
16674};
16675
16676/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016677static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016678{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016679 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016680
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016681 spec->autocfg.hp_pins[0] = 0x15;
16682 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016683}
16684
Takashi Iwaicb53c622007-08-10 17:21:45 +020016685#ifdef CONFIG_SND_HDA_POWER_SAVE
16686#define alc861vd_loopbacks alc880_loopbacks
16687#endif
16688
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016689/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016690#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16691#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16692#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16693#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16694
16695/*
16696 * configuration and preset
16697 */
16698static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
16699 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016700 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016701 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016702 [ALC861VD_3ST] = "3stack",
16703 [ALC861VD_3ST_DIG] = "3stack-digout",
16704 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016705 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016706 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016707 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016708 [ALC861VD_AUTO] = "auto",
16709};
16710
16711static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016712 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16713 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016714 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016715 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016716 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016717 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016718 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016719 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016720 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016721 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016722 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016723 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016724 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016725 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016726 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016727 {}
16728};
16729
16730static struct alc_config_preset alc861vd_presets[] = {
16731 [ALC660VD_3ST] = {
16732 .mixers = { alc861vd_3st_mixer },
16733 .init_verbs = { alc861vd_volume_init_verbs,
16734 alc861vd_3stack_init_verbs },
16735 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16736 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016737 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16738 .channel_mode = alc861vd_3stack_2ch_modes,
16739 .input_mux = &alc861vd_capture_source,
16740 },
Mike Crash6963f842007-06-25 12:12:51 +020016741 [ALC660VD_3ST_DIG] = {
16742 .mixers = { alc861vd_3st_mixer },
16743 .init_verbs = { alc861vd_volume_init_verbs,
16744 alc861vd_3stack_init_verbs },
16745 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16746 .dac_nids = alc660vd_dac_nids,
16747 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016748 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16749 .channel_mode = alc861vd_3stack_2ch_modes,
16750 .input_mux = &alc861vd_capture_source,
16751 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016752 [ALC861VD_3ST] = {
16753 .mixers = { alc861vd_3st_mixer },
16754 .init_verbs = { alc861vd_volume_init_verbs,
16755 alc861vd_3stack_init_verbs },
16756 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16757 .dac_nids = alc861vd_dac_nids,
16758 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16759 .channel_mode = alc861vd_3stack_2ch_modes,
16760 .input_mux = &alc861vd_capture_source,
16761 },
16762 [ALC861VD_3ST_DIG] = {
16763 .mixers = { alc861vd_3st_mixer },
16764 .init_verbs = { alc861vd_volume_init_verbs,
16765 alc861vd_3stack_init_verbs },
16766 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16767 .dac_nids = alc861vd_dac_nids,
16768 .dig_out_nid = ALC861VD_DIGOUT_NID,
16769 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16770 .channel_mode = alc861vd_3stack_2ch_modes,
16771 .input_mux = &alc861vd_capture_source,
16772 },
16773 [ALC861VD_6ST_DIG] = {
16774 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16775 .init_verbs = { alc861vd_volume_init_verbs,
16776 alc861vd_6stack_init_verbs },
16777 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16778 .dac_nids = alc861vd_dac_nids,
16779 .dig_out_nid = ALC861VD_DIGOUT_NID,
16780 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16781 .channel_mode = alc861vd_6stack_modes,
16782 .input_mux = &alc861vd_capture_source,
16783 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016784 [ALC861VD_LENOVO] = {
16785 .mixers = { alc861vd_lenovo_mixer },
16786 .init_verbs = { alc861vd_volume_init_verbs,
16787 alc861vd_3stack_init_verbs,
16788 alc861vd_eapd_verbs,
16789 alc861vd_lenovo_unsol_verbs },
16790 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16791 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016792 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16793 .channel_mode = alc861vd_3stack_2ch_modes,
16794 .input_mux = &alc861vd_capture_source,
16795 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016796 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016797 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016798 },
Kailang Yang272a5272007-05-14 11:00:38 +020016799 [ALC861VD_DALLAS] = {
16800 .mixers = { alc861vd_dallas_mixer },
16801 .init_verbs = { alc861vd_dallas_verbs },
16802 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16803 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016804 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16805 .channel_mode = alc861vd_3stack_2ch_modes,
16806 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016807 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016808 .setup = alc861vd_dallas_setup,
16809 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016810 },
16811 [ALC861VD_HP] = {
16812 .mixers = { alc861vd_hp_mixer },
16813 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16814 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16815 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016816 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016817 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16818 .channel_mode = alc861vd_3stack_2ch_modes,
16819 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016820 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016821 .setup = alc861vd_dallas_setup,
16822 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020016823 },
Takashi Iwai13c94742008-11-05 08:06:08 +010016824 [ALC660VD_ASUS_V1S] = {
16825 .mixers = { alc861vd_lenovo_mixer },
16826 .init_verbs = { alc861vd_volume_init_verbs,
16827 alc861vd_3stack_init_verbs,
16828 alc861vd_eapd_verbs,
16829 alc861vd_lenovo_unsol_verbs },
16830 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16831 .dac_nids = alc660vd_dac_nids,
16832 .dig_out_nid = ALC861VD_DIGOUT_NID,
16833 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16834 .channel_mode = alc861vd_3stack_2ch_modes,
16835 .input_mux = &alc861vd_capture_source,
16836 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016837 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016838 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010016839 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016840};
16841
16842/*
16843 * BIOS auto configuration
16844 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016845static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
16846 const struct auto_pin_cfg *cfg)
16847{
Kailang Yang6227cdc2010-02-25 08:36:52 +010016848 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020016849}
16850
16851
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016852static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
16853 hda_nid_t nid, int pin_type, int dac_idx)
16854{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016855 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016856}
16857
16858static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
16859{
16860 struct alc_spec *spec = codec->spec;
16861 int i;
16862
16863 for (i = 0; i <= HDA_SIDE; i++) {
16864 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016865 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016866 if (nid)
16867 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016868 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016869 }
16870}
16871
16872
16873static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
16874{
16875 struct alc_spec *spec = codec->spec;
16876 hda_nid_t pin;
16877
16878 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016879 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016880 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016881 pin = spec->autocfg.speaker_pins[0];
16882 if (pin)
16883 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016884}
16885
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016886#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
16887
16888static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
16889{
16890 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016891 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016892 int i;
16893
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016894 for (i = 0; i < cfg->num_inputs; i++) {
16895 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016896 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020016897 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +010016898 if (nid != ALC861VD_PIN_CD_NID &&
16899 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016900 snd_hda_codec_write(codec, nid, 0,
16901 AC_VERB_SET_AMP_GAIN_MUTE,
16902 AMP_OUT_MUTE);
16903 }
16904 }
16905}
16906
Takashi Iwaif511b012008-08-15 16:46:42 +020016907#define alc861vd_auto_init_input_src alc882_auto_init_input_src
16908
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016909#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
16910#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
16911
16912/* add playback controls from the parsed DAC table */
16913/* Based on ALC880 version. But ALC861VD has separate,
16914 * different NIDs for mute/unmute switch and volume control */
16915static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
16916 const struct auto_pin_cfg *cfg)
16917{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016918 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
16919 hda_nid_t nid_v, nid_s;
16920 int i, err;
16921
16922 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016923 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016924 continue;
16925 nid_v = alc861vd_idx_to_mixer_vol(
16926 alc880_dac_to_idx(
16927 spec->multiout.dac_nids[i]));
16928 nid_s = alc861vd_idx_to_mixer_switch(
16929 alc880_dac_to_idx(
16930 spec->multiout.dac_nids[i]));
16931
16932 if (i == 2) {
16933 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016934 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16935 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016936 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
16937 HDA_OUTPUT));
16938 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016939 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016940 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16941 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016942 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
16943 HDA_OUTPUT));
16944 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016945 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016946 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16947 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016948 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
16949 HDA_INPUT));
16950 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016951 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016952 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16953 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016954 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
16955 HDA_INPUT));
16956 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016957 return err;
16958 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016959 const char *pfx;
16960 if (cfg->line_outs == 1 &&
16961 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
16962 if (!cfg->hp_pins)
16963 pfx = "Speaker";
16964 else
16965 pfx = "PCM";
16966 } else
16967 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016968 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016969 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
16970 HDA_OUTPUT));
16971 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016972 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016973 if (cfg->line_outs == 1 &&
16974 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
16975 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016976 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016977 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016978 HDA_INPUT));
16979 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016980 return err;
16981 }
16982 }
16983 return 0;
16984}
16985
16986/* add playback controls for speaker and HP outputs */
16987/* Based on ALC880 version. But ALC861VD has separate,
16988 * different NIDs for mute/unmute switch and volume control */
16989static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
16990 hda_nid_t pin, const char *pfx)
16991{
16992 hda_nid_t nid_v, nid_s;
16993 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016994
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016995 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016996 return 0;
16997
16998 if (alc880_is_fixed_pin(pin)) {
16999 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17000 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017001 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017002 spec->multiout.hp_nid = nid_v;
17003 else
17004 spec->multiout.extra_out_nid[0] = nid_v;
17005 /* control HP volume/switch on the output mixer amp */
17006 nid_v = alc861vd_idx_to_mixer_vol(
17007 alc880_fixed_pin_idx(pin));
17008 nid_s = alc861vd_idx_to_mixer_switch(
17009 alc880_fixed_pin_idx(pin));
17010
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017011 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017012 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
17013 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017014 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017015 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017016 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
17017 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017018 return err;
17019 } else if (alc880_is_multi_pin(pin)) {
17020 /* set manual connection */
17021 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017022 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017023 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17024 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017025 return err;
17026 }
17027 return 0;
17028}
17029
17030/* parse the BIOS configuration and set up the alc_spec
17031 * return 1 if successful, 0 if the proper config is not found,
17032 * or a negative error code
17033 * Based on ALC880 version - had to change it to override
17034 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
17035static int alc861vd_parse_auto_config(struct hda_codec *codec)
17036{
17037 struct alc_spec *spec = codec->spec;
17038 int err;
17039 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
17040
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017041 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17042 alc861vd_ignore);
17043 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017044 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017045 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017046 return 0; /* can't find valid BIOS pin config */
17047
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017048 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17049 if (err < 0)
17050 return err;
17051 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
17052 if (err < 0)
17053 return err;
17054 err = alc861vd_auto_create_extra_out(spec,
17055 spec->autocfg.speaker_pins[0],
17056 "Speaker");
17057 if (err < 0)
17058 return err;
17059 err = alc861vd_auto_create_extra_out(spec,
17060 spec->autocfg.hp_pins[0],
17061 "Headphone");
17062 if (err < 0)
17063 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017064 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017065 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017066 return err;
17067
17068 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17069
Takashi Iwai757899a2010-07-30 10:48:14 +020017070 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017071
Takashi Iwai603c4012008-07-30 15:01:44 +020017072 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017073 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017074
Takashi Iwaid88897e2008-10-31 15:01:37 +010017075 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017076
17077 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017078 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017079
Takashi Iwai776e1842007-08-29 15:07:11 +020017080 err = alc_auto_add_mic_boost(codec);
17081 if (err < 0)
17082 return err;
17083
Kailang Yang6227cdc2010-02-25 08:36:52 +010017084 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017085
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017086 return 1;
17087}
17088
17089/* additional initialization for auto-configuration model */
17090static void alc861vd_auto_init(struct hda_codec *codec)
17091{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017092 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017093 alc861vd_auto_init_multi_out(codec);
17094 alc861vd_auto_init_hp_out(codec);
17095 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017096 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020017097 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017098 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017099 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017100}
17101
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017102enum {
17103 ALC660VD_FIX_ASUS_GPIO1
17104};
17105
17106/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017107static const struct alc_fixup alc861vd_fixups[] = {
17108 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020017109 .verbs = (const struct hda_verb[]) {
17110 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
17111 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
17112 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
17113 { }
17114 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017115 },
17116};
17117
17118static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
17119 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
17120 {}
17121};
17122
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017123static int patch_alc861vd(struct hda_codec *codec)
17124{
17125 struct alc_spec *spec;
17126 int err, board_config;
17127
17128 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17129 if (spec == NULL)
17130 return -ENOMEM;
17131
17132 codec->spec = spec;
17133
17134 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
17135 alc861vd_models,
17136 alc861vd_cfg_tbl);
17137
17138 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017139 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17140 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017141 board_config = ALC861VD_AUTO;
17142 }
17143
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017144 if (board_config == ALC861VD_AUTO)
17145 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 1);
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017146
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017147 if (board_config == ALC861VD_AUTO) {
17148 /* automatic parse from the BIOS config */
17149 err = alc861vd_parse_auto_config(codec);
17150 if (err < 0) {
17151 alc_free(codec);
17152 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017153 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017154 printk(KERN_INFO
17155 "hda_codec: Cannot set up configuration "
17156 "from BIOS. Using base mode...\n");
17157 board_config = ALC861VD_3ST;
17158 }
17159 }
17160
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017161 err = snd_hda_attach_beep_device(codec, 0x23);
17162 if (err < 0) {
17163 alc_free(codec);
17164 return err;
17165 }
17166
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017167 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017168 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017169
Kailang Yang2f893282008-05-27 12:14:47 +020017170 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020017171 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010017172 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020017173 }
17174
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017175 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
17176 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
17177
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017178 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
17179 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
17180
Takashi Iwaidd704692009-08-11 08:45:11 +020017181 if (!spec->adc_nids) {
17182 spec->adc_nids = alc861vd_adc_nids;
17183 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
17184 }
17185 if (!spec->capsrc_nids)
17186 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017187
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017188 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010017189 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017190
Takashi Iwai2134ea42008-01-10 16:53:55 +010017191 spec->vmaster_nid = 0x02;
17192
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017193 if (board_config == ALC861VD_AUTO)
17194 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 0);
17195
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017196 codec->patch_ops = alc_patch_ops;
17197
17198 if (board_config == ALC861VD_AUTO)
17199 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017200#ifdef CONFIG_SND_HDA_POWER_SAVE
17201 if (!spec->loopback.amplist)
17202 spec->loopback.amplist = alc861vd_loopbacks;
17203#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017204
17205 return 0;
17206}
17207
17208/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017209 * ALC662 support
17210 *
17211 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
17212 * configuration. Each pin widget can choose any input DACs and a mixer.
17213 * Each ADC is connected from a mixer of all inputs. This makes possible
17214 * 6-channel independent captures.
17215 *
17216 * In addition, an independent DAC for the multi-playback (not used in this
17217 * driver yet).
17218 */
17219#define ALC662_DIGOUT_NID 0x06
17220#define ALC662_DIGIN_NID 0x0a
17221
17222static hda_nid_t alc662_dac_nids[4] = {
17223 /* front, rear, clfe, rear_surr */
17224 0x02, 0x03, 0x04
17225};
17226
Kailang Yang622e84c2009-04-21 07:39:04 +020017227static hda_nid_t alc272_dac_nids[2] = {
17228 0x02, 0x03
17229};
17230
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017231static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017232 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017233 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017234};
Takashi Iwaie1406342008-02-11 18:32:32 +010017235
Kailang Yang622e84c2009-04-21 07:39:04 +020017236static hda_nid_t alc272_adc_nids[1] = {
17237 /* ADC1-2 */
17238 0x08,
17239};
17240
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017241static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020017242static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
17243
Takashi Iwaie1406342008-02-11 18:32:32 +010017244
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017245/* input MUX */
17246/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017247static struct hda_input_mux alc662_capture_source = {
17248 .num_items = 4,
17249 .items = {
17250 { "Mic", 0x0 },
17251 { "Front Mic", 0x1 },
17252 { "Line", 0x2 },
17253 { "CD", 0x4 },
17254 },
17255};
17256
17257static struct hda_input_mux alc662_lenovo_101e_capture_source = {
17258 .num_items = 2,
17259 .items = {
17260 { "Mic", 0x1 },
17261 { "Line", 0x2 },
17262 },
17263};
Kailang Yang291702f2007-10-16 14:28:03 +020017264
Kailang Yang6dda9f42008-05-27 12:05:31 +020017265static struct hda_input_mux alc663_capture_source = {
17266 .num_items = 3,
17267 .items = {
17268 { "Mic", 0x0 },
17269 { "Front Mic", 0x1 },
17270 { "Line", 0x2 },
17271 },
17272};
17273
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017274#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020017275static struct hda_input_mux alc272_nc10_capture_source = {
17276 .num_items = 16,
17277 .items = {
17278 { "Autoselect Mic", 0x0 },
17279 { "Internal Mic", 0x1 },
17280 { "In-0x02", 0x2 },
17281 { "In-0x03", 0x3 },
17282 { "In-0x04", 0x4 },
17283 { "In-0x05", 0x5 },
17284 { "In-0x06", 0x6 },
17285 { "In-0x07", 0x7 },
17286 { "In-0x08", 0x8 },
17287 { "In-0x09", 0x9 },
17288 { "In-0x0a", 0x0a },
17289 { "In-0x0b", 0x0b },
17290 { "In-0x0c", 0x0c },
17291 { "In-0x0d", 0x0d },
17292 { "In-0x0e", 0x0e },
17293 { "In-0x0f", 0x0f },
17294 },
17295};
17296#endif
17297
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017298/*
17299 * 2ch mode
17300 */
17301static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17302 { 2, NULL }
17303};
17304
17305/*
17306 * 2ch mode
17307 */
17308static struct hda_verb alc662_3ST_ch2_init[] = {
17309 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17310 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17311 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17312 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17313 { } /* end */
17314};
17315
17316/*
17317 * 6ch mode
17318 */
17319static struct hda_verb alc662_3ST_ch6_init[] = {
17320 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17321 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17322 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17323 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17324 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17325 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17326 { } /* end */
17327};
17328
17329static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17330 { 2, alc662_3ST_ch2_init },
17331 { 6, alc662_3ST_ch6_init },
17332};
17333
17334/*
17335 * 2ch mode
17336 */
17337static struct hda_verb alc662_sixstack_ch6_init[] = {
17338 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17339 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17340 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17341 { } /* end */
17342};
17343
17344/*
17345 * 6ch mode
17346 */
17347static struct hda_verb alc662_sixstack_ch8_init[] = {
17348 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17349 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17350 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17351 { } /* end */
17352};
17353
17354static struct hda_channel_mode alc662_5stack_modes[2] = {
17355 { 2, alc662_sixstack_ch6_init },
17356 { 6, alc662_sixstack_ch8_init },
17357};
17358
17359/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17360 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17361 */
17362
17363static struct snd_kcontrol_new alc662_base_mixer[] = {
17364 /* output mixer control */
17365 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017366 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017367 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017368 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017369 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17370 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017371 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17372 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017373 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17374
17375 /*Input mixer control */
17376 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17377 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17378 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17379 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17380 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17381 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17382 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17383 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017384 { } /* end */
17385};
17386
17387static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17388 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017389 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017390 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17391 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17392 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17393 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17394 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17395 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17396 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17397 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17398 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017399 { } /* end */
17400};
17401
17402static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17403 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017404 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017405 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017406 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017407 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17408 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017409 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17410 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017411 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17412 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17413 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17414 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17415 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17416 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17417 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17418 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17419 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017420 { } /* end */
17421};
17422
17423static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17424 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17425 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017426 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17427 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017428 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17429 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17430 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17431 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17432 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017433 { } /* end */
17434};
17435
Kailang Yang291702f2007-10-16 14:28:03 +020017436static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017437 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17438 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017439
17440 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
17441 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17442 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17443
17444 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17445 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17446 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17447 { } /* end */
17448};
17449
Kailang Yang8c427222008-01-10 13:03:59 +010017450static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017451 ALC262_HIPPO_MASTER_SWITCH,
17452 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017453 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017454 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17455 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017456 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17457 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17458 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17459 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17460 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17461 { } /* end */
17462};
17463
Kailang Yangf1d4e282008-08-26 14:03:29 +020017464static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17465 .ops = &snd_hda_bind_vol,
17466 .values = {
17467 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17468 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17469 0
17470 },
17471};
17472
17473static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17474 .ops = &snd_hda_bind_sw,
17475 .values = {
17476 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17477 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17478 0
17479 },
17480};
17481
Kailang Yang6dda9f42008-05-27 12:05:31 +020017482static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017483 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17484 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17485 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17486 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17487 { } /* end */
17488};
17489
17490static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17491 .ops = &snd_hda_bind_sw,
17492 .values = {
17493 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17494 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17495 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17496 0
17497 },
17498};
17499
17500static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17501 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17502 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17503 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17504 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17505 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17506 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17507
17508 { } /* end */
17509};
17510
17511static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17512 .ops = &snd_hda_bind_sw,
17513 .values = {
17514 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17515 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17516 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17517 0
17518 },
17519};
17520
17521static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17522 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17523 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17524 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17525 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17526 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17527 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17528 { } /* end */
17529};
17530
17531static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017532 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17533 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017534 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17535 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17536 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17537 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17538 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17539 { } /* end */
17540};
17541
17542static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17543 .ops = &snd_hda_bind_vol,
17544 .values = {
17545 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17546 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17547 0
17548 },
17549};
17550
17551static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17552 .ops = &snd_hda_bind_sw,
17553 .values = {
17554 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17555 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17556 0
17557 },
17558};
17559
17560static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17561 HDA_BIND_VOL("Master Playback Volume",
17562 &alc663_asus_two_bind_master_vol),
17563 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17564 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017565 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17566 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17567 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017568 { } /* end */
17569};
17570
17571static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17572 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17573 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17574 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17575 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17576 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17577 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017578 { } /* end */
17579};
17580
17581static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17582 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17583 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17584 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17585 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17586 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17587
17588 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17589 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17590 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17591 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17592 { } /* end */
17593};
17594
17595static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17596 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17597 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17598 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17599
17600 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17601 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17602 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17603 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17604 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17605 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17606 { } /* end */
17607};
17608
Kailang Yangebb83ee2009-12-17 12:23:00 +010017609static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17610 .ops = &snd_hda_bind_sw,
17611 .values = {
17612 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17613 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17614 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17615 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17616 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17617 0
17618 },
17619};
17620
17621static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17622 .ops = &snd_hda_bind_sw,
17623 .values = {
17624 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17625 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17626 0
17627 },
17628};
17629
17630static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17631 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17632 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17633 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17634 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17635 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17636 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17637 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17638 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17639 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17640 { } /* end */
17641};
17642
17643static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17644 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17645 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17646 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17647 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17648 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17649 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17650 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17651 { } /* end */
17652};
17653
17654
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017655static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17656 {
17657 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17658 .name = "Channel Mode",
17659 .info = alc_ch_mode_info,
17660 .get = alc_ch_mode_get,
17661 .put = alc_ch_mode_put,
17662 },
17663 { } /* end */
17664};
17665
17666static struct hda_verb alc662_init_verbs[] = {
17667 /* ADC: mute amp left and right */
17668 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17669 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017670
Kailang Yangb60dd392007-09-20 12:50:29 +020017671 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17672 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17673 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17674 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17675 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17676 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017677
17678 /* Front Pin: output 0 (0x0c) */
17679 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17680 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17681
17682 /* Rear Pin: output 1 (0x0d) */
17683 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17684 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17685
17686 /* CLFE Pin: output 2 (0x0e) */
17687 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17688 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17689
17690 /* Mic (rear) pin: input vref at 80% */
17691 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17692 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17693 /* Front Mic pin: input vref at 80% */
17694 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17695 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17696 /* Line In pin: input */
17697 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17698 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17699 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17700 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17701 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17702 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17703 /* CD pin widget for input */
17704 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17705
17706 /* FIXME: use matrix-type input source selection */
17707 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17708 /* Input mixer */
17709 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017710 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017711
17712 /* always trun on EAPD */
17713 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17714 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17715
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017716 { }
17717};
17718
Kailang Yangcec27c82010-02-04 14:18:18 +010017719static struct hda_verb alc663_init_verbs[] = {
17720 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17721 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17722 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17723 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17724 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17725 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17726 { }
17727};
17728
17729static struct hda_verb alc272_init_verbs[] = {
17730 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17731 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17732 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17733 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17734 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17735 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17736 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17737 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17738 { }
17739};
17740
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017741static struct hda_verb alc662_sue_init_verbs[] = {
17742 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17743 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017744 {}
17745};
17746
17747static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17748 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17749 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17750 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017751};
17752
Kailang Yang8c427222008-01-10 13:03:59 +010017753/* Set Unsolicited Event*/
17754static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17755 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17756 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17757 {}
17758};
17759
Kailang Yang6dda9f42008-05-27 12:05:31 +020017760static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017761 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17762 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017763 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17764 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017765 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17766 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17767 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017768 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17769 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17770 {}
17771};
17772
Kailang Yangf1d4e282008-08-26 14:03:29 +020017773static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17774 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17775 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17776 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17777 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17778 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17779 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17780 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17781 {}
17782};
17783
17784static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17785 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17786 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17787 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17788 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17789 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17790 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17791 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17792 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17793 {}
17794};
17795
17796static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17797 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17798 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17799 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17800 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17801 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17802 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17803 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17804 {}
17805};
17806
17807static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17808 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17809 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17810 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17811 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17812 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17813 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17814 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17815 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17816 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17817 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17818 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17819 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17820 {}
17821};
17822
17823static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
17824 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17825 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17826 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17827 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17828 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17829 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17830 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17831 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17832 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17833 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17834 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17835 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17836 {}
17837};
17838
Kailang Yang6dda9f42008-05-27 12:05:31 +020017839static struct hda_verb alc663_g71v_init_verbs[] = {
17840 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17841 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
17842 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
17843
17844 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17845 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17846 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17847
17848 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17849 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
17850 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17851 {}
17852};
17853
17854static struct hda_verb alc663_g50v_init_verbs[] = {
17855 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17856 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17857 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17858
17859 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17860 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17861 {}
17862};
17863
Kailang Yangf1d4e282008-08-26 14:03:29 +020017864static struct hda_verb alc662_ecs_init_verbs[] = {
17865 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
17866 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17867 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17868 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17869 {}
17870};
17871
Kailang Yang622e84c2009-04-21 07:39:04 +020017872static struct hda_verb alc272_dell_zm1_init_verbs[] = {
17873 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17874 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17875 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17876 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17877 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17878 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17879 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17880 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17881 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17882 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17883 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17884 {}
17885};
17886
17887static struct hda_verb alc272_dell_init_verbs[] = {
17888 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17889 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17890 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17891 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17892 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17893 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17894 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17895 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17896 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17897 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17898 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17899 {}
17900};
17901
Kailang Yangebb83ee2009-12-17 12:23:00 +010017902static struct hda_verb alc663_mode7_init_verbs[] = {
17903 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17904 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17905 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17906 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17907 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17908 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17909 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
17910 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17911 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17912 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17913 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17914 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17915 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17916 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17917 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17918 {}
17919};
17920
17921static struct hda_verb alc663_mode8_init_verbs[] = {
17922 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17923 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17924 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17925 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
17926 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17927 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17928 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17929 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17930 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17931 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17932 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17933 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17934 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17935 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17936 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17937 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17938 {}
17939};
17940
Kailang Yangf1d4e282008-08-26 14:03:29 +020017941static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
17942 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
17943 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
17944 { } /* end */
17945};
17946
Kailang Yang622e84c2009-04-21 07:39:04 +020017947static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
17948 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
17949 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
17950 { } /* end */
17951};
17952
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017953static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
17954{
17955 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017956 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017957
Wu Fengguang864f92b2009-11-18 12:38:02 +080017958 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017959 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017960
Takashi Iwai47fd8302007-08-10 17:11:07 +020017961 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17962 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017963}
17964
17965static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
17966{
17967 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017968 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017969
Wu Fengguang864f92b2009-11-18 12:38:02 +080017970 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017971 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017972
Takashi Iwai47fd8302007-08-10 17:11:07 +020017973 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17974 HDA_AMP_MUTE, bits);
17975 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17976 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017977}
17978
17979static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
17980 unsigned int res)
17981{
17982 if ((res >> 26) == ALC880_HP_EVENT)
17983 alc662_lenovo_101e_all_automute(codec);
17984 if ((res >> 26) == ALC880_FRONT_EVENT)
17985 alc662_lenovo_101e_ispeaker_automute(codec);
17986}
17987
Kailang Yang291702f2007-10-16 14:28:03 +020017988/* unsolicited event for HP jack sensing */
17989static void alc662_eeepc_unsol_event(struct hda_codec *codec,
17990 unsigned int res)
17991{
Kailang Yang291702f2007-10-16 14:28:03 +020017992 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017993 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020017994 else
17995 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020017996}
17997
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017998static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020017999{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018000 struct alc_spec *spec = codec->spec;
18001
18002 alc262_hippo1_setup(codec);
18003 spec->ext_mic.pin = 0x18;
18004 spec->ext_mic.mux_idx = 0;
18005 spec->int_mic.pin = 0x19;
18006 spec->int_mic.mux_idx = 1;
18007 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020018008}
18009
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018010static void alc662_eeepc_inithook(struct hda_codec *codec)
18011{
18012 alc262_hippo_automute(codec);
18013 alc_mic_automute(codec);
18014}
18015
18016static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010018017{
Takashi Iwai42171c12009-05-08 14:11:43 +020018018 struct alc_spec *spec = codec->spec;
18019
18020 spec->autocfg.hp_pins[0] = 0x14;
18021 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010018022}
18023
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018024#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
18025
Kailang Yang6dda9f42008-05-27 12:05:31 +020018026static void alc663_m51va_speaker_automute(struct hda_codec *codec)
18027{
18028 unsigned int present;
18029 unsigned char bits;
18030
Wu Fengguang864f92b2009-11-18 12:38:02 +080018031 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018032 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018033 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018034 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018035 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018036 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018037}
18038
18039static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
18040{
18041 unsigned int present;
18042 unsigned char bits;
18043
Wu Fengguang864f92b2009-11-18 12:38:02 +080018044 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018045 bits = present ? HDA_AMP_MUTE : 0;
18046 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018047 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018048 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018049 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018050 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018051 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018052 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018053 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018054}
18055
18056static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
18057{
18058 unsigned int present;
18059 unsigned char bits;
18060
Wu Fengguang864f92b2009-11-18 12:38:02 +080018061 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018062 bits = present ? HDA_AMP_MUTE : 0;
18063 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018064 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018065 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018066 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018067 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018068 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018069 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018070 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018071}
18072
18073static void alc662_f5z_speaker_automute(struct hda_codec *codec)
18074{
18075 unsigned int present;
18076 unsigned char bits;
18077
Wu Fengguang864f92b2009-11-18 12:38:02 +080018078 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018079 bits = present ? 0 : PIN_OUT;
18080 snd_hda_codec_write(codec, 0x14, 0,
18081 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
18082}
18083
18084static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
18085{
18086 unsigned int present1, present2;
18087
Wu Fengguang864f92b2009-11-18 12:38:02 +080018088 present1 = snd_hda_jack_detect(codec, 0x21);
18089 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018090
18091 if (present1 || present2) {
18092 snd_hda_codec_write_cache(codec, 0x14, 0,
18093 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18094 } else {
18095 snd_hda_codec_write_cache(codec, 0x14, 0,
18096 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18097 }
18098}
18099
18100static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
18101{
18102 unsigned int present1, present2;
18103
Wu Fengguang864f92b2009-11-18 12:38:02 +080018104 present1 = snd_hda_jack_detect(codec, 0x1b);
18105 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018106
18107 if (present1 || present2) {
18108 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018109 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018110 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018111 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018112 } else {
18113 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018114 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018115 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018116 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018117 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020018118}
18119
Kailang Yangebb83ee2009-12-17 12:23:00 +010018120static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
18121{
18122 unsigned int present1, present2;
18123
18124 present1 = snd_hda_codec_read(codec, 0x1b, 0,
18125 AC_VERB_GET_PIN_SENSE, 0)
18126 & AC_PINSENSE_PRESENCE;
18127 present2 = snd_hda_codec_read(codec, 0x21, 0,
18128 AC_VERB_GET_PIN_SENSE, 0)
18129 & AC_PINSENSE_PRESENCE;
18130
18131 if (present1 || present2) {
18132 snd_hda_codec_write_cache(codec, 0x14, 0,
18133 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18134 snd_hda_codec_write_cache(codec, 0x17, 0,
18135 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18136 } else {
18137 snd_hda_codec_write_cache(codec, 0x14, 0,
18138 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18139 snd_hda_codec_write_cache(codec, 0x17, 0,
18140 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18141 }
18142}
18143
18144static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
18145{
18146 unsigned int present1, present2;
18147
18148 present1 = snd_hda_codec_read(codec, 0x21, 0,
18149 AC_VERB_GET_PIN_SENSE, 0)
18150 & AC_PINSENSE_PRESENCE;
18151 present2 = snd_hda_codec_read(codec, 0x15, 0,
18152 AC_VERB_GET_PIN_SENSE, 0)
18153 & AC_PINSENSE_PRESENCE;
18154
18155 if (present1 || present2) {
18156 snd_hda_codec_write_cache(codec, 0x14, 0,
18157 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18158 snd_hda_codec_write_cache(codec, 0x17, 0,
18159 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18160 } else {
18161 snd_hda_codec_write_cache(codec, 0x14, 0,
18162 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18163 snd_hda_codec_write_cache(codec, 0x17, 0,
18164 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18165 }
18166}
18167
Kailang Yang6dda9f42008-05-27 12:05:31 +020018168static void alc663_m51va_unsol_event(struct hda_codec *codec,
18169 unsigned int res)
18170{
18171 switch (res >> 26) {
18172 case ALC880_HP_EVENT:
18173 alc663_m51va_speaker_automute(codec);
18174 break;
18175 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018176 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018177 break;
18178 }
18179}
18180
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018181static void alc663_m51va_setup(struct hda_codec *codec)
18182{
18183 struct alc_spec *spec = codec->spec;
18184 spec->ext_mic.pin = 0x18;
18185 spec->ext_mic.mux_idx = 0;
18186 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018187 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018188 spec->auto_mic = 1;
18189}
18190
Kailang Yang6dda9f42008-05-27 12:05:31 +020018191static void alc663_m51va_inithook(struct hda_codec *codec)
18192{
18193 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018194 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018195}
18196
Kailang Yangf1d4e282008-08-26 14:03:29 +020018197/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018198#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010018199
18200static void alc663_mode1_setup(struct hda_codec *codec)
18201{
18202 struct alc_spec *spec = codec->spec;
18203 spec->ext_mic.pin = 0x18;
18204 spec->ext_mic.mux_idx = 0;
18205 spec->int_mic.pin = 0x19;
18206 spec->int_mic.mux_idx = 1;
18207 spec->auto_mic = 1;
18208}
18209
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018210#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020018211
Kailang Yangf1d4e282008-08-26 14:03:29 +020018212/* ***************** Mode2 ******************************/
18213static void alc662_mode2_unsol_event(struct hda_codec *codec,
18214 unsigned int res)
18215{
18216 switch (res >> 26) {
18217 case ALC880_HP_EVENT:
18218 alc662_f5z_speaker_automute(codec);
18219 break;
18220 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018221 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018222 break;
18223 }
18224}
18225
Kailang Yangebb83ee2009-12-17 12:23:00 +010018226#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018227
Kailang Yangf1d4e282008-08-26 14:03:29 +020018228static void alc662_mode2_inithook(struct hda_codec *codec)
18229{
18230 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018231 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018232}
18233/* ***************** Mode3 ******************************/
18234static void alc663_mode3_unsol_event(struct hda_codec *codec,
18235 unsigned int res)
18236{
18237 switch (res >> 26) {
18238 case ALC880_HP_EVENT:
18239 alc663_two_hp_m1_speaker_automute(codec);
18240 break;
18241 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018242 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018243 break;
18244 }
18245}
18246
Kailang Yangebb83ee2009-12-17 12:23:00 +010018247#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018248
Kailang Yangf1d4e282008-08-26 14:03:29 +020018249static void alc663_mode3_inithook(struct hda_codec *codec)
18250{
18251 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018252 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018253}
18254/* ***************** Mode4 ******************************/
18255static void alc663_mode4_unsol_event(struct hda_codec *codec,
18256 unsigned int res)
18257{
18258 switch (res >> 26) {
18259 case ALC880_HP_EVENT:
18260 alc663_21jd_two_speaker_automute(codec);
18261 break;
18262 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018263 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018264 break;
18265 }
18266}
18267
Kailang Yangebb83ee2009-12-17 12:23:00 +010018268#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018269
Kailang Yangf1d4e282008-08-26 14:03:29 +020018270static void alc663_mode4_inithook(struct hda_codec *codec)
18271{
18272 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018273 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018274}
18275/* ***************** Mode5 ******************************/
18276static void alc663_mode5_unsol_event(struct hda_codec *codec,
18277 unsigned int res)
18278{
18279 switch (res >> 26) {
18280 case ALC880_HP_EVENT:
18281 alc663_15jd_two_speaker_automute(codec);
18282 break;
18283 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018284 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018285 break;
18286 }
18287}
18288
Kailang Yangebb83ee2009-12-17 12:23:00 +010018289#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018290
Kailang Yangf1d4e282008-08-26 14:03:29 +020018291static void alc663_mode5_inithook(struct hda_codec *codec)
18292{
18293 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018294 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018295}
18296/* ***************** Mode6 ******************************/
18297static void alc663_mode6_unsol_event(struct hda_codec *codec,
18298 unsigned int res)
18299{
18300 switch (res >> 26) {
18301 case ALC880_HP_EVENT:
18302 alc663_two_hp_m2_speaker_automute(codec);
18303 break;
18304 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018305 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018306 break;
18307 }
18308}
18309
Kailang Yangebb83ee2009-12-17 12:23:00 +010018310#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018311
Kailang Yangf1d4e282008-08-26 14:03:29 +020018312static void alc663_mode6_inithook(struct hda_codec *codec)
18313{
18314 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018315 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018316}
18317
Kailang Yangebb83ee2009-12-17 12:23:00 +010018318/* ***************** Mode7 ******************************/
18319static void alc663_mode7_unsol_event(struct hda_codec *codec,
18320 unsigned int res)
18321{
18322 switch (res >> 26) {
18323 case ALC880_HP_EVENT:
18324 alc663_two_hp_m7_speaker_automute(codec);
18325 break;
18326 case ALC880_MIC_EVENT:
18327 alc_mic_automute(codec);
18328 break;
18329 }
18330}
18331
18332#define alc663_mode7_setup alc663_mode1_setup
18333
18334static void alc663_mode7_inithook(struct hda_codec *codec)
18335{
18336 alc663_two_hp_m7_speaker_automute(codec);
18337 alc_mic_automute(codec);
18338}
18339
18340/* ***************** Mode8 ******************************/
18341static void alc663_mode8_unsol_event(struct hda_codec *codec,
18342 unsigned int res)
18343{
18344 switch (res >> 26) {
18345 case ALC880_HP_EVENT:
18346 alc663_two_hp_m8_speaker_automute(codec);
18347 break;
18348 case ALC880_MIC_EVENT:
18349 alc_mic_automute(codec);
18350 break;
18351 }
18352}
18353
18354#define alc663_mode8_setup alc663_m51va_setup
18355
18356static void alc663_mode8_inithook(struct hda_codec *codec)
18357{
18358 alc663_two_hp_m8_speaker_automute(codec);
18359 alc_mic_automute(codec);
18360}
18361
Kailang Yang6dda9f42008-05-27 12:05:31 +020018362static void alc663_g71v_hp_automute(struct hda_codec *codec)
18363{
18364 unsigned int present;
18365 unsigned char bits;
18366
Wu Fengguang864f92b2009-11-18 12:38:02 +080018367 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018368 bits = present ? HDA_AMP_MUTE : 0;
18369 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18370 HDA_AMP_MUTE, bits);
18371 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18372 HDA_AMP_MUTE, bits);
18373}
18374
18375static void alc663_g71v_front_automute(struct hda_codec *codec)
18376{
18377 unsigned int present;
18378 unsigned char bits;
18379
Wu Fengguang864f92b2009-11-18 12:38:02 +080018380 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018381 bits = present ? HDA_AMP_MUTE : 0;
18382 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18383 HDA_AMP_MUTE, bits);
18384}
18385
18386static void alc663_g71v_unsol_event(struct hda_codec *codec,
18387 unsigned int res)
18388{
18389 switch (res >> 26) {
18390 case ALC880_HP_EVENT:
18391 alc663_g71v_hp_automute(codec);
18392 break;
18393 case ALC880_FRONT_EVENT:
18394 alc663_g71v_front_automute(codec);
18395 break;
18396 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018397 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018398 break;
18399 }
18400}
18401
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018402#define alc663_g71v_setup alc663_m51va_setup
18403
Kailang Yang6dda9f42008-05-27 12:05:31 +020018404static void alc663_g71v_inithook(struct hda_codec *codec)
18405{
18406 alc663_g71v_front_automute(codec);
18407 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018408 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018409}
18410
18411static void alc663_g50v_unsol_event(struct hda_codec *codec,
18412 unsigned int res)
18413{
18414 switch (res >> 26) {
18415 case ALC880_HP_EVENT:
18416 alc663_m51va_speaker_automute(codec);
18417 break;
18418 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018419 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018420 break;
18421 }
18422}
18423
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018424#define alc663_g50v_setup alc663_m51va_setup
18425
Kailang Yang6dda9f42008-05-27 12:05:31 +020018426static void alc663_g50v_inithook(struct hda_codec *codec)
18427{
18428 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018429 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018430}
18431
Kailang Yangf1d4e282008-08-26 14:03:29 +020018432static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18433 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018434 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018435
18436 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
18437 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18438 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
18439
18440 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
18441 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18442 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18443 { } /* end */
18444};
18445
Chris Pockelé9541ba12009-05-12 08:08:53 +020018446static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18447 /* Master Playback automatically created from Speaker and Headphone */
18448 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18449 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18450 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18451 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18452
18453 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18454 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
18455 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
18456
18457 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18458 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18459 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
18460 { } /* end */
18461};
18462
Takashi Iwaicb53c622007-08-10 17:21:45 +020018463#ifdef CONFIG_SND_HDA_POWER_SAVE
18464#define alc662_loopbacks alc880_loopbacks
18465#endif
18466
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018467
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018468/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018469#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18470#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18471#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18472#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18473
18474/*
18475 * configuration and preset
18476 */
18477static const char *alc662_models[ALC662_MODEL_LAST] = {
18478 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18479 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18480 [ALC662_3ST_6ch] = "3stack-6ch",
18481 [ALC662_5ST_DIG] = "6stack-dig",
18482 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018483 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018484 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018485 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018486 [ALC663_ASUS_M51VA] = "m51va",
18487 [ALC663_ASUS_G71V] = "g71v",
18488 [ALC663_ASUS_H13] = "h13",
18489 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018490 [ALC663_ASUS_MODE1] = "asus-mode1",
18491 [ALC662_ASUS_MODE2] = "asus-mode2",
18492 [ALC663_ASUS_MODE3] = "asus-mode3",
18493 [ALC663_ASUS_MODE4] = "asus-mode4",
18494 [ALC663_ASUS_MODE5] = "asus-mode5",
18495 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018496 [ALC663_ASUS_MODE7] = "asus-mode7",
18497 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018498 [ALC272_DELL] = "dell",
18499 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018500 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018501 [ALC662_AUTO] = "auto",
18502};
18503
18504static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018505 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018506 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18507 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018508 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18509 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018510 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018511 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18512 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18513 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18514 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018515 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18516 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018517 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018518 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18519 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18520 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18521 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18522 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018523 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018524 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18525 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018526 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18527 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18528 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18529 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018530 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018531 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18532 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18533 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018534 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18535 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18536 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18537 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018538 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018539 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18540 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018541 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018542 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18543 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18544 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018545 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018546 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018547 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18548 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018549 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18550 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18551 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018552 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018553 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18554 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018555 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018556 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018557 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018558 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18559 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18560 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018561 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018562 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18563 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018564 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018565 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018566 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018567 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018568 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18569 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018570 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018571 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018572 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18573 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018574 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018575 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018576 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018577 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018578 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018579 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018580 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18581 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018582 {}
18583};
18584
18585static struct alc_config_preset alc662_presets[] = {
18586 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018587 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018588 .init_verbs = { alc662_init_verbs },
18589 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18590 .dac_nids = alc662_dac_nids,
18591 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018592 .dig_in_nid = ALC662_DIGIN_NID,
18593 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18594 .channel_mode = alc662_3ST_2ch_modes,
18595 .input_mux = &alc662_capture_source,
18596 },
18597 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018598 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018599 .init_verbs = { alc662_init_verbs },
18600 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18601 .dac_nids = alc662_dac_nids,
18602 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018603 .dig_in_nid = ALC662_DIGIN_NID,
18604 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18605 .channel_mode = alc662_3ST_6ch_modes,
18606 .need_dac_fix = 1,
18607 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018608 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018609 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018610 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018611 .init_verbs = { alc662_init_verbs },
18612 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18613 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018614 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18615 .channel_mode = alc662_3ST_6ch_modes,
18616 .need_dac_fix = 1,
18617 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018618 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018619 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018620 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018621 .init_verbs = { alc662_init_verbs },
18622 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18623 .dac_nids = alc662_dac_nids,
18624 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018625 .dig_in_nid = ALC662_DIGIN_NID,
18626 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18627 .channel_mode = alc662_5stack_modes,
18628 .input_mux = &alc662_capture_source,
18629 },
18630 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018631 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018632 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18633 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18634 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018635 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18636 .channel_mode = alc662_3ST_2ch_modes,
18637 .input_mux = &alc662_lenovo_101e_capture_source,
18638 .unsol_event = alc662_lenovo_101e_unsol_event,
18639 .init_hook = alc662_lenovo_101e_all_automute,
18640 },
Kailang Yang291702f2007-10-16 14:28:03 +020018641 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018642 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018643 .init_verbs = { alc662_init_verbs,
18644 alc662_eeepc_sue_init_verbs },
18645 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18646 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018647 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18648 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018649 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018650 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018651 .init_hook = alc662_eeepc_inithook,
18652 },
Kailang Yang8c427222008-01-10 13:03:59 +010018653 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018654 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018655 alc662_chmode_mixer },
18656 .init_verbs = { alc662_init_verbs,
18657 alc662_eeepc_ep20_sue_init_verbs },
18658 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18659 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018660 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18661 .channel_mode = alc662_3ST_6ch_modes,
18662 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018663 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018664 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018665 .init_hook = alc662_eeepc_ep20_inithook,
18666 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018667 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018668 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018669 .init_verbs = { alc662_init_verbs,
18670 alc662_ecs_init_verbs },
18671 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18672 .dac_nids = alc662_dac_nids,
18673 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18674 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018675 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018676 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018677 .init_hook = alc662_eeepc_inithook,
18678 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018679 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018680 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018681 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18682 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18683 .dac_nids = alc662_dac_nids,
18684 .dig_out_nid = ALC662_DIGOUT_NID,
18685 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18686 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018687 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018688 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018689 .init_hook = alc663_m51va_inithook,
18690 },
18691 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018692 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018693 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18694 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18695 .dac_nids = alc662_dac_nids,
18696 .dig_out_nid = ALC662_DIGOUT_NID,
18697 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18698 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018699 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018700 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018701 .init_hook = alc663_g71v_inithook,
18702 },
18703 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018704 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018705 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18706 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18707 .dac_nids = alc662_dac_nids,
18708 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18709 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018710 .unsol_event = alc663_m51va_unsol_event,
18711 .init_hook = alc663_m51va_inithook,
18712 },
18713 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018714 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018715 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18716 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18717 .dac_nids = alc662_dac_nids,
18718 .dig_out_nid = ALC662_DIGOUT_NID,
18719 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18720 .channel_mode = alc662_3ST_6ch_modes,
18721 .input_mux = &alc663_capture_source,
18722 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018723 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018724 .init_hook = alc663_g50v_inithook,
18725 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018726 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018727 .mixers = { alc663_m51va_mixer },
18728 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018729 .init_verbs = { alc662_init_verbs,
18730 alc663_21jd_amic_init_verbs },
18731 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18732 .hp_nid = 0x03,
18733 .dac_nids = alc662_dac_nids,
18734 .dig_out_nid = ALC662_DIGOUT_NID,
18735 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18736 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018737 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018738 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018739 .init_hook = alc663_mode1_inithook,
18740 },
18741 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018742 .mixers = { alc662_1bjd_mixer },
18743 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018744 .init_verbs = { alc662_init_verbs,
18745 alc662_1bjd_amic_init_verbs },
18746 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18747 .dac_nids = alc662_dac_nids,
18748 .dig_out_nid = ALC662_DIGOUT_NID,
18749 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18750 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018751 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018752 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018753 .init_hook = alc662_mode2_inithook,
18754 },
18755 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018756 .mixers = { alc663_two_hp_m1_mixer },
18757 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018758 .init_verbs = { alc662_init_verbs,
18759 alc663_two_hp_amic_m1_init_verbs },
18760 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18761 .hp_nid = 0x03,
18762 .dac_nids = alc662_dac_nids,
18763 .dig_out_nid = ALC662_DIGOUT_NID,
18764 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18765 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018766 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018767 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018768 .init_hook = alc663_mode3_inithook,
18769 },
18770 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018771 .mixers = { alc663_asus_21jd_clfe_mixer },
18772 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018773 .init_verbs = { alc662_init_verbs,
18774 alc663_21jd_amic_init_verbs},
18775 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18776 .hp_nid = 0x03,
18777 .dac_nids = alc662_dac_nids,
18778 .dig_out_nid = ALC662_DIGOUT_NID,
18779 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18780 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018781 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018782 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018783 .init_hook = alc663_mode4_inithook,
18784 },
18785 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018786 .mixers = { alc663_asus_15jd_clfe_mixer },
18787 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018788 .init_verbs = { alc662_init_verbs,
18789 alc663_15jd_amic_init_verbs },
18790 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18791 .hp_nid = 0x03,
18792 .dac_nids = alc662_dac_nids,
18793 .dig_out_nid = ALC662_DIGOUT_NID,
18794 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18795 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018796 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018797 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018798 .init_hook = alc663_mode5_inithook,
18799 },
18800 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018801 .mixers = { alc663_two_hp_m2_mixer },
18802 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018803 .init_verbs = { alc662_init_verbs,
18804 alc663_two_hp_amic_m2_init_verbs },
18805 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18806 .hp_nid = 0x03,
18807 .dac_nids = alc662_dac_nids,
18808 .dig_out_nid = ALC662_DIGOUT_NID,
18809 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18810 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018811 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018812 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018813 .init_hook = alc663_mode6_inithook,
18814 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018815 [ALC663_ASUS_MODE7] = {
18816 .mixers = { alc663_mode7_mixer },
18817 .cap_mixer = alc662_auto_capture_mixer,
18818 .init_verbs = { alc662_init_verbs,
18819 alc663_mode7_init_verbs },
18820 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18821 .hp_nid = 0x03,
18822 .dac_nids = alc662_dac_nids,
18823 .dig_out_nid = ALC662_DIGOUT_NID,
18824 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18825 .channel_mode = alc662_3ST_2ch_modes,
18826 .unsol_event = alc663_mode7_unsol_event,
18827 .setup = alc663_mode7_setup,
18828 .init_hook = alc663_mode7_inithook,
18829 },
18830 [ALC663_ASUS_MODE8] = {
18831 .mixers = { alc663_mode8_mixer },
18832 .cap_mixer = alc662_auto_capture_mixer,
18833 .init_verbs = { alc662_init_verbs,
18834 alc663_mode8_init_verbs },
18835 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18836 .hp_nid = 0x03,
18837 .dac_nids = alc662_dac_nids,
18838 .dig_out_nid = ALC662_DIGOUT_NID,
18839 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18840 .channel_mode = alc662_3ST_2ch_modes,
18841 .unsol_event = alc663_mode8_unsol_event,
18842 .setup = alc663_mode8_setup,
18843 .init_hook = alc663_mode8_inithook,
18844 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018845 [ALC272_DELL] = {
18846 .mixers = { alc663_m51va_mixer },
18847 .cap_mixer = alc272_auto_capture_mixer,
18848 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
18849 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18850 .dac_nids = alc662_dac_nids,
18851 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18852 .adc_nids = alc272_adc_nids,
18853 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18854 .capsrc_nids = alc272_capsrc_nids,
18855 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018856 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018857 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018858 .init_hook = alc663_m51va_inithook,
18859 },
18860 [ALC272_DELL_ZM1] = {
18861 .mixers = { alc663_m51va_mixer },
18862 .cap_mixer = alc662_auto_capture_mixer,
18863 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
18864 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18865 .dac_nids = alc662_dac_nids,
18866 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18867 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018868 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018869 .capsrc_nids = alc662_capsrc_nids,
18870 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018871 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018872 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018873 .init_hook = alc663_m51va_inithook,
18874 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018875 [ALC272_SAMSUNG_NC10] = {
18876 .mixers = { alc272_nc10_mixer },
18877 .init_verbs = { alc662_init_verbs,
18878 alc663_21jd_amic_init_verbs },
18879 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18880 .dac_nids = alc272_dac_nids,
18881 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18882 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018883 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020018884 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018885 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018886 .init_hook = alc663_mode4_inithook,
18887 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018888};
18889
18890
18891/*
18892 * BIOS auto configuration
18893 */
18894
Takashi Iwai7085ec12009-10-02 09:03:58 +020018895/* convert from MIX nid to DAC */
18896static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
18897{
18898 if (nid == 0x0f)
18899 return 0x02;
18900 else if (nid >= 0x0c && nid <= 0x0e)
18901 return nid - 0x0c + 0x02;
18902 else
18903 return 0;
18904}
18905
18906/* get MIX nid connected to the given pin targeted to DAC */
18907static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
18908 hda_nid_t dac)
18909{
18910 hda_nid_t mix[4];
18911 int i, num;
18912
18913 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18914 for (i = 0; i < num; i++) {
18915 if (alc662_mix_to_dac(mix[i]) == dac)
18916 return mix[i];
18917 }
18918 return 0;
18919}
18920
18921/* look for an empty DAC slot */
18922static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
18923{
18924 struct alc_spec *spec = codec->spec;
18925 hda_nid_t srcs[5];
18926 int i, j, num;
18927
18928 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
18929 if (num < 0)
18930 return 0;
18931 for (i = 0; i < num; i++) {
18932 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
18933 if (!nid)
18934 continue;
18935 for (j = 0; j < spec->multiout.num_dacs; j++)
18936 if (spec->multiout.dac_nids[j] == nid)
18937 break;
18938 if (j >= spec->multiout.num_dacs)
18939 return nid;
18940 }
18941 return 0;
18942}
18943
18944/* fill in the dac_nids table from the parsed pin configuration */
18945static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18946 const struct auto_pin_cfg *cfg)
18947{
18948 struct alc_spec *spec = codec->spec;
18949 int i;
18950 hda_nid_t dac;
18951
18952 spec->multiout.dac_nids = spec->private_dac_nids;
18953 for (i = 0; i < cfg->line_outs; i++) {
18954 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
18955 if (!dac)
18956 continue;
18957 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
18958 }
18959 return 0;
18960}
18961
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018962static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018963 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018964{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018965 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018966 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18967}
18968
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018969static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018970 hda_nid_t nid, unsigned int chs)
18971{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018972 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018973 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
18974}
18975
18976#define alc662_add_stereo_vol(spec, pfx, nid) \
18977 alc662_add_vol_ctl(spec, pfx, nid, 3)
18978#define alc662_add_stereo_sw(spec, pfx, nid) \
18979 alc662_add_sw_ctl(spec, pfx, nid, 3)
18980
18981/* add playback controls from the parsed DAC table */
18982static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
18983 const struct auto_pin_cfg *cfg)
18984{
18985 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018986 static const char *chname[4] = {
18987 "Front", "Surround", NULL /*CLFE*/, "Side"
18988 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020018989 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018990 int i, err;
18991
18992 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018993 nid = spec->multiout.dac_nids[i];
18994 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018995 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018996 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
18997 if (!mix)
18998 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018999 if (i == 2) {
19000 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019001 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019002 if (err < 0)
19003 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019004 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019005 if (err < 0)
19006 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019007 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019008 if (err < 0)
19009 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019010 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019011 if (err < 0)
19012 return err;
19013 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020019014 const char *pfx;
19015 if (cfg->line_outs == 1 &&
19016 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019017 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020019018 pfx = "Speaker";
19019 else
19020 pfx = "PCM";
19021 } else
19022 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019023 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019024 if (err < 0)
19025 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020019026 if (cfg->line_outs == 1 &&
19027 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19028 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020019029 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019030 if (err < 0)
19031 return err;
19032 }
19033 }
19034 return 0;
19035}
19036
19037/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019038/* return DAC nid if any new DAC is assigned */
19039static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019040 const char *pfx)
19041{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019042 struct alc_spec *spec = codec->spec;
19043 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019044 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019045
19046 if (!pin)
19047 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019048 nid = alc662_look_for_dac(codec, pin);
19049 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019050 /* the corresponding DAC is already occupied */
19051 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
19052 return 0; /* no way */
19053 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019054 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019055 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19056 }
19057
19058 mix = alc662_dac_to_mix(codec, pin, nid);
19059 if (!mix)
19060 return 0;
19061 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
19062 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020019063 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019064 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
19065 if (err < 0)
19066 return err;
19067 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019068}
19069
19070/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020019071#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020019072 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019073
19074static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
19075 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019076 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019077{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019078 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020019079 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019080
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019081 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019082 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019083 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
19084 if (num <= 1)
19085 return;
19086 for (i = 0; i < num; i++) {
19087 if (alc662_mix_to_dac(srcs[i]) != dac)
19088 continue;
19089 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
19090 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019091 }
19092}
19093
19094static void alc662_auto_init_multi_out(struct hda_codec *codec)
19095{
19096 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019097 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019098 int i;
19099
19100 for (i = 0; i <= HDA_SIDE; i++) {
19101 hda_nid_t nid = spec->autocfg.line_out_pins[i];
19102 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020019103 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019104 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019105 }
19106}
19107
19108static void alc662_auto_init_hp_out(struct hda_codec *codec)
19109{
19110 struct alc_spec *spec = codec->spec;
19111 hda_nid_t pin;
19112
19113 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019114 if (pin)
19115 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
19116 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019117 pin = spec->autocfg.speaker_pins[0];
19118 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019119 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
19120 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019121}
19122
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019123#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
19124
19125static void alc662_auto_init_analog_input(struct hda_codec *codec)
19126{
19127 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019128 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019129 int i;
19130
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019131 for (i = 0; i < cfg->num_inputs; i++) {
19132 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019133 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020019134 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010019135 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010019136 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019137 snd_hda_codec_write(codec, nid, 0,
19138 AC_VERB_SET_AMP_GAIN_MUTE,
19139 AMP_OUT_MUTE);
19140 }
19141 }
19142}
19143
Takashi Iwaif511b012008-08-15 16:46:42 +020019144#define alc662_auto_init_input_src alc882_auto_init_input_src
19145
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019146static int alc662_parse_auto_config(struct hda_codec *codec)
19147{
19148 struct alc_spec *spec = codec->spec;
19149 int err;
19150 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
19151
19152 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19153 alc662_ignore);
19154 if (err < 0)
19155 return err;
19156 if (!spec->autocfg.line_outs)
19157 return 0; /* can't find valid BIOS pin config */
19158
Takashi Iwai7085ec12009-10-02 09:03:58 +020019159 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019160 if (err < 0)
19161 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019162 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019163 if (err < 0)
19164 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019165 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019166 spec->autocfg.speaker_pins[0],
19167 "Speaker");
19168 if (err < 0)
19169 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019170 if (err)
19171 spec->multiout.extra_out_nid[0] = err;
19172 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019173 "Headphone");
19174 if (err < 0)
19175 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019176 if (err)
19177 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019178 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019179 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019180 return err;
19181
19182 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
19183
Takashi Iwai757899a2010-07-30 10:48:14 +020019184 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019185
Takashi Iwai603c4012008-07-30 15:01:44 +020019186 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010019187 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019188
19189 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020019190 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020019191
Kailang Yangcec27c82010-02-04 14:18:18 +010019192 add_verb(spec, alc662_init_verbs);
19193 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019194 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Kailang Yangcec27c82010-02-04 14:18:18 +010019195 add_verb(spec, alc663_init_verbs);
19196
19197 if (codec->vendor_id == 0x10ec0272)
19198 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020019199
19200 err = alc_auto_add_mic_boost(codec);
19201 if (err < 0)
19202 return err;
19203
Kailang Yang6227cdc2010-02-25 08:36:52 +010019204 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
19205 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
19206 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
19207 else
19208 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020019209
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019210 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019211}
19212
19213/* additional initialization for auto-configuration model */
19214static void alc662_auto_init(struct hda_codec *codec)
19215{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019216 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019217 alc662_auto_init_multi_out(codec);
19218 alc662_auto_init_hp_out(codec);
19219 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020019220 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019221 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019222 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020019223 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019224}
19225
David Henningsson6cb3b702010-09-09 08:51:44 +020019226enum {
19227 ALC662_FIXUP_IDEAPAD,
19228};
19229
19230static const struct alc_fixup alc662_fixups[] = {
19231 [ALC662_FIXUP_IDEAPAD] = {
19232 .pins = (const struct alc_pincfg[]) {
19233 { 0x17, 0x99130112 }, /* subwoofer */
19234 { }
19235 }
19236 },
19237};
19238
19239static struct snd_pci_quirk alc662_fixup_tbl[] = {
19240 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
19241 {}
19242};
19243
19244
19245
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019246static int patch_alc662(struct hda_codec *codec)
19247{
19248 struct alc_spec *spec;
19249 int err, board_config;
19250
19251 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19252 if (!spec)
19253 return -ENOMEM;
19254
19255 codec->spec = spec;
19256
Kailang Yangda00c242010-03-19 11:23:45 +010019257 alc_auto_parse_customize_define(codec);
19258
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020019259 alc_fix_pll_init(codec, 0x20, 0x04, 15);
19260
Kailang Yangc027ddc2010-03-19 11:33:06 +010019261 if (alc_read_coef_idx(codec, 0) == 0x8020)
19262 alc_codec_rename(codec, "ALC661");
19263 else if ((alc_read_coef_idx(codec, 0) & (1 << 14)) &&
19264 codec->bus->pci->subsystem_vendor == 0x1025 &&
19265 spec->cdefine.platform_type == 1)
19266 alc_codec_rename(codec, "ALC272X");
Kailang Yang274693f2009-12-03 10:07:50 +010019267
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019268 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19269 alc662_models,
19270 alc662_cfg_tbl);
19271 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019272 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19273 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019274 board_config = ALC662_AUTO;
19275 }
19276
19277 if (board_config == ALC662_AUTO) {
David Henningsson6cb3b702010-09-09 08:51:44 +020019278 alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019279 /* automatic parse from the BIOS config */
19280 err = alc662_parse_auto_config(codec);
19281 if (err < 0) {
19282 alc_free(codec);
19283 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019284 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019285 printk(KERN_INFO
19286 "hda_codec: Cannot set up configuration "
19287 "from BIOS. Using base mode...\n");
19288 board_config = ALC662_3ST_2ch_DIG;
19289 }
19290 }
19291
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019292 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019293 err = snd_hda_attach_beep_device(codec, 0x1);
19294 if (err < 0) {
19295 alc_free(codec);
19296 return err;
19297 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019298 }
19299
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019300 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019301 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019302
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019303 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19304 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19305
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019306 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19307 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19308
Takashi Iwaidd704692009-08-11 08:45:11 +020019309 if (!spec->adc_nids) {
19310 spec->adc_nids = alc662_adc_nids;
19311 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19312 }
19313 if (!spec->capsrc_nids)
19314 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019315
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019316 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019317 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019318
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019319 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019320 switch (codec->vendor_id) {
19321 case 0x10ec0662:
19322 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19323 break;
19324 case 0x10ec0272:
19325 case 0x10ec0663:
19326 case 0x10ec0665:
19327 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19328 break;
19329 case 0x10ec0273:
19330 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19331 break;
19332 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019333 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019334 spec->vmaster_nid = 0x02;
19335
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019336 codec->patch_ops = alc_patch_ops;
David Henningsson6cb3b702010-09-09 08:51:44 +020019337 if (board_config == ALC662_AUTO) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019338 spec->init_hook = alc662_auto_init;
David Henningsson6cb3b702010-09-09 08:51:44 +020019339 alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 0);
19340 }
19341
Takashi Iwaicb53c622007-08-10 17:21:45 +020019342#ifdef CONFIG_SND_HDA_POWER_SAVE
19343 if (!spec->loopback.amplist)
19344 spec->loopback.amplist = alc662_loopbacks;
19345#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019346
19347 return 0;
19348}
19349
Kailang Yang274693f2009-12-03 10:07:50 +010019350static int patch_alc888(struct hda_codec *codec)
19351{
19352 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19353 kfree(codec->chip_name);
19354 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019355 if (!codec->chip_name) {
19356 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019357 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019358 }
19359 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019360 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019361 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019362}
19363
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019364/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019365 * ALC680 support
19366 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019367#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019368#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19369#define alc680_modes alc260_modes
19370
19371static hda_nid_t alc680_dac_nids[3] = {
19372 /* Lout1, Lout2, hp */
19373 0x02, 0x03, 0x04
19374};
19375
19376static hda_nid_t alc680_adc_nids[3] = {
19377 /* ADC0-2 */
19378 /* DMIC, MIC, Line-in*/
19379 0x07, 0x08, 0x09
19380};
19381
Kailang Yangc69aefa2010-08-17 10:39:22 +020019382/*
19383 * Analog capture ADC cgange
19384 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019385static void alc680_rec_autoswitch(struct hda_codec *codec)
19386{
19387 struct alc_spec *spec = codec->spec;
19388 struct auto_pin_cfg *cfg = &spec->autocfg;
19389 int pin_found = 0;
19390 int type_found = AUTO_PIN_LAST;
19391 hda_nid_t nid;
19392 int i;
19393
19394 for (i = 0; i < cfg->num_inputs; i++) {
19395 nid = cfg->inputs[i].pin;
19396 if (!(snd_hda_query_pin_caps(codec, nid) &
19397 AC_PINCAP_PRES_DETECT))
19398 continue;
19399 if (snd_hda_jack_detect(codec, nid)) {
19400 if (cfg->inputs[i].type < type_found) {
19401 type_found = cfg->inputs[i].type;
19402 pin_found = nid;
19403 }
19404 }
19405 }
19406
19407 nid = 0x07;
19408 if (pin_found)
19409 snd_hda_get_connections(codec, pin_found, &nid, 1);
19410
19411 if (nid != spec->cur_adc)
19412 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19413 spec->cur_adc = nid;
19414 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19415 spec->cur_adc_format);
19416}
19417
Kailang Yangc69aefa2010-08-17 10:39:22 +020019418static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19419 struct hda_codec *codec,
19420 unsigned int stream_tag,
19421 unsigned int format,
19422 struct snd_pcm_substream *substream)
19423{
19424 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019425
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019426 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019427 spec->cur_adc_stream_tag = stream_tag;
19428 spec->cur_adc_format = format;
19429
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019430 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019431 return 0;
19432}
19433
19434static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19435 struct hda_codec *codec,
19436 struct snd_pcm_substream *substream)
19437{
19438 snd_hda_codec_cleanup_stream(codec, 0x07);
19439 snd_hda_codec_cleanup_stream(codec, 0x08);
19440 snd_hda_codec_cleanup_stream(codec, 0x09);
19441 return 0;
19442}
19443
19444static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19445 .substreams = 1, /* can be overridden */
19446 .channels_min = 2,
19447 .channels_max = 2,
19448 /* NID is set in alc_build_pcms */
19449 .ops = {
19450 .prepare = alc680_capture_pcm_prepare,
19451 .cleanup = alc680_capture_pcm_cleanup
19452 },
19453};
19454
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019455static struct snd_kcontrol_new alc680_base_mixer[] = {
19456 /* output mixer control */
19457 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19458 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19459 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19460 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019461 HDA_CODEC_VOLUME("Int Mic Boost", 0x12, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019462 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019463 HDA_CODEC_VOLUME("Line In Boost", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019464 { }
19465};
19466
Kailang Yangc69aefa2010-08-17 10:39:22 +020019467static struct hda_bind_ctls alc680_bind_cap_vol = {
19468 .ops = &snd_hda_bind_vol,
19469 .values = {
19470 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19471 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19472 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19473 0
19474 },
19475};
19476
19477static struct hda_bind_ctls alc680_bind_cap_switch = {
19478 .ops = &snd_hda_bind_sw,
19479 .values = {
19480 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19481 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19482 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19483 0
19484 },
19485};
19486
19487static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19488 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19489 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019490 { } /* end */
19491};
19492
19493/*
19494 * generic initialization of ADC, input mixers and output mixers
19495 */
19496static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019497 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19498 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19499 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019500
Kailang Yangc69aefa2010-08-17 10:39:22 +020019501 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19502 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19503 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19504 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19505 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19506 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019507
19508 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19509 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19510 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19511 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19512 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019513
19514 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19515 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019516 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019517
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019518 { }
19519};
19520
Kailang Yangc69aefa2010-08-17 10:39:22 +020019521/* toggle speaker-output according to the hp-jack state */
19522static void alc680_base_setup(struct hda_codec *codec)
19523{
19524 struct alc_spec *spec = codec->spec;
19525
19526 spec->autocfg.hp_pins[0] = 0x16;
19527 spec->autocfg.speaker_pins[0] = 0x14;
19528 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019529 spec->autocfg.num_inputs = 2;
19530 spec->autocfg.inputs[0].pin = 0x18;
19531 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19532 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019533 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019534}
19535
19536static void alc680_unsol_event(struct hda_codec *codec,
19537 unsigned int res)
19538{
19539 if ((res >> 26) == ALC880_HP_EVENT)
19540 alc_automute_amp(codec);
19541 if ((res >> 26) == ALC880_MIC_EVENT)
19542 alc680_rec_autoswitch(codec);
19543}
19544
19545static void alc680_inithook(struct hda_codec *codec)
19546{
19547 alc_automute_amp(codec);
19548 alc680_rec_autoswitch(codec);
19549}
19550
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019551/* create input playback/capture controls for the given pin */
19552static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19553 const char *ctlname, int idx)
19554{
19555 hda_nid_t dac;
19556 int err;
19557
19558 switch (nid) {
19559 case 0x14:
19560 dac = 0x02;
19561 break;
19562 case 0x15:
19563 dac = 0x03;
19564 break;
19565 case 0x16:
19566 dac = 0x04;
19567 break;
19568 default:
19569 return 0;
19570 }
19571 if (spec->multiout.dac_nids[0] != dac &&
19572 spec->multiout.dac_nids[1] != dac) {
19573 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19574 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19575 HDA_OUTPUT));
19576 if (err < 0)
19577 return err;
19578
19579 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19580 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19581
19582 if (err < 0)
19583 return err;
19584 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19585 }
19586
19587 return 0;
19588}
19589
19590/* add playback controls from the parsed DAC table */
19591static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19592 const struct auto_pin_cfg *cfg)
19593{
19594 hda_nid_t nid;
19595 int err;
19596
19597 spec->multiout.dac_nids = spec->private_dac_nids;
19598
19599 nid = cfg->line_out_pins[0];
19600 if (nid) {
19601 const char *name;
19602 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19603 name = "Speaker";
19604 else
19605 name = "Front";
19606 err = alc680_new_analog_output(spec, nid, name, 0);
19607 if (err < 0)
19608 return err;
19609 }
19610
19611 nid = cfg->speaker_pins[0];
19612 if (nid) {
19613 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19614 if (err < 0)
19615 return err;
19616 }
19617 nid = cfg->hp_pins[0];
19618 if (nid) {
19619 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19620 if (err < 0)
19621 return err;
19622 }
19623
19624 return 0;
19625}
19626
19627static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19628 hda_nid_t nid, int pin_type)
19629{
19630 alc_set_pin_output(codec, nid, pin_type);
19631}
19632
19633static void alc680_auto_init_multi_out(struct hda_codec *codec)
19634{
19635 struct alc_spec *spec = codec->spec;
19636 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19637 if (nid) {
19638 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19639 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19640 }
19641}
19642
19643static void alc680_auto_init_hp_out(struct hda_codec *codec)
19644{
19645 struct alc_spec *spec = codec->spec;
19646 hda_nid_t pin;
19647
19648 pin = spec->autocfg.hp_pins[0];
19649 if (pin)
19650 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19651 pin = spec->autocfg.speaker_pins[0];
19652 if (pin)
19653 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19654}
19655
19656/* pcm configuration: identical with ALC880 */
19657#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19658#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19659#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19660#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019661#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019662
19663/*
19664 * BIOS auto configuration
19665 */
19666static int alc680_parse_auto_config(struct hda_codec *codec)
19667{
19668 struct alc_spec *spec = codec->spec;
19669 int err;
19670 static hda_nid_t alc680_ignore[] = { 0 };
19671
19672 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19673 alc680_ignore);
19674 if (err < 0)
19675 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019676
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019677 if (!spec->autocfg.line_outs) {
19678 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19679 spec->multiout.max_channels = 2;
19680 spec->no_analog = 1;
19681 goto dig_only;
19682 }
19683 return 0; /* can't find valid BIOS pin config */
19684 }
19685 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19686 if (err < 0)
19687 return err;
19688
19689 spec->multiout.max_channels = 2;
19690
19691 dig_only:
19692 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019693 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019694 if (spec->kctls.list)
19695 add_mixer(spec, spec->kctls.list);
19696
19697 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019698
19699 err = alc_auto_add_mic_boost(codec);
19700 if (err < 0)
19701 return err;
19702
19703 return 1;
19704}
19705
19706#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19707
19708/* init callback for auto-configuration model -- overriding the default init */
19709static void alc680_auto_init(struct hda_codec *codec)
19710{
19711 struct alc_spec *spec = codec->spec;
19712 alc680_auto_init_multi_out(codec);
19713 alc680_auto_init_hp_out(codec);
19714 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019715 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019716 if (spec->unsol_event)
19717 alc_inithook(codec);
19718}
19719
19720/*
19721 * configuration and preset
19722 */
19723static const char *alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019724 [ALC680_BASE] = "base",
19725 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019726};
19727
19728static struct snd_pci_quirk alc680_cfg_tbl[] = {
19729 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19730 {}
19731};
19732
19733static struct alc_config_preset alc680_presets[] = {
19734 [ALC680_BASE] = {
19735 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019736 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019737 .init_verbs = { alc680_init_verbs },
19738 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19739 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019740 .dig_out_nid = ALC680_DIGOUT_NID,
19741 .num_channel_mode = ARRAY_SIZE(alc680_modes),
19742 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020019743 .unsol_event = alc680_unsol_event,
19744 .setup = alc680_base_setup,
19745 .init_hook = alc680_inithook,
19746
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019747 },
19748};
19749
19750static int patch_alc680(struct hda_codec *codec)
19751{
19752 struct alc_spec *spec;
19753 int board_config;
19754 int err;
19755
19756 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19757 if (spec == NULL)
19758 return -ENOMEM;
19759
19760 codec->spec = spec;
19761
19762 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
19763 alc680_models,
19764 alc680_cfg_tbl);
19765
19766 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
19767 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19768 codec->chip_name);
19769 board_config = ALC680_AUTO;
19770 }
19771
19772 if (board_config == ALC680_AUTO) {
19773 /* automatic parse from the BIOS config */
19774 err = alc680_parse_auto_config(codec);
19775 if (err < 0) {
19776 alc_free(codec);
19777 return err;
19778 } else if (!err) {
19779 printk(KERN_INFO
19780 "hda_codec: Cannot set up configuration "
19781 "from BIOS. Using base mode...\n");
19782 board_config = ALC680_BASE;
19783 }
19784 }
19785
19786 if (board_config != ALC680_AUTO)
19787 setup_preset(codec, &alc680_presets[board_config]);
19788
19789 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019790 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019791 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019792 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019793
19794 if (!spec->adc_nids) {
19795 spec->adc_nids = alc680_adc_nids;
19796 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
19797 }
19798
19799 if (!spec->cap_mixer)
19800 set_capture_mixer(codec);
19801
19802 spec->vmaster_nid = 0x02;
19803
19804 codec->patch_ops = alc_patch_ops;
19805 if (board_config == ALC680_AUTO)
19806 spec->init_hook = alc680_auto_init;
19807
19808 return 0;
19809}
19810
19811/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070019812 * patch entries
19813 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019814static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070019815 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019816 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019817 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020019818 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019819 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019820 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020019821 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019822 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019823 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019824 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019825 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
19826 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
19827 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019828 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019829 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019830 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
19831 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020019832 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010019833 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010019834 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019835 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019836 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019837 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019838 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020019839 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019840 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020019841 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019842 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019843 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019844 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020019845 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019846 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019847 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019848 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019849 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019850 {} /* terminator */
19851};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019852
19853MODULE_ALIAS("snd-hda-codec-id:10ec*");
19854
19855MODULE_LICENSE("GPL");
19856MODULE_DESCRIPTION("Realtek HD-audio codec");
19857
19858static struct hda_codec_preset_list realtek_list = {
19859 .preset = snd_hda_preset_realtek,
19860 .owner = THIS_MODULE,
19861};
19862
19863static int __init patch_realtek_init(void)
19864{
19865 return snd_hda_add_codec_preset(&realtek_list);
19866}
19867
19868static void __exit patch_realtek_exit(void)
19869{
19870 snd_hda_delete_codec_preset(&realtek_list);
19871}
19872
19873module_init(patch_realtek_init)
19874module_exit(patch_realtek_exit)